Python Twilio gather我怎样才能告诉gather在演讲开始前等待一段时间,然后开始收集

Python Twilio gather我怎样才能告诉gather在演讲开始前等待一段时间,然后开始收集,python,flask,twilio,Python,Flask,Twilio,所以用来接听来电和收集语音。下面是我使用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'])

所以用来接听来电和收集语音。下面是我使用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秒告知采集开始


我尝试在分别收集之前添加
time.slpeep(5)
。。。但它不起作用。

这里是Twilio开发者的福音传道者

我不知道你在说什么

我缺少的是,您的首字母似乎没有要求用户输入。当
等待输入,然后放弃并转到
/gather
端点时,
SpeechResult
中没有任何内容,这将导致约5秒钟的静默

如果您想对用户说些什么让他们回答,您应该在
中使用,如下所示:

gather = resp.gather(input='speech dtmf', timeout=3, speech_timeout=4, action='/gather', method='POST')
gather.say('Please answer the question')
您还可以在
中使用和


如果有任何帮助,请告诉我。

就我而言,我有一个来电。调用来到我的Twilio代码,我的代码应答该调用,并且它期望来自调用方的提示。如果调用者是人(me),那么代码工作正常,因为我说提示符和my/gather结果是预期的结果。然而,如果呼叫者是一台机器,它在语音开始前有5秒的延迟,那么采集不会返回任何信息。哦,我建议您的系统提示用户,而不是相反,这只是为了考虑用户体验。您的系统接收来自计算机的传入呼叫的可能性有多大?这是一个预期的用例吗?您希望如何处理这种调用?