SpeechResult 的 Twilio 语音识别问题
Twilio Speech Recognition Issues with SpeechResult
我有这个项目,我需要在 Twilio 中拨打我的一个号码,说些什么,在用户用他的声音响应播放音频后,我已经 "have" 代码但是 SpeechResult 和 UnstableSpeechResults总是为空。这是我的代码:
[HttpPost]
public ActionResult ReceiveCall()
{
var response = new VoiceResponse();
var gather = new Gather(input: new List<Gather.InputEnum> { Gather.InputEnum.Speech },
action: new Uri("http://eb4cdc87.ngrok.io/Voice/GatherProcess"),
speechTimeout: "5",
method: HttpMethod.Post,
partialResultCallback: new Uri("http://eb4cdc87.ngrok.io/Voice/WriteVoice") ,
partialResultCallbackMethod: HttpMethod.Post);
gather.Say("Say Something to record and after press pound");
gather.Pause(5);
gather.Play(new Uri("https://corn-collie-1715.twil.io/assets/demo.mp3"));
response.Append(gather);
return TwiML(response);
}
[HttpPost]
public void GatherProcess()
{
var response = new VoiceResponse();
var gather = new Gather(input: new List<Gather.InputEnum> { Gather.InputEnum.Speech, Gather.InputEnum.Dtmf });//(input: "speech dtmf", timeout: 3, numDigits: 1);
gather.Say("You say this: " + Request.QueryString["SpeechResult"].ToString());
gather.Pause(5);
gather.Play(new Uri("https://corn-collie-1715.twil.io/assets/demo.mp3"));
response.Append(gather);
}
[HttpPost]
public void WriteVoice()
{
var speech = Request.QueryString["UnstableSpeechResult"].ToString();
if (!String.IsNullOrEmpty(speech))
{
System.IO.File.AppendAllText(Server.MapPath(Path.Combine("~/Content/", "Voice.txt")), "You entered: " + speech + "\n");
}
}
我真的需要这方面的帮助,我知道我遗漏了一些东西,但我不知道是什么,我从 twilio 开始,所以我没有太多经验。
谢谢
终于成功了!
解决方案是使用 Request["SpeechResult"] 而不是 Request.QueryString["SpeechResult"].
谢谢
我有这个项目,我需要在 Twilio 中拨打我的一个号码,说些什么,在用户用他的声音响应播放音频后,我已经 "have" 代码但是 SpeechResult 和 UnstableSpeechResults总是为空。这是我的代码:
[HttpPost]
public ActionResult ReceiveCall()
{
var response = new VoiceResponse();
var gather = new Gather(input: new List<Gather.InputEnum> { Gather.InputEnum.Speech },
action: new Uri("http://eb4cdc87.ngrok.io/Voice/GatherProcess"),
speechTimeout: "5",
method: HttpMethod.Post,
partialResultCallback: new Uri("http://eb4cdc87.ngrok.io/Voice/WriteVoice") ,
partialResultCallbackMethod: HttpMethod.Post);
gather.Say("Say Something to record and after press pound");
gather.Pause(5);
gather.Play(new Uri("https://corn-collie-1715.twil.io/assets/demo.mp3"));
response.Append(gather);
return TwiML(response);
}
[HttpPost]
public void GatherProcess()
{
var response = new VoiceResponse();
var gather = new Gather(input: new List<Gather.InputEnum> { Gather.InputEnum.Speech, Gather.InputEnum.Dtmf });//(input: "speech dtmf", timeout: 3, numDigits: 1);
gather.Say("You say this: " + Request.QueryString["SpeechResult"].ToString());
gather.Pause(5);
gather.Play(new Uri("https://corn-collie-1715.twil.io/assets/demo.mp3"));
response.Append(gather);
}
[HttpPost]
public void WriteVoice()
{
var speech = Request.QueryString["UnstableSpeechResult"].ToString();
if (!String.IsNullOrEmpty(speech))
{
System.IO.File.AppendAllText(Server.MapPath(Path.Combine("~/Content/", "Voice.txt")), "You entered: " + speech + "\n");
}
}
我真的需要这方面的帮助,我知道我遗漏了一些东西,但我不知道是什么,我从 twilio 开始,所以我没有太多经验。
谢谢
终于成功了!
解决方案是使用 Request["SpeechResult"] 而不是 Request.QueryString["SpeechResult"].
谢谢