After this tutorial you'll be able to do the same thing as seen at the start of this video where it's playing custom Simpsons sounds:
If you're using this on the Amazon Echo be aware that Alexa needs the audio files to be in a very specific audio format (48 kbps for example). Check here for details.
STEP 1 - CREATE COMMAND TO PLAY SOUND
The <speak></speak> tags are used to indicate that you're going to use a special kind of response where you can use special stuff like playing back sound files. As you can see you can also use normal text between those tags and it'll work as well.
- In AutoVoice Natural Language Commands create a new command
- Set the command to play a sound
- Set the response to <speak>Hello</speak>
Here's how that sounds like so far:
STEP 2 - ADD SOUND FILE IN RESPONSE
These are special <audio></audio> tags that can be used to play back a sound. To define the sound you want to play you set the src attribute. This must be an URL for a publicly available sound file. You must also define what phrase you'd like it to say if the sound file can't be played for some reason between the tags, which in this case I set to Placeholder
- Edit the command's responses
- After Hello but before </speak> add this: <audio src="https://storage.googleapis.com/my-awesome-joaomgcd-cloud.appspot.com/sounds/Ned - Okily Dokily.mp3">Placeholder</audio>
If you need a place to host your files, you can do it on Google Cloud Storage:
This is how it sounds now:
STEP 3 - PLAY 2 SOUNDS WITH A PAUSE
The <break> tag is a special tag that allows the assistant to not say anything for 3 seconds.
- Edit the response again
- Add another sound file after the first one: <audio src="https://dl.dropboxusercontent.com/u/9787157/sounds/Bart - Aye Carumba.wav">Placeholder</audio>
- Add this between the sound files: <break time="3s"/>
As you can see the assistant will now say
Google Home supports a lot of other tags in the response speech like saying numbers and dates in specific ways, spelling out words and more.
- play first sound file
- wait 3 seconds
- play second sound file
Check out all of the supported tags here: https://developers.google.com/actions/reference/ssml