Twilio,我如何从手机获得语音响应



我目前正在尝试将对话流与twilio集成。我希望能够分析我的客户提供给机器人的语音响应。如何获得语音响应;并根据某些语音文本发回响应。

截至目前,当有人拨打电话时,它会回复"你好";然后我希望能够获取客户的回复;然后适当地回复。到目前为止,我使用的是网络钩子"来电"。 这是否需要额外的库来将语音转换为文本?还是特威利奥提供它。

import os
from twilio.rest import Client
from flask import Flask
from twilio.twiml.voice_response import VoiceResponse
app = Flask(__name__)
# using os.environ['account_sid']
@app.route('/voice', methods=["GET","POST"])
def voice():
    resp = VoiceResponse()
    resp.say("hello")
    return str(resp)

if __name__ == "__main__":
    app.run(debug=True)

您要查找的是语音收集命令。Twilio 确实通过此命令本身提供语音识别。

from twilio.twiml.voice_response import Gather, VoiceResponse, Say
response = VoiceResponse()
gather = Gather(input='speech dtmf', timeout=3, num_digits=1)
gather.say('Hello!')
response.append(gather)
print(response)

文档在这里 -> https://www.twilio.com/docs/voice/twiml/gather

最新更新