How do pronunciation dictionaries fix how TTS says names and brands?

Authors
How do pronunciation dictionaries fix how TTS says names and brands?

A pronunciation dictionary is a list of words with the exact way each one must be spoken, so that a TTS (Text-to-Speech) model says names and brands correctly instead of guessing from the spelling.

In this blog, we will learn about how pronunciation dictionaries fix how TTS says names and brands. We will also see why TTS gets names wrong in the first place, the two kinds of rules (alias and phoneme), how the dictionary is applied, how a dictionary file looks, how it fits inside a voice agent, and where it works well and where it fails.

We will cover the following:

  • Why TTS mispronounces names and brands
  • How TTS turns letters into sounds
  • What is a pronunciation dictionary?
  • Alias rules
  • Phoneme rules
  • How the dictionary is applied
  • What a dictionary file looks like
  • How matching works: case and whole words
  • Using a pronunciation dictionary in a voice agent
  • Where it works well and where it fails

I am Amit Shekhar, Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.

I teach AI and Machine Learning at Outcome School.

Let's get started.

Why TTS mispronounces names and brands

TTS (Text-to-Speech) is a model that takes written text and turns it into spoken audio. Voice assistants, audiobook apps, and voice AI agents on phone calls all use TTS to talk to us.

Most of the time, TTS sounds very natural. But the moment it meets a name like "Siobhan" or a brand like "Xiaomi", it often says something strange.

Let's say we are building a voice agent for a phone shop. A customer calls, and the agent says:

"Sure, we have the latest Xiaomi phone in stock."

The correct way to say "Xiaomi" is close to "SHAO-mee". But a TTS can read the letters the way English letters usually sound and say something like "zee-AH-oh-mee". The customer notices it, and it makes the brand look bad.

The same thing happens with:

  • People's names: "Siobhan" is said "shi-VAWN", but a TTS can follow the English spelling and say something like "see-OB-han".
  • Brand names: "Porsche" is said "POR-shuh", but a TTS can say "porsh".
  • Acronyms: our team can want "SQL" said as "sequel", but a TTS can read it as "S Q L" instead.
  • Same letters, different words: "US" (the country) and "us" (the word) have the same letters but different sounds.

So, why does this happen? To answer this, we must first understand how TTS turns letters into sounds.

How TTS turns letters into sounds

When we read a word, we do not read letters. We read sounds. The word "cat" has three sounds: "k", "a", and "t".

These units of sound are called phonemes. A phoneme is the smallest sound in a language that can change the meaning of a word. For example, "cat" and "bat" differ by only one phoneme: "k" vs "b".

Here, the problem is that English spelling does not match its sounds very well. The letters "ough" sound different in "though", "through", and "tough". So, a TTS system cannot simply map each letter to one sound.

To solve this, a TTS system does a step called grapheme-to-phoneme conversion. A grapheme is a written letter or group of letters. So, grapheme-to-phoneme means "from letters to sounds".

For common words, the TTS already knows the correct sounds, because it has seen them many times. For a word it has never seen, it has to guess based on the patterns of spelling it learned.

Note: Many modern neural TTS models do not have a separate, visible grapheme-to-phoneme step. They learn the letter-to-sound mapping inside the model itself. But the idea is the same: for an unfamiliar word, the model guesses from spelling.

Now, think about names and brands:

  • They are rare, so the model has seen them very less during training.
  • They often come from other languages, like "Xiaomi" from Chinese or "Siobhan" from Irish, which follow different spelling rules.
  • New brands are invented every day, so no model can know all of them.

So, the TTS guesses from the spelling. And for names and brands, that guess is often wrong.

Now, the question is: how do we tell the TTS the correct way to say a word? Here comes the pronunciation dictionary into the picture.

What is a pronunciation dictionary?

A pronunciation dictionary is a list of words, where each word is paired with the exact way it must be spoken. Before the TTS speaks, it checks this list, and if a word is in the list, it uses our pronunciation instead of guessing.

