0% found this document useful (0 votes)
64 views8 pages

Using SSML Break Tags in Amazon Polly

This document provides a comprehensive guide on using SSML markup tags for creating text-to-speech audio files, focusing on elements like <speak>, <break>, <say-as>, and prosody tags. It explains how to control pauses, emphasis, pronunciation, and audio embedding to enhance the quality of the generated speech. Additionally, it includes specific instructions for using Amazon Polly and Google TTS features effectively.

Uploaded by

Leo Lacerda
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views8 pages

Using SSML Break Tags in Amazon Polly

This document provides a comprehensive guide on using SSML markup tags for creating text-to-speech audio files, focusing on elements like <speak>, <break>, <say-as>, and prosody tags. It explains how to control pauses, emphasis, pronunciation, and audio embedding to enhance the quality of the generated speech. Additionally, it includes specific instructions for using Amazon Polly and Google TTS features effectively.

Uploaded by

Leo Lacerda
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

How To Create Text-To-Speech Audio Files –

SSML Markup Tags: Quick Reference Guide


Please refer to the SSML markup tutorials for detailed information about using SSML tags to markup
text and the accompanying cheat sheets in this course for additional quick reference resources.

Overview
Prosody refers to areas of language like the tune, rhythm, stress and intonation of speech and how these
features contribute to meaning. Prosodic, therefore, refers to aspects of prosody.

<speak>
This SSML tag can be used with Google TTS and Amazon Polly.

The speak tag is the root element of all SSML text.

Text must be enclosed within a pair of speak tags to be converted into speech.

Add an opening speak tag <speak> to the beginning of your text. Add a closing speak tag </speak> to the
end of your text file.

Here is an example of how to use the speak tag in your text file. Note that all the content you want to
convert into speech is enclosed within the opening and closing speak tags

Wrap everything with <speak></speak> tags:

<speak>Hello</speak>

© [Link] 1
Adding Pauses To Words & Sentences
The <break/> tag lets you add pauses to words, sentences and paragraphs in your text-to-speech files.

The break tag is an empty element, which means that it produces no sound. It controls pausing or other
prosodic boundaries between words.

Note that using break tags is completely optional. If this element is not present between words, the
break will be automatically determined based on how the text-to-speech engine processes the linguistic
context.

In other words, even if you don't add break tags, a TTS engine will naturally add a pause after finding
certain grammatical features like punctuation in your text, such as periods and commas.

A break tag, then, allows you to finetune the spacing of pauses and breaks between words, sentences,
and paragraphs.

If you add a break tag after a word, sentence, or paragraph, a break will be inserted with a prosodic
strength greater than if no break element is supplied.

In other words, the text-to-speech engine will determine the linguistic context of your text and increase
the natural pause if it detects a break tag in your content.

So, while a sentence with no break tags will have natural pauses added, adding break tags can extend
those pauses and create a more lifelike feel to your narration.

© [Link] 2
The break tag also lets you use optional attributes, like time and strength.

• time (<break time="?"/>) and


• strength (<break strength="?"/>)

Using a break tag with the time attribute lets you fine tune your narrations by setting the length of your
break or pause using seconds or milliseconds. For example, 3 seconds, or 200ms.

For example:

• <break time="1s"/>
• <break time="2s"/>
• <break time="3s"/>
• <break time="250ms"/>
• <break time="500ms"/>
• <break time="800ms"/>

© [Link] 3
If you use Amazon Polly to convert your text files into speech, please note that the maximum duration
amount you can specify in the break tag is 10 seconds, or 10,000 milliseconds.

Using a break tag with the strength attribute also lets you fine tune your narrations by setting the length
of your breaks or pauses using relative values, such as:

• extra strong: <break time=“x-strong”/>


• strong: <break time=“strong”/>
• medium: <break time=“medium”/>
• weak: <break time=“weak”/>
• extra weak: <break time=“x-weak”/>
• none: <break time=“none”/>

Use the value “none” to prevent a prosodic break or pause that your text-to-speech processor would
otherwise produce and insert into your narration.

If using Amazon Polly, strength attribute values are equivalent to pausing after a comma, sentence, or
paragraph:

• none: No pause. Use none to remove a normally occurring pause, such as after a period.
• x-weak: Has the same strength as none, no pause.
• weak: Sets a pause of the same duration as the pause after a comma.
• medium: Has the same strength as weak.
• strong: Sets a pause of the same duration as the pause after a sentence.
• x-strong: Sets a pause of the same duration as the pause after a paragraph.

Additionally, if you don't use attributes with the break tag (i.e. use only <break/>) when processing text-
to-speech with Amazon Polly, the results vary depending on your text.

• If there is no other punctuation next to the break tag, it creates a break strength of medium
value, which is the equivalent of a comma-length pause.
• If the tag is next to a comma, it upgrades the tag to a strong break tag, which is the equivalent of
a sentence-length pause.
• If the tag is next to a period, it upgrades the tag to an extra strong break tag, or the equivalent
of a paragraph-length pause.

