0

Python 3.6 和 Flask-Ask

我似乎无法让 Alexa 为我当前的爱好项目(http://github.com/michaeljdietz/jukebox)流式传输音频。

我可以通过网络浏览器手动流式传输音频,我的响应对象中的 https 流 URL 没有问题。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,它似乎确实有十分之 1 的工作。以下是 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":"*****"
    }
}

4

1 回答 1

0

根据亚马逊的博客文档"type": "AudioPlayer.Play"您的directives.

于 2018-01-08T04:32:18.613 回答