Think of a new receptionist at an office. On the first day, the manager gives them a note: "Our client Mr. Nguyen is said 'win'. The brand 'Qdrant' is said 'quadrant'." Now, the receptionist does not guess. They read the note and say each name correctly.

A pronunciation dictionary does the same job for TTS.

Each entry in the dictionary is called a rule. A rule has two parts:

  • The word to find: the text exactly as it appears, for example "Xiaomi".
  • How to say it: the correct pronunciation.

There are two kinds of rules, based on how we write "how to say it". Let's learn about each of them.

Alias rules

An alias rule replaces a word with another spelling that the TTS already knows how to say.

The word "alias" means "another name". So, we give the hard word another name, which is easier for the TTS.

For example:

Word to findAlias (say it as)
XiaomiShaomee
SQLsequel
Nguyenwin
Dr.Doctor
Qdrantquadrant

Here, when the text contains "Xiaomi", the TTS actually reads "Shaomee". The listener hears "SHAO-mee", which is correct. The written text in our app still shows "Xiaomi". Only the spoken version changes.

Advantage: Alias rules are easy to write. Anyone in the team can write them, and they work with most TTS models, because the TTS is reading a normal-looking word.

Disadvantage: Alias rules are not exact. We are still depending on the TTS to guess how to say "Shaomee". Most of the time it works, but sometimes we need to try a few spellings before one sounds right.

Planning your move into AI?

No matter which tech domain you work in today, with your effort, you can transition to these roles:

  • AI Engineer
  • Forward Deployed Engineer
  • AI Agent Engineer
  • Harness Engineer
  • Voice AI Engineer
  • AI Architect
  • LLM Engineer
  • LLM Inference Engineer
  • Gen AI Engineer
  • MLOps Engineer
  • ML Engineer
  • Deep Learning Engineer

Our AI and Machine Learning Program at Outcome School takes you there.

When we need exact control, we use the next kind of rule.

Phoneme rules

A phoneme rule tells the TTS the exact sounds of a word, written in a special sound alphabet.

A widely used sound alphabet is IPA (International Phonetic Alphabet). In IPA, each symbol stands for one sound, and it means the same sound no matter which word or language it is used in. So, there is no guessing.

For example:

Word to findIPARoughly sounds like
Siobhanʃɪˈvɔːnshi-VAWN
XiaomiˈʃaʊmiSHAO-mee
PorscheˈpɔːrʃəPOR-shuh

Here, the symbol ʃ always means the "sh" sound. The mark ˈ comes before the part of the word that gets the stress, which means the part that is said a little louder and longer. So, ʃɪˈvɔːn says: "sh", then "ih", then a stressed "vawn".

Some TTS providers also support CMU Arpabet, which writes English sounds using plain capital letters and numbers, for example SH IH0 V AO1 N for "Siobhan". The numbers show the stress.

Advantage: Phoneme rules are exact. The TTS does not guess anything.

Disadvantage: Writing IPA needs some practice, although we can often find the IPA of a well-known name in a good online dictionary. Also, not every TTS model supports phoneme rules. Some models only support alias rules, so we must check the documentation of our TTS provider.

Now that we have learned about both kinds of rules, it's time to see how the TTS uses them.

How the dictionary is applied

The best way to learn this is by taking an example. Let's say the text to be spoken is:

"Siobhan, your Xiaomi order is ready."

And our dictionary has two rules: a phoneme rule for "Siobhan" and an alias rule for "Xiaomi".

The flow looks like below:

+--------------------------------------+
| Text: "Siobhan, your Xiaomi order    |
|        is ready."                    |
+--------------------------------------+
                   ↓
+--------------------------------------+
| Look up each word in the dictionary  |
+--------------------------------------+
                   ↓
+--------------------------------------+
| "Siobhan" found: use ʃɪˈvɔːn         |
| "Xiaomi" found: say "Shaomee"        |
| Other words not found: normal path   |
+--------------------------------------+
                   ↓
+--------------------------------------+
| TTS model creates the audio          |
+--------------------------------------+
                   ↓
+--------------------------------------+
| Audio: "shi-VAWN, your SHAO-mee      |
|         order is ready."             |
+--------------------------------------+