The break tag, then, lets you specify exact pause durations between words, sentences and paragraphs
and can be used to enhance the lifelike aspect of your voice narrations.

Summary:

Use break tags with time attribute to specify breaks using seconds or milliseconds:

• <break time="3s" />


• <break time="500ms" />

Use break tags with strength attribute to specify breaks using relative values:

• <break strength="none" /> <!—Amazon Polly removes pause after period -->

© [Link] 4
• <break strength="x-weak" /> <!—Amazon Polly treats this the same as “none” -->
• <break strength="weak" /> <!-- Amazon Polly treats this like a comma -->
• <break strength="medium" /> <!—Amazon Polly treats this the same as “weak” -->
• <break strength="strong" /> <!-- Amazon Polly treats this like a sentence break (period) -->
• <s>Sentence</s>
• <break strength="x-strong" /> <!-- Amazon Polly treats this like a paragraph break -->
• <p>Paragraph</p>

Text Interpretation
The <say-as> element lets you specify how certain characters, words, and numbers in your text-to-
speech file should be spoken.

A <say-as> tag requires using the <interpret-as> attribute, which determines what is being
processed.

Optional attributes like <format> and <detail> can also be used, depending on the element selected.

The structure for marking up text to interpret <say-as> values is shown below.

• <say-as interpret-as="characters">hello</say-as> <!-- or "spell-out" -->


• <say-as interpret-as="cardinal">150</say-as> <!-- or "number" -->
• <say-as interpret-as="ordinal">3</say-as>
• <say-as interpret-as="digits">7124</say-as>
• <say-as interpret-as="fraction">1/3</say-as>
• <say-as interpret-as="unit">4dB</say-as>
• <say-as interpret-as="date">20181031</say-as>
• <say-as interpret-as="date" format="ymd">20181031</say-as> <!-- any combination of ymd -->
• <say-as interpret-as="time">1'21"</say-as>
• <say-as interpret-as="telephone">1234567</say-as>
• <say-as interpret-as="telephone">1234567890</say-as>
• <say-as interpret-as="address">123 The Avenue, Town, 54321, Country </say-as> <!-- street -->
• <say-as interpret-as="expletive">Becomes beeeep</say-as>

Additionally …

© [Link] 5
• <say-as interpret-as="interjection">oh no</say-as>
• <!-- [Link]
[Link]#supported-speechcons -->

Additional Info: See ”Say-As” Slides Document for more details.

Emphasis (Speed & Volume)


Emphasis Tags:

• <emphasis level="strong">Slower and louder text</emphasis>


• <emphasis level="moderate">Normal text</emphasis>
• <emphasis level="reduced">Faster and softer text</emphasis>

Prosody: Volume, Pitch & Rate


Prosody Tags:

Volume
• <prosody volume="silent">Text</prosody>
• <prosody volume="x-soft">Text</prosody>
• <prosody volume="soft">Text</prosody>
• <prosody volume="medium">Text</prosody>
• <prosody volume="loud">Text</prosody>
• <prosody volume="x-loud">Text</prosody>
• <prosody volume="+6dB">Text</prosody> <!-- max +4.08dB -->

Pitch
• <prosody pitch="x-low">Text</prosody>
• <prosody pitch="low">Text</prosody>
• <prosody pitch="medium">Text</prosody>
• <prosody pitch="high">Text</prosody>
• <prosody pitch="x-high">Text</prosody>
• <prosody pitch="+10%">Text</prosody> <!-- max +50% -->
• <prosody pitch="-10%">Text</prosody> <!-- min -33.3% -->

Rate
• <prosody rate="x-slow">Text</prosody>
• <prosody rate="slow">Text</prosody>
• <prosody rate="medium">Text</prosody>

© [Link] 6
• <prosody rate="fast">Text</prosody>
• <prosody rate="x-fast">Text</prosody>
• <prosody rate="100%">Text</prosody> <!-- min 20% -->

Specify Pronunciation
Use the <sub alias> tag to pronounce abbreviations and acronyms:

• <sub alias="magnesium">Mg</sub>
• <sub alias="World Health Organization">WHO</sub>

Note: As Google TTS currently doesn’t interpret phonemes, use the <sub alias> tag as a workaround if
you need to pronounce words differently.

Embed Audio File


Use <audio> tags to include other audio in your text files:

<audio src="[Link]

<audio repeatCount="3" soundLevel="+2.28dB" fadeInDur="1s" fadeOutDur="1s src="https://


[Link]/folder/[Link]">AudioDescription</audio>

Notes:

• URL of audio must be ‘https’


• You can use .WAV, .MP3, .OGG audio files
• Amazon Polly = MP3 sound (max 240 seconds and no more than five)

