Twilio 如何在 SAY 循环中添加暂停
Twilio how to add a PAUSE within a SAY Loop
我正在尝试在整个通话期间重复要循环播放的 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
"If you want to insert a long pause, try using the <Pause>
verb. <Pause>
should be placed outside <Say>
tags, not nested inside them."
但在当前的实施中,永远不会达到此暂停。
有人可以指导我吗。
编辑:尝试使用重定向来重复一条消息,但电话在接听后会在 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;
}
来自 <say>
的文档
Punctuation, such as commas and periods will be interpreted as natural pauses by the speech engine.
所以你可以这样改变你的说法:
<Say voice="woman" loop="0">This is my SAY message, which is repeating. How to repeat this with a pause of 2 seconds, , ,</Say>
这里是 Twilio 开发人员布道者。
您实际上可以在 Twilio 中使用 <Redirect>
动词来循环 <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>
如果有帮助请告诉我。
我正在尝试在整个通话期间重复要循环播放的 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
"If you want to insert a long pause, try using the <Pause>
verb. <Pause>
should be placed outside <Say>
tags, not nested inside them."
但在当前的实施中,永远不会达到此暂停。
有人可以指导我吗。
编辑:尝试使用重定向来重复一条消息,但电话在接听后会在 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;
}
来自 <say>
Punctuation, such as commas and periods will be interpreted as natural pauses by the speech engine.
所以你可以这样改变你的说法:
<Say voice="woman" loop="0">This is my SAY message, which is repeating. How to repeat this with a pause of 2 seconds, , ,</Say>
这里是 Twilio 开发人员布道者。
您实际上可以在 Twilio 中使用 <Redirect>
动词来循环 <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>
如果有帮助请告诉我。