Here, the TTS looks up each word in the pronunciation dictionary. For "Siobhan", it finds a phoneme rule, so it uses the exact sounds ʃɪˈvɔːn. For "Xiaomi", it finds an alias rule, so it reads "Shaomee" instead. The words "your", "order", "is", and "ready" are not in the dictionary, so the TTS handles them in its normal way.

Then, the TTS model creates the audio with the correct sounds.

This is how a pronunciation dictionary fixes the pronunciation without changing the text that the user sees.

A quick note for you

No matter which tech domain you work in, get familiar with these topics:

  • LLM
  • RAG
  • MCP
  • Agent
  • Fine-tuning
  • Quantization

We put it all together in one video:

AI Engineering Explained: LLM, RAG, MCP, Agent, Fine-Tuning, and Quantization

No need to stop reading - bookmark it and watch later when you get time. Future you will thank you.

Now, let's get back to the topic.

What a dictionary file looks like

There is an open standard for pronunciation dictionaries called PLS (Pronunciation Lexicon Specification), created by the W3C. Many TTS providers accept PLS files.

A PLS file is written in XML. It looks like below:

<?xml version="1.0" encoding="UTF-8"?>
<lexicon version="1.0"
      xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
      alphabet="ipa" xml:lang="en-US">
  <lexeme>
    <grapheme>Siobhan</grapheme>
    <phoneme>ʃɪˈvɔːn</phoneme>
  </lexeme>
  <lexeme>
    <grapheme>Xiaomi</grapheme>
    <alias>Shaomee</alias>
  </lexeme>
</lexicon>

Here, we have:

  • lexicon: the whole dictionary. alphabet="ipa" says that our phoneme rules use IPA, and xml:lang="en-US" says the language is American English.
  • lexeme: one rule.
  • grapheme: the word to find, exactly as it is written. One lexeme can have more than one grapheme, for example "Xiaomi" and "XIAOMI", so that both spellings share one pronunciation.
  • phoneme: the exact sounds, for a phoneme rule.
  • alias: the replacement spelling, for an alias rule.

Usually, we upload this file to our TTS provider once, and then we refer to it in our requests. The TTS applies it automatically.

Note: If we need to fix only one word in one sentence, many TTS providers also support SSML (Speech Synthesis Markup Language) tags inside the text itself, like below:

<speak>
  <phoneme alphabet="ipa" ph="ʃɪˈvɔːn">Siobhan</phoneme>, your
  <sub alias="Shaomee">Xiaomi</sub> order is ready.
</speak>

Here, the phoneme tag is a phoneme rule, and the sub tag is an alias rule, but only for this one sentence. A dictionary is better when the same word appears again and again, because we write the rule once and it works everywhere.

Stay updated: Subscribe to our newsletter to get our latest AI and Machine Learning blogs straight to your inbox.

How matching works: case and whole words

The dictionary must find the right word, and only the right word. Two details decide this.

Case: We want the matching to be case-sensitive, which means "US" and "us" are treated as two different words. "US" (the country) can have the alias "United States", while "us" (the word) stays untouched. If matching were not case-sensitive, the sentence "Call us today" would become "Call United States today".

Whole words: The rule must match the whole word, not a part of another word. A rule that turns "SQL" into "sequel" must not change the "SQL" inside "MySQL" or "PostgreSQL".

If our TTS provider does not support a dictionary, or we want the same rules across many providers, we can apply alias rules in our own code before sending the text. We can write the code as below:

import re

aliases = {
    "Xiaomi": "Shaomee",
    "SQL": "sequel",
    "US": "United States",
}

def apply_aliases(text):
    for word, alias in aliases.items():
        # \b means whole word only, and the match is case-sensitive
        text = re.sub(rf"\b{re.escape(word)}\b", alias, text)
    return text

print(apply_aliases("Call us about the US launch of the Xiaomi phone."))

This will print the following:

Call us about the United States launch of the Shaomee phone.

Here, we can see that:

  • "US" became "United States", but "us" stayed the same, because the match is case-sensitive.
  • "Xiaomi" became "Shaomee", so the TTS says it correctly.
  • \b makes sure that we only match whole words, so a word like "MySQL" stays untouched.

