【问题标题】:Twilio Speech Gather not working as I expected. What am I doing wrong?Twilio Speech Gather 没有像我预期的那样工作。我究竟做错了什么?
【发布时间】:2019-07-08 22:59:53
【问题描述】:

使用 Node.js,我已经设法让 DMTF 工作得很好,但现在我必须实际收集声音,但它并没有像我预期的那样工作,所以我显然做错了什么。这是我的两个功能:

exports.testSpeech = functions.https.onRequest(async(req,res)=>{
  const twiml = new VoiceResponse()
  const gather = twiml.gather({
    'voice':'alice',
    'language':'en-US',
    'input':'dmtf speech',
    'finishOnKey':'#',
    'speechTimeout':15,
    'speechModel':'phone_call',
    'action':'testSpeechResults'
  })
  gather.say('Hi. tell me something I don\'t know.')
  console.log(twiml.toString())
  res.status(200).send(twiml.toString())
  return null
})
exports.testSpeechResults = functions.https.onRequest(async(req,res)=>{
  console.log('This is my response:',JSON.stringify(req.body))
  const twiml = new VoiceResponse()
  twiml.say({
    'voice':'alice',
    'language':'en-US'
  },'Sorry, I alrady knew that. Goodbye')
  twiml.hangup()
  res.status(200).send(twiml.toString())
  return null
})
exports.twilioStatusChange = functions.https.onRequest(async(req,res)=>{
  const twiml = new VoiceResponse();
  const from_phone = TEST_PHONE !== '' ? TEST_PHONE : req.body.From
  console.log('twilioStatusChange',from_phone)
  console.log(JSON.stringify(req.body))
  res.status(200).send({})
})

我的日志显示 testSPeech 被击中,但在我说了什么并按 # 键后,我被转储到了我的 twilioStatusChange webhook,而不是我期待的 testSpeechResults webhook。这是 testSpeech 函数末尾 twiml.toString 的输出:

<?xml version="1.0" encoding="UTF-8"?><Response><Gather voice="alice" language="en-US" input="dmtf speech" finishOnKey="#" speechTimeout="15" speechModel="phone_call" action="testSpeechResults"><Say>Hi. tell me something I don't know.</Say></Gather></Response>

没有记录错误。

【问题讨论】:

    标签: node.js twilio


    【解决方案1】:

    Gather 不是我需要的正确动词。做我期望的需要记录

    【讨论】:

    • 很高兴您已对此进行了排序。 &lt;Record&gt; 允许您录制来自用户的消息,而 &lt;Gather&gt; 允许您对文本进行实时语音。将 &lt;Gather&gt; 与语音一起使用时,您应该在操作 URL 的请求参数中查找 SpeechResult 参数。如果您需要任何进一步的帮助,请告诉我。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-06
    • 1970-01-01
    • 2012-07-01
    • 2016-07-18
    相关资源
    最近更新 更多