![](/img/trans.png)
[英]Twilio <Gather> Speech Recognition support in twilio python package
[英]Twilio gather how can I tell gather wait for sometime before speech starts and start collecting
SO用于接听来电和收集语音。 这是我拥有的代码示例,使用 Python 和 Flask。
# more code above
resp.gather(input='speech dtmf', timeout=3, speech_timeout=4, action='/gather', method='POST')
resp.redirect('/gather')
# more code in between
@app.route("/gather", methods=['GET', 'POST'])
def gather():
#print("gather: Entry ")
resp = VoiceResponse()
sid = request.form['CallSid']
SpeechResult = request.values.get("SpeechResult", "")
params = urllib.parse.urlencode({"SpeechResult": SpeechResult})
print("0 gather: " + str(params).lower())
但是,调用它会导致:
0 gather: speechresult=
当我自己调用该应用程序时,我注意到它在启动提示之前等待了 5 秒钟。 我如何告诉收集在收集前 5 秒开始。
我尝试在 resp.gather 之前添加resp.gather
time.slpeep(5)
......但它没有用。
Twilio 开发人员布道师在这里。
我不确定你在这里说的是什么提示。
我缺少的是您最初的<Gather>
似乎没有要求用户输入。 这将导致约 5 秒的静默,而<Gather>
等待输入然后放弃并移动到/gather
端点, SpeechResult
中没有任何内容。
如果您想对用户说些什么以要求他们做出回应,则应在<Gather>
中使用<Say>
,如下所示:
gather = resp.gather(input='speech dtmf', timeout=3, speech_timeout=4, action='/gather', method='POST')
gather.say('Please answer the question')
您还可以在<Gather>
中使用<Play>
和<Pause>
> 。
让我知道这是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.