Alexa automatically handles normal punctuation, such as pausing after a period, or speaking a sentence ending in a question mark as a question. However, in some cases you may want additional control over how Alexa generates the speech from the text in your response. For example, you may want a longer pause within the speech, or you may want a string of digits read back as a standard telephone number. This can be accomplished with Speech Synthesis Markup Language (SSML) support.
This guide assumes you’ve already added the Alexa integration to your Meya app and have it working. If you haven’t done that yet, check out the guide below.
Let’s create a sample flow that uses SSML.
For the complete Alexa SSML reference, check out the documentation.
In your app’s
flow/amazon folder, create a new file called
ssml.yaml and copy this code into it:
triggers: - keyword: ssml steps: - say: Here is an example of an excited voice. - delay: 1 - say: > <amazon:emotion name="excited" intensity="high"> You win this round! </amazon:emotion> - delay: 1 - say: Here is an example of a disappointed voice. - delay: 1 - say: > <amazon:emotion name="disappointed" intensity="high"> Here I am with a brain the size of a planet and they ask me to pick up a piece of paper. </amazon:emotion>
This flow uses the amazon:emotion SSML tag so Alexa can express emotion when speaking.
Save the file and push it to the Grid:
meya format meya push
Go to the Alexa Developer Console and navigate to the skill’s Simulator. Activate the skill with your invocation phrase, then say
ssml to trigger the new flow. Can you hear the emotion?
You now know how to give your Meya app a bit of personality by controlling the tone of voice. Keep exploring the Alexa SSML reference to see what’s possible.
Updated 12 months ago