Introduction
In the previous article; i.e. SSML in Alexa Skill Kit Part 1, we tried to understand what is SSML and some of the tags which are supported by ASK, however, this article is a continuation of the previous article which will elaborate on remaining tags.
P
This tag is the same as a break, however, it provides some extra breaks before and after the tag. It is equivalent to <break strength="x-strong"/>
- <speak>
- <p>This is the first paragraph.
- There should be a pause after this text is spoken.
- </p>
- <p>This is the second paragraph.</p>
- </speak>
Let’s understand how to write in response from the Lamda function.
- var speech = new SsmlOutputSpeech();
- speech.Ssml = @"<speak><p> This is the first paragraph.There should be a pause after this
- text is spoken.</p> <p>This is the second paragraph.</p></speak>";
- // build the response using ResponseBuilder
- var finalResponse = ResponseBuilder.Tell(speech);
- return finalResponse;
S
This tag is the same as a break, however, it provides some extra breaks before and after the sentence i.e. tag. It is equivalent to <break strength="strong"/>.
- <speak>
- <s>this is a first sentence</s>
- <s>this is the second sentence there should be a short pause before this second sentence</s>
- This is third and ends with a period and should have the same pause.
- </speak>
Emphasis
This tag helps to change the rate and volume of speech. This tag has a level attribute that has the below values,
- strong: with the help of this value, you can slow down speaking rate due to which speech becomes louder and slower
- moderate: It is the same as strong however it is less than strong.
- reduced: It will decrease the volume and speed up the speaking rate.
- // build the SSML response
- var speech = new SsmlOutputSpeech();
- speech.Ssml = @"<speak>I already told you I <emphasis level=""strong"">really like</emphasis> that person.</speak>";
- // build the response using ResponseBuilder
- var finalResponse = ResponseBuilder.Tell(speech);
- return finalResponse;
Lang
This tag helps us to speak a phrase in a specific language. Like French, US, Indian, etc. You need to xml: lang as an attribute to specify the language as shown below,
- <speak>
- In India, they pronounce it
- <lang xml:lang="en-IN">India</lang>
- </speak>
In Lamda function you need to specify as shown below,
- var speech=new SsmlOutputSpeech();
- speech.Ssml=@"<speak>In India, they pronounce it <lang xml:lang=""en-
- IN"">India</lang>.</speak>";
- // build the response using ResponseBuilder
- var finalResponse=ResponseBuilder.Tell(speech);
- return finalResponse;
hi-IN, en-US, en-IN, en-AU, de-DE, en-CA, es-ES, it-IT, ja-JP, fr-FR, en-GB.
phoneme
If you want to pronounce any text as phonemic/phonetic then you can use phoneme tag. It has alphabet and ph as an attribute, where the alphabet is used for setting the phonetic alphabet and ph is for pronunciation.
- <speak>
- You say,
- <phoneme alphabet="ipa" ph="pbA.t@l"></phoneme>
- </speak>
In the above example we set alphabet as ipa and its ph values pbA.t@l which will pronaince as bootle.
- var speech=new SsmlOutputSpeech() speech.Ssml=@"<speak> You say, <phoneme alphabet=""ipa"" ph=""pbA.t@l""></phoneme>. <speak>";
- // build the response using ResponseBuilder
- var finalResponse=ResponseBuilder.Tell(speech);
- return finalResponse;
Prosody
This tag is used for modifying pitch, volume, and rate of speech. It has volume, pitch, and rate as attributes which has several values as described below,
- volume: it helps to change the volume of speech, It has below values.
- silent
- x-soft
- soft
- medium
- loud
- x-loud
- pitch: it helps to raise /lower the tone of speech, It has below values.
- x-low
- low
- high
- x-high
- rate: it helps to modify the rate of speech, It has below values.
- x-slow
- slow
- medium
- fast
- x-fast
Let’s understand with an example.
- <speak>
- Normal volume for the first sentence.
- <prosody volume="x-loud">Louder volume for the second sentence</prosody>
- . When I wake up,
- <prosody rate="x-slow">I speak quite slowly</prosody>
- .< I can speak with my normal pitch,
- <prosody pitch="x-high"> but also with a much higher pitch </prosody>
- , and also
- <prosody pitch="low">with a lower pitch</prosody>
- .
- </speak>
Say-as
It helps to specify how the text should be interpreted as a number that should be interpreted as digits or cardinal. It has interpret-as and format attributes however the format is optional. And interpret-as specifies how Alexa should respond.
Interpret-as
- spell out: it spells out each letter, this is used for characters.
- cardinal: it interprets values as cardinal numbers.
- ordinal: it interprets values as ordinal numbers.
- digits: it spells each digit individually.
- fractional: it interprets values as a fractional
- unit: it interprets values in measurement.
- time: interprets the value in time like minutes and seconds.
- telephone: interprets numbers like 7 or 10 digit telephone numbers.
- date: it interprets values as date , however, format attribute is used with this.
- expletive: it beeps out the content inside this tag.
- interjection: with the help of this tag you can force Alexa to speak text in a more expressive voice.
- address: it helps to interpret values as a street address.
- <speak>
- number is spoken with each digit separately:
- <say-as interpret-as="digits">12345</say-as>
- . number spoken as a cardinal number:
- <say-as interpret-as="cardinal">12345</say-as>
- . word is spelled out:
- <say-as interpret-as="spell-out">hi</say-as>
- </speak>
W
it is similar to say-as, however, it customizes pronunciation by specifying words' part of speech like a simple present or past participle, noun, etc. It has a role attribute which has the below values.
role
- amazon: NN: it interprets a word as a noun
- amazon:VB: it interprets the word as a verb
- amazon:VBD: it interprets as a past participle
- amazon: SENSE_1: it interprets the word as non- default pronunciation
Let’s understand by example,
- <speak>
- The word
- <say-as interpret-as="characters">test</say-as>
- may be interpreted as either the present simple form
- <w role="amazon:VB">test</w>
- , or the past participle form
- <w role="amazon:VBD">test</w>
- .
- </speak>
Voice
This tag helps to speak the text in Amazon Polly voice. It has the name attribute where you can specify the name which indicated the region like for
- America i.e en-Us: you can specify Ivy, Kendra, Matthew, Joanna, Joey, Salli, Justin, Kimberly
- Hindi (hi-IN): Aditi
- English, British (en-GB): Amy, Brian, Emma
- English, Indian (en-IN): Raveena, Aditi,
- Spanish, Castilian (es-ES): Conchita, Enrique
- Japanese (ja-JP): Mizuki, Takumi
- German (de-DE): Hans, Vicki, Marlene
- French (fr-FR): Lea, Celine, Mathieu
- English, Australian (en-AU): Russell, Nicole
- Italian (it-IT): Carla, Giorgio
Let’s understand by example,
- <speak>
- I want to tell you a secret.
- <voice name="Aditi">I am not a real human.</voice>
- . Can you believe it?
- </speak>
Summary
In this article, we learned about SSML in the Alexa Skill Kit.

Join the conversation! Your thoughts help the community grow.