Alexa Skills Kit provides Synthesis Markup Language(SSML) to enhance the Alexa speech output. It's very convenient to make Alexa say something we expect. In some case, you may want response an MP3 sound to Alexa, how could we do that?
This article focuses on how to implement the <audio> tag to play an MP3 file.
Converting Audio Files to an Alexa-Friendly Format.
- Download FFmpeg
- Convert your file via below command
ffmpeg -i <input-file> -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 <output-file.mp3>
Hosting the Audio Files for Skills
You can store your files on Amazon S3, and make them public. Or using Azure Media Service. The following steps show how to host audio files on Azure Media Service- Create Media Service resource
- Upload the audio files Search "Assets" on Media Service, and click upload to add your files
- Publish your file and save your URL
Add <audio> Tag In Your Response
Below is an example shows how to use <audio> tagvar say = "<audio src='https://s3.amazonaws.com/my-ssml-samples/Flourish.mp3' />" this.response.speak( say ); this.emit( ":responseReady" ); |
留言
張貼留言