Python 3.6和Flask-Ask
我似乎无法让Alexa为我当前的爱好项目(http://github.com/michaeljdietz/jukebox)传输音频。
我可以通过网络浏览器手动流式传输音频,我的响应对象中的https流网址没问题。 Alexa和AVS服务模拟器都正确地响应语音和文本请求。无论如何,该指令似乎是根据我的知识格式化的。
以下是应该触发播放的Alexa响应:
{
"version": "1.0",
"response": {
"outputSpeech": {
"text": "Playing the album The Bends by Radiohead on your jukebox",
"type": "PlainText"
},
"speechletResponse": {
"outputSpeech": {
"text": "Playing the album The Bends by Radiohead on your jukebox"
},
"directives": [
{
"playBehavior": "REPLACE_ALL",
"type": "AudioPlayer.Play",
"audioItem": {
"stream": {
"token": "334f1e7e-938d-4dea-a732-45884c6f6db9",
"url": "https://michaeljdietz.me/songs/1426",
"offsetInMilliseconds": 0
}
}
}
],
"shouldEndSession": true
}
},
"sessionAttributes": {}
}

更新:对于相同的流URL,它似乎在大约10次中有效。以下是Alexa失败时的回复。
{
"version":"1.0",
"context": {
"AudioPlayer":{
"offsetInMilliseconds":0,
"token":"*****",
"playerActivity":"FINISHED"
},
"System": {
"application": {
"applicationId": "*****"
},
"user" {
"userId":"*****"
},
"device": {
"deviceId": "*****",
"supportedInterfaces": {
"AudioPlayer": {}
}
},
"apiEndpoint":"https://api.amazonalexa.com",
"apiAccessToken":"*****"
}
},
"request": {
"type":"AudioPlayer.PlaybackFailed",
"requestId":"*****",
"timestamp":"2018-01-09T00:02:48Z",
"locale":"en-US",
"currentPlaybackState": {
"offsetInMilliseconds":0,
"token":"*****",
"playerActivity":"FINISHED"
},
"error": {
"message":"Setting up renderers for an unknown media type: UNDEFINED",
"type":"MEDIA_ERROR_UNKNOWN"
},
"token":"*****"
}
}