Hi, i'm new here. I've tested the example alexaHelloWorldStarter, it's OK. But adding the play sound, it can only play predeterminted sound. My question is: how can we play mp3/wav file ?
Welcome.
The example
Juke Box described in this extension is one possible way.
See the Example App: Jukebox discussion that shows how to get a a list of all music files of the Music directory of your device and play your music in random order.
There are other ways that depend on where the mp3 files you hope to play are located and how larger the files are. Have you read the documentation for Player ?
Thanks for quick answer . but my question is how can we play a mp3 file in the example alexa skill: helloworldstarter example. I want alexa responds with a song/ audio file beside the" hi" or "hello". Can we do that?
I haven't tried it, but in theory it is possible.
You would need to use the speech markup
block in the Voice drawer and construct an <audio>
element from SSML. The tag has a single attribute, src
, that is a URL that must meet the following criteria:
- The MP3 must be hosted at an Internet-accessible HTTPS endpoint. HTTPS is required, and the domain hosting the MP3 file must present a valid, trusted SSL certificate. You can't use self-signed certificates.
- The MP3 must not contain any customer-specific or other sensitive information.
- The MP3 must be a valid MP3 file (MPEG version 2).
- For your speech response, the audio file can't be longer than 240 seconds.
- The combined total time for all audio files in the
outputSpeech
property of the response can't be more than 240 seconds. - The combined total time for all audio files in the
reprompt
property of the response can't be more than 90 seconds. - The bit rate must be 48 kbps. Note that this bit rate gives a good result when used with spoken content, but is generally not a high enough quality for music.
- The sample rate must be 22050 Hz, 24000 Hz, or 16000 Hz.
The documentation also notes that a response can have up to 5 <audio>
tags. This would include the <audio>
tag that is provided if you use any of the built-in sounds.
Thks, i will try it later.