timheuer / alexa-skills-dotnet

An Amazon Alexa Skills SDK for .NET
MIT License
547 stars 108 forks source link

Can't play audio via SSML - There was a problem with the requested skill's response #258

Closed SteveJCCC closed 1 year ago

SteveJCCC commented 1 year ago

Hi, I've been trying to get Alexa Skills .Net to play an audio file references in the SSML. I have done this both via the Developer Console and also directly on my physical device (Echo Dot).

I've have tried using the following code, and various variations of it (different characters for the quotes, moving the tag to behind Hello etc): var speech = new SsmlOutputSpeech(); speech.Ssml = "Hello"; response = ResponseBuilder.Tell(speech); return response;

I have also tried using: speech.Ssml = new Speech(new Audio("https://s3.eu-west-1.amazonaws.com/afinadorcromaticosounds/piano/A_piano.mp3")).ToXml();

But that's doesn't work either.

Using this does play the sound, but that's not how I want to do it: return ResponseBuilder.AudioPlayerPlay(PlayBehavior.ReplaceAll, "https://matthiasshapiro.com/alexasamples/First.mp3", "testToken");

Can you please help so I can get the sound file playing through SSML please? I am using .Net 7.

Many thanks, Steve

SteveJCCC commented 1 year ago

Hi Tim, Can you please assist with the above? Kind regards, Steve

stoiveyp commented 1 year ago

Hi @SteveJCCC

The ToXml method should be the correct way to set the SSML response as it needs to be a valid SSML document.

Couple of questions (re-read your message and realised I was asking the wrong questions originally)

Cheers

stoiveyp commented 1 year ago

Just downloaded the mp3 you referenced in your audio tag and looked at the file info and it appears to not be a sample rate that's considered valid.

timheuer commented 1 year ago

@SteveJCCC hopefully you can convert the audio to a supported sample rate (link above in @stoiveyp reply) and be good.

SteveJCCC commented 1 year ago

Thank guys, I'll have a look at this, although I was also linking to a file specifically created for audio playback. I'll have a look this month and keep you posted. Many thanks, Steve