【发布时间】: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>
没有记录错误。
【问题讨论】: