如何使用C#在Twilio voice中的语音提示选项之间添加停顿?

如何使用C#在Twilio voice中的语音提示选项之间添加停顿?,c#,twilio,twilio-twiml,twilio-programmable-voice,C#,Twilio,Twilio Twiml,Twilio Programmable Voice,我希望能够通过使用C#(在C#/Core Web应用程序中)中的Twilio Voice(TwiML)编辑以下代码来完成以下任务: 在语音提示选项之间添加300毫秒的短暂停顿 在提示中为某些单词添加强调符号(例如,朋友、互联网、, (其他等) 允许用户说“friend”并中断读出,这反过来调用动作uri Twilio提供了一个如何在上标记“Say”对象的示例,但没有说明如何将其与聚集对象合并。似乎合并Say就是一个诀窍,这样听者就可以在任何时候通过说“friend”来中断选择,跳过其余的选择

我希望能够通过使用C#(在C#/Core Web应用程序中)中的Twilio Voice(TwiML)编辑以下代码来完成以下任务:

  • 在语音提示选项之间添加300毫秒的短暂停顿
  • 在提示中为某些单词添加强调符号(例如,朋友、互联网、, (其他等)
  • 允许用户说“friend”并中断读出,这反过来调用动作uri
Twilio提供了一个如何在上标记“Say”对象的示例,但没有说明如何将其与聚集对象合并。似乎合并Say就是一个诀窍,这样听者就可以在任何时候通过说“friend”来中断选择,跳过其余的选择读出,并调用actionuri

我已经能够构建一个聚集对象并附加单独的Say方法,如下面的示例代码所示。请注意,下面的代码是编译并运行的,但我不知道如何在选项之间暂停文本到语音的读出,让人有300毫秒的时间脱口而出“朋友”。此外,当您说“friend”时,它似乎要等待整个三秒钟的默认值,而不是将其识别为用户输入并更快地调用动作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));
}
私有静态无效RenderFerralSource(语音响应)
{
string hintchoices=“朋友、互联网、其他,”;
列出两个HDTMFandSpeech=
新列表(2){Gather.InputEnum.Dtmf,Gather.InputEnum.Speech};
var mygather=新聚集(输入:bothDtmfAndSpeech,
操作:新建Uri(“/voice/GatherReferralSource”,UriKind.Relative),
speechModel:Gather.SpeechModelEnum.NumbersAndCommands,
对,,
提示:hintchoices,
巴金:是的,
演讲暂停:“3”,
numDigits:1);
mygather.说(“你是怎么找到我们的,或者是谁推荐你来我们的诊所的?”,声音:“Polly.Joanna”);
string digmenu=“我将阅读五个选项的列表。按数字或说出单词”;
digmenu+=“只要你听到推荐你的人的正确选择,”;
mygather.Say(digmenu);
mygather.Say(“如果我们的朋友、家人或其他客户推荐您,请按1或说Friend,”);
mygather.Say(“按2,或者说互联网,如果你在谷歌上或通过互联网搜索找到我们,”);
比如(“按3,或者说火星人,如果有火星人推荐你,”);
mygather.Say(“按4,或者说Chuck Norris,如果他命令你访问我们,”);
mygather.Say(“按5,或以任何其他方式说其他,”);
//询问用户并收集响应
Append(mygather);
//如果没有选择,重定向
重定向(新Uri(“/voice”,UriKind.Relative));
}

似乎超时或speechTimeout都应该设置等待响应。奇怪的是,您将其设置为字符串而不是int。您是正确的。我想这可能会解决我的一个问题。我将在speechtimeout设置为自动的情况下尝试,看看会发生什么。Jakub,谢谢!将speechtimeout设置为“自动”有效。我还试图将它设置为整数而不是字符串,但C#不会编译它,除非它是字符串。因此,将其设置为“自动”作为字符串起作用。解决了三个问题中的两个。我现在可以通过在每个.say(“要说的文本”)方法之前预先挂起.pause(1)方法来暂停,就像在mygather.pause(1).say(“要说的文本”)中一样;你不能停顿一秒钟。我希望在毫秒范围内有更多的控制,就像使用Break方法一样,可以在Say对象上使用,该对象在聚集上没有后缀。最后一个难题是如何使用Say对象进行强调和其他微调。使用SSML,文本到语音-,这将允许您在使用Polly voices时控制TTS。