question

DevCoder avatar image
DevCoder asked ·

Alexa-Hosted Skill not playing audio file from S3 with signed url

I'm trying to play a short audio file as a response using an Alexa-Hosted skill. I can't make the audio file public in the S3 bucket provided, this just keeps throwing up an error around invalid permission, so following the docs I'm using the `util` package to get a signed url. However the error I'm receiving appears to be related to the signed url:


Error: Fatal error occurred when processing SSML content. This usually happens when the SSML is not well formed. Error: Unexpected character '=' (code 61); expected a semi-colon after the reference for entity 'X-Amz-Credential'\n at [row,col {unknown-source}]: [1,289]"

If I use `encodeURIComponent` on the full signedUrl this returns and invalid URI response. The SSML looks like it's formatted correctly in terms of the audio tag, but the signedURL itself is what's causing the problem.


For what it's worth I'm sending the response via


 return handlerInput.responseBuilder
      .speak(speechText)

But I haven't had issues with any other SSML such as <break> when using this.


Anyone got any ideas?

audiossmlhosted skill
10 |2000 characters needed characters left characters exceeded

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

Anand@Amazon avatar image
Anand@Amazon answered ·

Hi @DevCoder,

Can you share skill id as multiple skills are there in your account?

10 |2000 characters needed characters left characters exceeded

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

CharlesF avatar image
CharlesF answered ·

I received this advice in a different scenario:

We had a previous contact from a developer with a similar problem. They were trying to play audio files but were not able to. The solution for them was to escape the '&' character using the following workaround: https://forums.developer.amazon.com/questions/199131/playing-audio-files-from-s3-called-from-a-data-dic.html

It didn't help me but the solution it refers to may apply to your situation. I don't think it will strip the = signs which appear to not conform to the SSML schema. What you're doing may not be workable with the current Alexa Hosted setup which is a bummer but I guess it's Beta.

10 |2000 characters needed characters left characters exceeded

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

Dzefo avatar image
Dzefo answered ·

I had the same issue and solved it with the escapeXmlCharacters function.

It exports from the ask-sdk-core package.

https://developer.amazon.com/en-US/docs/alexa/alexa-skills-kit-sdk-for-nodejs/utilities.html#ssmlutils

Before:

const audioUrl = getS3PreSignedUrl("Media/audio.mp3");

After:

const audioUrl = escapeXmlCharacters(getS3PreSignedUrl("Media/audio.mp3"));
10 |2000 characters needed characters left characters exceeded

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