Twilio 动态文本转语音对话

Twilio Dynamic Text-To-Speech Conversation

我刚开始使用 Twilio API,我基本上希望有人能够发送文本并在 phone 调用中读出它,但随后保持线路畅通以便稍后发送更多文本。

似乎我应该将可编程语音 API 与 TwilML 一起使用,但我遇到的问题是一旦 TwilML 指令完成,呼叫就会结束。无论如何我可以阻止这种情况发生并让呼叫等待 Rest API 更新发送到 phone 呼叫让它说新文本?

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

有几种方法可以解决这个问题,但我认为最好的方法是使用 <Enqueue>. Once your TwiML is played out, you can <Enqueue> the call and then provide a waitUrl that points to an endpoint that returns more TwiML to play to the user while they wait. This will automatically loop while the user remains in the queue. You could use this to simply <Pause> indefinitely or <Play> background music. Then, once you have more text to read to the user you can redirect the call by updating it

如果有帮助请告诉我。