Closed bradoyler closed 12 years ago
public ActionResult TranscribeCallback(string CallSid, string TranscriptionText, string RecordingUrl) { ... }
I have a requirement to record a users vocal response, then get a transcript of the users vocal response and read it out to the user. Below are the steps.
**- Caller calls the twlio number
Twilio - Please say somthing?
Caller - ABC1234
Twilio - Record Completed. Waiting for Transcription.
Twilio - You said ABC1234, Good Bye**
Below is the code I did so far using, ASP.NET MVC.
`// below code gets users initial vocal response, records and then transcribes it
[HttpPost]
public ActionResult Welcome()
{
var response = new VoiceResponse();
try
{
response.Say("Please say something \n", Say.VoiceEnum.Alice, 1, Say.LanguageEnum.EnGb);
// record and transcribe users voice
response.Record(
timeout: 30,
maxLength: 30,
playBeep: true,
action: new Uri(NgRokPath+ "/RecordingCompleted"),
transcribe: true,
transcribeCallback: new Uri(NgRokPath + "/TranscribeCallback"),
finishOnKey: "*");
response.Say("I did not receive a recording");
}
catch (Exception e)
{
ErrorLog.LogError(e, "Error within ivr/Welcome");
response = RejectCall();
}
return TwiML(response);
}
`
Below is the action result I wrote for voice record completion,
` [HttpPost] public TwiMLResult RecordingCompleted() { var response = new VoiceResponse(); try { var recordingSid = Request.Params["RecordingSid"]; var status = Request.Params["CallStatus"]; var duration = int.Parse(Request.Params["RecordingDuration"]); var url = Request.Params["RecordingUrl"];
// reading the transcibed result
response.Say("Recoding Completed. Waiting for transcription, \n");
}
catch (Exception e)
{
ErrorLog.LogError(e, "Error within ivr/RecordingCompleted");
response.Say(ConversationHelper.NothingReceived, ConversationHelper.SpeakVoice, 1, ConversationHelper.SpeakLanguage);
}
return TwiML(response);
}`
Below is the transcribe call back. In this action I need to read out the transcribed text to the user and Hang up the call.
`//https://www.twilio.com/docs/voice/tutorials/ivr-screening-csharp-mvc [HttpPost] public ActionResult TranscribeCallback(string CallSid, string TranscriptionText, string RecordingUrl) { var response = new VoiceResponse(); try { response.Say($"Transcribed message is,\n {TranscriptionText}");
// done
response.Say("Good Bye", Say.VoiceEnum.Alice, null, Say.LanguageEnum.EnGb);
}
catch (Exception e)
{
ErrorLog.LogError(e, "Error within ivr/TranscribeCallback");
response.Say(ConversationHelper.NothingReceived, ConversationHelper.SpeakVoice, 1, ConversationHelper.SpeakLanguage);
response.Say("Goodbye");
}
response.Hangup();
return TwiML(response);
}`
Problem - The call gets hangup, before the execution of the TranscribeCallback action method. So, the coversation currently goes like below,
**- Caller calls the twlio number
Call finishes with above, but does not read out the transcribed output (- Twilio - You said ABC1234, Good Bye).
Maybe Im missing something. Any help to solve this is much appreciated. Thanks.
Looking at ur sample voicemail mvc app (http://john-sheehan.com/blog/building-a-simple-voicemail-system-with-twilio-and-aspnet-mvc-part-2/) and was wondering how you'd modify to add voicemail transcription. Specifically, what would the "transcribed" ActionResult look like? Thx,