如何解决如何使用C#在Twilio语音中的语音提示选择之间添加停顿?
我希望能够通过在C#(在C#/ Core Web应用程序中)中使用Twilio语音(TwiML)编辑以下代码来完成以下工作:
- 在语音提示选项之间添加例如300ms的短暂停留
- 在提示中强调某些单词(例如,朋友,互联网, 其他,等等)
- 允许用户说“朋友”并中断读出,这反过来又调用uri操作
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 举报,一经查实,本站将立刻删除。