Substitute

When you're looking to control the spoken output of your text-to-speech (TTS) application, especially for rendering unusual words, specific names, or acronyms, the <sub> tag in SSML becomes invaluable. It enables you to specify an alternative pronunciation for any word or phrase.

Attributes of the Substitute Tag

  • alias – This is a required attribute that determines what the TTS will pronounce in place of the original text.

For instance, you might want the TTS to read "USA" as "United States of America". Here's how you would do it:

<speak>
  I live in the <sub alias="United States of America">USA</sub>.
</speak>

In this example, the TTS will speak "I live in the United States of America" even though "USA" is written in the text. This ensures that the TTS output is natural-sounding and contextually appropriate.

Best Practices

  • Always provide an alias: Without an alias, the <sub> tag cannot function properly.

  • Use for clarity: Employ the <sub> tag to clarify pronunciation, particularly for acronyms or industry-specific terminology that may not be universally recognized.

  • Ensure natural pronunciation: The substitution should be crafted to sound as natural as possible within the context of the sentence.

Last updated