Amazon Polly
The following SSML tags currently work only with Amazon Polly voices:

Phonemes
Use phoneme tags to pronounce words differently:

• <phoneme alphabet="ipa" ph="ˈbɑ.təl">bottle</phoneme>


• <phoneme alphabet="x-sampa" ph="&quot;bA.t@l">bottle</phoneme>

© [Link] 7
Whispered Voice
Use the whispered tag to create a whispering voice effect:

• <amazon:effect name="whispered">Whispered text</amazon:effect>

Languages
Use the language tag when you want your selected voice to speak certain words or sections of the text
from another language.

<lang xml:lang="de-DE">Entschuldigung</lang>

<!-- en-US, en-GB, en-IN, en-AU, en-CA, de-DE, es-ES, it-IT, ja-JP, fr-FR -->

Note: Unless the text has been translated into the other language, the selected voice will narrate the
text in the language of the content with a distinctive accent.

For example:

• English voice speaking English words = English sounding narration.


• English voice speaking French words = French words spoken with an English accent.
• French voice speaking French words = French words spoken with a French accent.
• French voice speaking English words = English words spoken with a French accent.

Part Of Speech Pronunciation


Use the <w> tag to instruct voices how to say words in a different way (e.g. the word “read” in “I read
the book” – will sound differently depending on whether it refers to the past or the present).

• <w role="amazon:VB"></w> <!-- present simple -->


• <w role="amazon:VBD"></w> <!-- past participle -->
• <w role="amazon:NN"></w> <!-- noun -->
• <w role="amazon:SENSE_1"></w> <!-- use the non-default pronunciation -->

© [Link] 8

Common questions

Powered by AI

Optional attributes like 'time' and 'strength' in the <break> tag allow for precise control over the duration and intensity of pauses in narrations. The 'time' attribute lets users specify the length of pauses in seconds or milliseconds, while the 'strength' attribute adjusts the relative intensity of the break, simulating natural speech patterns by varying the pause after commas, sentences, or paragraphs .

The <speak> tag serves as the root element in SSML used with Google TTS and Amazon Polly. Its fundamental purpose is to enclose the text that needs to be transformed into speech. By wrapping text within <speak> opening and closing tags, the text-to-speech system recognizes which parts to process and convert into audible speech .

When defining time values in the <break> tag for Amazon Polly, users should note the 10-second maximum duration constraint, equivalent to 10,000 milliseconds. Exceeding this limit can lead to ignored pauses, thus impacting the intended timing and flow of narrative content .

Phoneme tags in SSML specify how words should be articulated using phonetic scripts like IPA or X-SAMPA, which is particularly useful in adjusting pronunciations for non-standard phonemic representations. For instance, <phoneme alphabet='ipa' ph='ˈbɑ.təl'> enables accurate pronunciation of 'bottle', thereby enhancing intelligibility and naturalness in synthesized speech .

Audio tags (<audio>) in SSML allow the inclusion of external audio files such as .WAV, .MP3, and .OGG, enriching the listening experience by adding sound effects or musical elements. Constraints include mandatory HTTPS URLs for security and a limitation in file duration and number, as seen in Amazon Polly's cap of 240 seconds per file with a maximum of five files .

The <w> tag in SSML is used to specify how words are pronounced based on their part of speech, such as differentiating between the past and present tense of a verb (e.g., "read"). This tag uses roles like 'amazon:VB' for verbs or 'amazon:NN' for nouns to ensure correct pronunciation according to the context within a sentence .

Language tags in SSML allow parts of the text to be spoken in different languages, affecting the accent with which non-native words are rendered. For instance, using <lang xml:lang='de-DE'> with an English voice results in German content being pronounced with an English accent, and vice versa, highlighting the importance of selecting the correct language tag for intended pronunciation .

SSML tags like <emphasis> and <prosody> can be effectively combined to modulate speech expression, creating a more dynamic and engaging narration. For example, setting <emphasis level='strong'> while adjusting <prosody volume='loud' pitch='+10%'> within certain text passages can create standout moments, emphasizing key concepts and increasing listener engagement .

Prosody tags in SSML allow users to finely tune speech characteristics such as volume, pitch, and rate to enhance speech quality. Volume adjustments range from 'x-soft' to '+6dB', pitch from 'x-low' to '+50%', and rate from 'x-slow' to 'x-fast'. These variations facilitate dynamic message delivery, such as emphasizing certain passages or ensuring speech intelligibility in various auditory environments .

The <say-as> tag in SSML for text interpretation provides clarity by defining how certain formats (e.g., numbers) should be spoken, enhancing the naturalness of speech synthesis. For instance, <say-as interpret-as='cardinal'>150</say-as> ensures numerical clarity. However, the downside is the need for precise formatting in the SSML markup, which can increase complexity and errors if not correctly applied .

You might also like