We only send this changed text to the TTS. The text shown on the screen stays the same.

Using a pronunciation dictionary in a voice agent

In a voice AI agent, the flow is: the user speaks, STT (Speech-to-Text) turns it into text, the LLM (Large Language Model) writes a reply, and TTS speaks that reply.

The pronunciation dictionary sits right before the TTS step. Whatever the LLM writes, the dictionary fixes every name and brand that it knows, before the audio is created.

We have a detailed blog on cascaded vs speech-to-speech voice agents that explains how this chain of STT, LLM, and TTS compares with the other way of building a voice agent.

A few practical points:

  • Start with our own words: our company name, product names, team member names, and the common customer names in our region.
  • Listen and add: we must listen to real call recordings. Every time the agent says a word wrong, we add a rule for it.
  • Test every rule: after adding a rule, we must play the audio and check it, because an alias that looks right on paper can still sound wrong.
  • Cover every spelling: the LLM can write "Xiaomi", "XIAOMI", or "xiaomi". With case-sensitive matching, each form must be listed, for example as extra grapheme entries.
  • Keep one dictionary per language: the same word can be said differently in different languages, so a dictionary is usually tied to one language.

If we want to go deep into how to Design a Real-Time Voice AI Agent, from speech recognition to the final spoken reply, we have a complete program on it: check out our AI and Machine Learning Program at Outcome School.

Where it works well and where it fails

It works well for:

  • Brand names and product names that we know in advance.
  • Names of people that we know in advance, like our staff or customers saved in our system.
  • Acronyms and short forms, like "SQL" and "Dr.".
  • Words that the TTS gets wrong every time, because one rule fixes them in every sentence.

It fails or struggles with:

  • Unknown names: a dictionary only knows the words we put in it. If a new customer has a rare name, the TTS will still guess.
  • Same spelling, different sounds: "read" can be "reed" or "red", "live" can be "liv" or "lyve", and "Dr." can be "Doctor" or "Drive", depending on the sentence. A simple dictionary rule always picks one, so it cannot fix both cases.
  • The same name said differently by different people: two people can spell their name the same way and say it differently. The dictionary has only one rule per spelling, so for such names we must store the pronunciation with each person's record and add it to that one sentence using an SSML phoneme tag.
  • Model support: some TTS models skip phoneme rules and fall back to their default pronunciation. On those models, we must use alias rules.

We have a detailed blog on how keyword boosting helps ASR recognize domain words that covers the same problem on the listening side.

Now we must have understood how pronunciation dictionaries fix how TTS says names and brands, how alias and phoneme rules work, how the dictionary is applied, and where it works well and where it fails.

Frequently Asked Questions

Is a pronunciation dictionary the same as SSML?

No. SSML tags like phoneme and sub fix a word only inside the one sentence where we write them. A pronunciation dictionary holds rules that we write once, and the TTS applies them everywhere the word appears. So, a dictionary is the better choice for names and brands that come up again and again.

Does a pronunciation dictionary change the text shown to the user?

No. A pronunciation dictionary changes only the spoken version of the text. For example, with an alias rule, the TTS reads "Shaomee", but the written text in our app still shows "Xiaomi". The fix happens right before the audio is created, so the text on the screen stays the same.

What is a PLS file?

A PLS file is a pronunciation dictionary written in XML using the Pronunciation Lexicon Specification, an open standard created by the W3C. Each lexeme in the file is one rule, with a grapheme for the word to find and either a phoneme or an alias for how to say it. Many TTS providers accept PLS files.

Can we use a pronunciation dictionary if our TTS provider does not support one?

Yes. We can apply alias rules in our own code before sending the text to the TTS. The code must match whole words only and be case-sensitive, so that "US" changes but "us" and "MySQL" stay untouched. This also lets us keep the same rules across many TTS providers.

That's it for now.

Thanks

Amit Shekhar
Founder @ Outcome School

You can connect with me on:

Follow Outcome School on:

Read all of our high-quality blogs here.