question

newuser-76fb7a19-f37c-4039-b416-26cc686350d8 avatar image

Alexa Skills AudioPlayer PlayDirective doesn't play the full audio completely

I'm trying to set up a very basic skill that plays some custom m4a files stored in the provided S3 bucket. I've gotten everything to work, however the PlayDirective doesn't play the audio completely. Every single time the audio is played, it stops at a seemingly random point. I'm not sure how to debug this, as the setup works perfectly, and the audio always starts playing, but it never plays to completion, always stopping arbitrarily.

def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        
        slots = handler_input.request_envelope.request.intent.slots
        tale_name = slots["tale_name"]
        
        audio_url = create_presigned_url("Media/"+self.get_audio_url(tale_name))
        
        speak_output = "Now playing {tale_name}!".format(tale_name=NOW_PLAYING)
        
        handler_input.response_builder.add_directive(PlayDirective(play_behavior=PlayBehavior.REPLACE_ALL, audio_item=AudioItem(stream=Stream(token="TOKEN", url=audio_url, offset_in_milliseconds=10, expected_previous_token=None))))

        return (
            handler_input.response_builder
                .speak(speak_output)
                # .ask("add a reprompt if you want to keep the session open for the user to respond")
                .response
        )


UPDATE:

If it helps, I've been seeing the following error in CloudWatch Logs:


[INFO]    2021-02-13T05:32:54.526Z    e6499c9a-54e6-4c22-80e6-ffd1544662fd    In PlaybackFailedHandler
[INFO]    2021-02-13T05:32:54.526Z    e6499c9a-54e6-4c22-80e6-ffd1544662fd    Playback failed: {'message': 'Device playback error', 'object_type': 'MEDIA_ERROR_UNKNOWN'}

[ERROR]    2021-02-13T05:32:54.578Z    ef7f8718-c822-42ad-a54b-43fcbb51a0e9    Unable to find a suitable request handler
Traceback (most recent call last):
File "/var/task/ask_sdk_runtime/dispatch.py", line 118, in dispatch
output = self.__dispatch_request(handler_input)  # type: Union[Output, None]




alexa skills kitaudioaudioplayerpythoninteraction model
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kinisoftware avatar image
Kinisoftware answered

Hi!


How long is the audio? There is a limit in Alexa (I think the limit is 4 minutes). After the audio stops, do you get any kind of request to your backend?


Cheers! :)

3 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Andy Whitworth avatar image Andy Whitworth commented ·

No duration limit when using the AudioPlayer interface. You're thinking of the <audio> tag in SSML or the Audio APLA component, both of which do have duration limits (4 minutes) for audio.


1 Like 1 ·

Hey! No, the audio I'm trying to play is around 2-3 minutes, nowhere close to 4 minutes.


No, the skill is supposed to simply play the audio, and thats it, no additional requests. It should be very simple, but I cant seem to figure out why the audio just stops.


Thanks for the help btw, I appreciate it! :)

0 Likes 0 ·

Any clue? I cant seem to debug this :/

0 Likes 0 ·
Andy Whitworth avatar image
Andy Whitworth answered

Have you tried converting to a different file format ?

M4A isn't listed on the supported file formats for Audio Player

"The supported formats for the audio file include AAC/MP4, MP3, PLS, M3U/M3U8, and HLS. Bitrates: 16kbps to 384 kbps."

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.