0

I need to retrieve the transcription of a recording done with the Record Twiml verb but I can't get it to work.

Here's what I've tried:

1. call.php

<Response>    
  <Record maxLength="5" transcribe="true" action="getTranscription.php" />
</Response>

2. getTranscription.php

<Response>
  <Say>Here's your audio recording transcription: <?php echo $_REQUEST['TranscriptionText']; ?></Say>
</Response>

I have no problem recording voice and playing it back with the following code:

1. call.php

<Response>    
  <Record action="getRecording.php" />
</Response>

2. getRecording.php

<Response>
  <Say language="fr-CA">Here's your audio recording.</Say>
  <Play><?php echo $_REQUEST['RecordingUrl']; ?></Play>
</Response>

It would be really appreciated if you guys could give me some hints on how to get the transcription back. Thanks a lot!

1 Answers1

0

Twilio developer evangelist here.

The transcription of a recording is done asynchronously to the call so you won't get the result when you get the webhook to the action URL.

So, you need to provide a transcribeCallback attribute too.

<Response>    
  <Record maxLength="5" transcribe="true" action="getRecordResult.php" transcribeCallback="getTranscription.php" />
</Response>

There is no guarantee on how long the transcription will take, so it's hard to play the transcription back to the caller. It's better to use the transcribeCallback URL to save the transcription alongside the call record.

If you are trying to drive the call based on transcribing the caller's words then using <Record> and transcriptions is not recommended. Instead, I recommend you check out using <Gather> with input="speech". This will give you live voice transcription in the call.

Let me know if this helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88