SSML Say-As Guide: Phone Numbers and Ordinals
Speech Synthesis Markup Language (SSML) provides developers with
precise control over synthetic speech, resolving ambiguities that
standard Text-to-Speech (TTS) engines encounter. The
<say-as> tag is an essential SSML element that
defines the exact context of text, instructing the voice engine on how
to interpret ambiguous characters. This article explains how the
<say-as> tag assists TTS engines in correctly
vocalizing telephone numbers and ordinal values, transforming raw digits
into clear, human-like speech.
The Challenge of Numerical Ambiguity in TTS
By default, TTS engines rely on built-in text normalization algorithms to convert written text into spoken words. When encountering numbers, a TTS engine typically defaults to cardinal values. For example, the string "123" is natively spoken as "one hundred twenty-three."
Without explicit semantic markup, an engine struggles to determine
whether a string of digits represents a quantity, a monetary amount, a
sequence of individual digits, or a rank. The
<say-as> element removes this ambiguity by applying
the interpret-as attribute, which explicitly dictates the
speech rules the engine must apply.
Pronouncing Telephone
Numbers with <say-as>
When a phone number lacks formatting or uses unconventional spacing, a standard TTS engine might attempt to pronounce it as a massive cardinal number or misplace the conversational rhythm.
By applying <say-as interpret-as="telephone">, the
developer instructs the engine to process the input according to
standard telecommunication conventions:
- Digit-by-Digit Parsing: Instead of reading "8005550199" as "eight billion...", the tag ensures each number is spoken individually ("eight, zero, zero...").
- Natural Cadence and Grouping: TTS systems apply localized pauses between area codes, exchange codes, and subscriber numbers, matching human speech rhythms.
- Special Character Handling: Characters like
hyphens, parentheses, plus signs (
+for country codes), and the letter "x" (for extensions) are vocalized appropriately (e.g., announcing "extension" rather than the letter "x").
<speak>
Please call our support line at
<say-as interpret-as="telephone" google:style="zero-as-o">1-800-555-0199</say-as>.
</speak>Vocalizing Ordinal Values
with <say-as>
Ordinal numbers denote position, rank, or sequence (e.g., first, second, third). Written text often presents ordinals ambiguously—either with suffixes like "1st", "2nd", or as plain integers within a list or date context (e.g., "May 4").
Using <say-as interpret-as="ordinal"> guarantees
that the TTS engine translates the digit into its ranked verbal form
rather than a simple count:
- Converting Digits to Ordinal Words: Wrapping the digit "1" with this tag forces the engine to synthesize "first" instead of "one."
- Handling Complex Numbers: Multidigit numbers are handled correctly according to grammatical rules, such as pronouncing "21" as "twenty-first" rather than "twenty-one."
- Eliminating Suffix Dependency: It allows developers to feed raw integers into the engine without needing programmatic string manipulation to append "st", "nd", "rd", or "th" before passing text to the voice synthesizer.
<speak>
You are the <say-as interpret-as="ordinal">3</say-as> caller in line,
and this is your <say-as interpret-as="ordinal">21st</say-as> reminder.
</speak>Summary
The SSML <say-as> tag bridges the gap between
written text and auditory comprehension. By explicitly tagging strings
with interpret-as="telephone" and
interpret-as="ordinal", developers eliminate TTS
pronunciation errors, ensuring automated voice systems deliver clear,
professional, and natural-sounding audio.