问题描述
我希望能够通过在C#(在C#/ Core Web应用程序中)中使用Twilio语音(TwiML)编辑以下代码来完成以下工作:
Twilio有一个示例,说明如何在https://www.twilio.com/docs/voice/twiml/say/text-speech处标记“说”对象,但没有说明如何将其与收集对象合并。似乎说说合并是一种诀窍,以便听者可以在任何时候通过说“朋友”来打断选择,跳过其余选择的读出,并调用动作Uri。
我已经能够构造一个collect对象并追加单独的Say方法,如下面的示例代码所示。请注意,下面的代码可以编译和工作,但是我不知道如何在选项之间暂停文本到语音的读取,以使人有300ms的时间来脱口而出“朋友”。同样,当您说“朋友”时,似乎要等待整个三秒钟的默认时间,而不是意识到这是用户输入并更快地调用操作uri。使用键盘数字可以按需工作,但是我想获得语音转文本功能,以更有效地工作。
以下是我相关的“使用”声明:
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Twilio.AspNet.Common;
using Twilio.AspNet.Core;
using Twilio.TwiML;
using Twilio.TwiML.Voice;
这是我正在研究的班级中的函数:
private static void RenderReferralSource(VoiceResponse response)
{
string hintchoices = "friend,internet,other,";
List<Gather.InputEnum> bothDtmfAndSpeech =
new List<Gather.InputEnum>(2) { Gather.InputEnum.Dtmf,Gather.InputEnum.Speech };
var mygather = new Gather(input: bothDtmfAndSpeech,action: new Uri("/voice/GatherReferralSource",UriKind.Relative),speechModel: Gather.SpeechModelEnum.NumbersAndCommands,enhanced: true,hints: hintchoices,bargeIn: true,speechTimeout: "3",numDigits: 1);
mygather.Say("How did you find us,or who referred you to our practice?",voice: "Polly.Joanna-Neural");
string digmenu = "I will read a list of five choices. Press the number or say the word ";
digmenu += "as soon as you hear the correct choice of who referred you,";
mygather.Say(digmenu);
mygather.Say("Press 1,or say Friend,if a friend,family member,or other customer of ours referred you,");
mygather.Say("Press 2,or say Internet,if you found us on Google or through an internet search,");
mygather.Say("Press 3,or say Martian,if someone from Mars referred you,");
mygather.Say("Press 4,or say Chuck norris,if he ordered you to visit us,");
mygather.Say("Press 5,or say Other,for any other way,");
// Ask user and gather response
response.Append(mygather);
// If no choice,redirect
response.Redirect(new Uri("/voice",UriKind.Relative));
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)