twilio - 如何在系统说话时阻止用户对 Twilio 的语音输入?
问题描述
如何在系统说话时阻止用户对 Twilio 的语音输入?我有一个<Say> Some long text</Say>
之后应该有来自用户的语音输入。但是,当系统正在阅读长文本时用户说话时,阅读将被中断。我需要用户听完文本,然后才准备好进行语音输入。
可以在 Twilio 中进行吗?
这是我发回的 XML 响应:
`<Response>
<Gather input="speech" action="MyControllername/MyMethodName" speechTimeout="auto">
<Say>Here is my very long confidential text</Say>
</Gather>
<Redirect>/MyControllername/IncorrectOrNoInputMethod</Redirect>
</Response>
`
这是代码:
`public async Task<TwiMLResult> MyMethodName()
{
var response = new VoiceResponse();
var message = await _logic.GetMyLongText(); // This test I get from BL, it is an async method
var gather = new Gather(new [] {Gather.InputEnum.Speech}.ToList(), Url.ActionUri(nameof(AnotherMethodName), ControllerName), speechTimeout: "auto");
gather.Append(new Say(message));
response.Append(gather);
response.Redirect(Url.ActionUri(nameof(IncorrectOrNoInputMethod), ControllerName));
return TwilioResultFrom(response);
}`
解决方案
Twilio 布道者在这里。
你需要让 Say 动词出现在 Gather 之前:
<Response>
<Say>Here is my very long confidential text</Say>
<Gather input="speech" action="MyControllername/MyMethodName" speechTimeout="auto">
</Gather>
<Redirect>/MyControllername/IncorrectOrNoInputMethod</Redirect>
</Response>
因此,在 C# 中,您只需Say
直接在response
对象诗句上调用该方法,并将其附加到gather
:
public async Task<TwiMLResult> MyMethodName()
{
var response = new VoiceResponse();
var message = await _logic.GetMyLongText(); // This test I get from BL, it is an async method
response.Say(message);
var gather = new Gather(new [] {Gather.InputEnum.Speech}.ToList(), Url.ActionUri(nameof(AnotherMethodName), ControllerName), speechTimeout: "auto");
response.Append(gather);
response.Redirect(Url.ActionUri(nameof(IncorrectOrNoInputMethod), ControllerName));
return TwilioResultFrom(response);
}
希望有帮助。
推荐阅读
- php - PhP获取目录中所有文件的内容
- excel - 时间总和,转换为每小时升数 Excel 电子表格
- google-sheets - 从两个不同的单元格获取单元格值
- python - Ubuntu服务器中的文件排列不同
- angular - Angular Material Mat 子菜单点击
- javascript - Laravel Livewire:Foreach 循环中的组件。按钮单击显示所有项目而不是单个项目
- intellij-idea - 我们如何使用 Intellij ANTLR V4 插件测试 ANTLR Lexer 规则?
- javascript - 表单提交 - 覆盖默认提交操作并提示确认
- javascript - 尝试重定向到 Next JS API 路由器中的 url 给我一个 cors 问题
- linux-kernel - 内核:`什么会导致以前一直被读取的内存读取突然开始导致“无法处理内核分页请求”?