0

Python 3.6 and Flask-Ask

I can't seem to get Alexa to stream audio for my current hobby project (http://github.com/michaeljdietz/jukebox).

I can stream the audio manually through a web browser no problem with the https stream URL in my response object. Both Alexa and the AVS Service Simulator respond with speech and text correctly to the request. The directive appears to be formatted right to me, to the best of my knowledge anyway.

Here is the response to Alexa which should trigger the playback:

{
  "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": {}
}

UPDATE: It does seem to work about 1 out of 10 times for the same stream URL. Below is the response on from Alexa when it fails.

{
    "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":"*****"
    }
}
Evriwon
  • 31
  • 5

1 Answers1

0

Based on Amazons blog and documentation, it seems you're missing "type": "AudioPlayer.Play"in your directives.

Samuel L.
  • 74
  • 9
  • That key/value pair IS there in the request right before it goes to AVS, so I am imagining the AVS Service Simulator (which is where I copied the request from) must pull it out given that the AudioPlayer is unsupported currently in the simulator. – Evriwon Jan 08 '18 at 21:30