python - Twilio/Flask - 将调用者的语音存储到字符串变量
问题描述
我的目标是在 Twilio 上支付一条简单的消息,该消息可以捕获来电者的回复。根据回复将呼叫者发送到下一个选项。我的挑战:如何将呼叫者的语音转换为文本?下面的示例是演示这将起作用的代码:
from flask import Flask, request, redirect
from twilio.twiml.voice_response import VoiceResponse, Gather, Say
from datetime import datetime
import time
app = Flask(__name__)
@app.route("/test1", methods=['GET', 'POST'])
def test1():
response = VoiceResponse()
gather = Gather(input='speech',timeout=3,hints='cat, numbers, chuck')
gather.say('Welcome to the fact hotline. Say cat numbers or chuck')
response.append(gather)
resp = VoiceResponse()
resp.say('you said' + str(response))
print(str(response))
return str(response)
if __name__ == "__main__":
app.run(debug=True)
结果是:
<?xml version="1.0" encoding="UTF-8"?><Response><Gather hints= "cat, numbers, chuck" input="speech" timeout=3><Say>Welcome to the fact hotline. Say cat numbers or chuck</Say></Gather></Response>
如果我说“chuck”,我想要一个变量 =“chuck”。有人可以提供指导吗?
解决方案
推荐阅读
- windows-10 - Windows 10 上的 Odoo 内部服务器错误。无法启动 Odoo 服务器 [Odoo 10.0]
- java - 如何在java中将数据从一个对象列表复制到另一个对象?
- android - 如何从另一个类更改 recyclerView 适配器内的 ImageView?
- android - 一个人如何返回多个屏幕?
- javascript - Angular JS 显示响应值
- php - Codeigniter - 需要帮助将图片上传到文件夹和数据库
- tensorflow - 如何获取数据以在 Kaggle 中训练我的神经网络模型?
- sql - 转换为_CHAR(HIRE_DATE,'MONTH')时没有输出
- latex - tex 编程
- javascript - 如何使用 Ajax 成功在新选项卡中打开 URL?