【问题标题】:Trouble Getting Alexa to Playback Streaming Audio让 Alexa 无法播放流媒体音频
【发布时间】:2018-01-08 04:25:09
【问题描述】:

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,它似乎确实有十分之一的工作。以下是 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":"*****"
    }
}

【问题讨论】:

  • 你能成功吗?我也面临同样的问题

标签: python flask alexa flask-ask


【解决方案1】:

根据亚马逊的blogdocumentation,您的directives 中似乎缺少"type": "AudioPlayer.Play"

【讨论】:

  • 该键/值对在它进入 AVS 之前就在请求中,所以我想象 AVS 服务模拟器(我从中复制请求)必须将其拉出,因为模拟器目前不支持 AudioPlayer。
猜你喜欢
  • 1970-01-01
  • 2019-04-03
  • 1970-01-01
  • 1970-01-01
  • 2014-01-29
  • 2012-11-20
  • 2013-08-25
  • 1970-01-01
  • 2012-11-09
相关资源
最近更新 更多