gpt4 book ai didi

java - Twilio 如何在 SAY 循环中添加暂停

转载 作者:行者123 更新时间:2023-11-29 05:07:22 25 4
gpt4 key购买 nike

我正在尝试在整个通话期间重复要循环播放的 SAY 消息。

目前有效。如何获得要播放的消息,暂停 2 秒。

这是一个示例代码:

<Response>
<Gather>
<Say voice="woman" loop="0">This is my SAY message, which is repeating. How to repeat this with a pause of 2 seconds.</Say>
<Pause length="5"></Pause>
</Gather>
</Response>

twilio 文档提到在 SAY 之外使用它。

https://www.twilio.com/docs/api/twiml/say“如果你想插入一个长停顿,尝试使用 <Pause> 动词。<Pause> 应该放在 <Say> 标签之外,而不是嵌套在它们里面。”

但是在当前的实现中,永远不会达到这个暂停。

有人可以指导我吗。

编辑:尝试使用重定向来重复一条消息,但一旦应答,调用将在 2 秒内掉线。添加暂停不会造成这种情况,重定向是,如果这有什么问题,有人可以指导我吗?

public TwiMLResponse myMethod(){
TwiMLResponse twimlResponse = new TwiMLResponse();
Gather gather = new Gather();
gather.setFinishOnKey("any digit");
gather.setNumDigits(1);
gather.setAction("myendpoint");
Say say = new Say("This message needs to repeat with a pause");
//Pause pause = new Pause();
//pause.setLength(2);
Redirect redirect = new Redirect("myendpoint");

try {
gather.append(say);
//gather.append(pause);
gather.append(redirect);
twimlResponse.append(gather);
} catch (TwiMLException e) {
LOGGER.warn("exception " + e);
}
return twimlResponse;
}

最佳答案

此处为 Twilio 开发人员布道师。

您实际上可以使用 <Redirect> Twilio 中用于循环 <Say> 的动词和一个 <Pause> .你可以这样使用它:

/gather.xml

<Response>
<Gather>
<Say voice="woman">This is my SAY message, which is repeating. How to repeat this with a pause of 2 seconds.</Say>
<Pause length="2"></Pause>
</Gather>
<Redirect>/gather.xml</Redirect>
</Response>

如果这有帮助,请告诉我。

关于java - Twilio 如何在 SAY 循环中添加暂停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29906937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com