Lesson 11 / Unit 3: Text Processing
Pronunciation Control
Our model has 29 input symbols and one pronunciation control: spelling. What a phoneme front end adds, from lexicon entries to SSML, and when a word needs data.
Our tiny model has 29 input symbols and exactly one pronunciation control: how you spell the word. There is no phoneme input, no dictionary and no markup. If it says a name wrong, the only thing you can change is the letters you send.
Check which input controls your engine supports: respelling, lexicon entries, phoneme input or SSML. Test one correction before collecting training data.
Correction Options
You override the text front end for that word, at the cheapest layer the engine exposes. There are four layers, and which ones exist depends on whether the model reads characters or phonemes:
| Lever | What you change | Needs a phoneme front end |
|---|---|---|
| Respelling | The input text (for example, a name sent in phonetic spelling) | No |
| Pronunciation dictionary (word to phonemes) | One lookup entry, applied to every request | Yes |
| Phoneme or IPA input | The phonemes for one word in one request | Yes |
SSML phoneme tag | Same, as markup, if the engine parses SSML | Yes, plus SSML support |
Respelling is the only one available to us. It works because the character model has learned a mapping from letter patterns to sounds, so you pick letters whose usual sound is the one you want. It is also fragile: the respelling that works on one model may not on the next, and every caller has to apply it. In a pipeline, it belongs in the normaliser, as a lookup that runs before the number rules in text normalisation, so the fix lives in one place.
Pronunciation Lexicons
A pronunciation dictionary, or lexicon, maps a written word to its phonemes, and the front end consults it before falling back to G2P. Add an entry for a product name or a drug name, and every sentence containing it uses your pronunciation from then on.
That order is the design of most phoneme front ends. NVIDIA’s NeMo G2P documentation describes dictionary lookups (the CMU dictionary is its example) with a trained model for what the dictionary does not cover, and puts the point plainly: phonetic input lets you “enforce the desired pronunciation by providing a phonetic transcript”. Grapheme to phoneme covers the models behind the fallback.
Two properties make a lexicon the workhorse. It is global, so one entry fixes the word everywhere. And it is data, so it can be reviewed, versioned and tested like any other config. Heteronyms are its blind spot: one entry per spelling cannot say “read” two ways, which is why G2P models read context.
Phoneme Overrides
Engines that run a phonemizer usually let you bypass it for part of the input. Piper, which uses espeak-ng for phonemes, documents this in its CLI guide: “You can inject raw espeak-ng phonemes with [[ <phonemes> ]] blocks.” The guide’s example:
I am the [[ bˈætmæn ]]It also shows where to get the phonemes: ask espeak-ng for a word you can spell, then edit the result.
espeak-ng -v en-us --ipa=3 -q batmanWe did not run these overrides; this is Piper’s documented interface. The workflow it implies is the useful part. Start from what espeak-ng emits for a word you can spell and edit only the sounds that are wrong, so the symbols match what the model was trained on.
SSML Phonemes
Yes, as a standard element that each engine may or may not implement. The W3C SSML 1.1 specification defines phoneme with a required ph attribute holding the pronunciation and an optional alphabet attribute, and says synthesis processors “SHOULD support a value for alphabet of ‘ipa’”. Anything beyond that is at the processor’s discretion.
Amazon Polly is one engine that documents it. Its phoneme tag page accepts ipa and x-sampa, says the tag is supported by its long-form, neural and standard formats, and gives this example:
<speak> You say, <phoneme alphabet="ipa" ph="pɪˈkɑːn">pecan</phoneme>. I say, <phoneme alphabet="ipa" ph="ˈpi.kæn">pecan</phoneme>.</speak>Check your own engine’s docs, then test the tag on the word you care about. Depending on the engine, markup it does not support may be rejected, ignored or read aloud, and an ignored tag leaves exactly the pronunciation you were trying to fix.
Manual Corrections
Take your list of pronunciation failures, fix ten of them by hand with a normaliser rule or a dictionary entry, and run the list again. If it gets shorter and stays short, you have a dictionary problem. If new failures keep arriving at the same rate, you have a distribution problem.
Our hard set illustrates the split. The digit failures were one class with one fix: adding a normaliser took the tiny model from 64.4% to 35.6% hard-set WER at step 1,650, in our harness on a 4-core cloud container with no GPU. That figure flatters the normaliser: the scorer builds its reference with the same normaliser, so its phone-number and leading-zero mistakes count as correct (the text normalisation lesson lists the caveats). Names such as Saoirse and Nguyen are individual items, the textbook case for a lexicon entry, on an engine that has one. The long agent-style sentence is different. Our model turned “refund policy” into “revenge quality” and “the bank” into “the back” (26% WER on that sentence, at step 1,650), in ordinary words with no digits or rare names. A dictionary entry per word would chase that forever, because the model is short of data, not short of entries.
Adaptation Criteria
When the failures are a pattern the model has not learned: an accent or dialect it renders as its nearest neighbour, a domain register where rhythm and vocabulary are unusual together, or, in our case, a model trained on 0.74 hours of audio. No lexicon changes a vowel system.
When to fine-tune sets out the full escalation order and what a fine-tune has to prove before you pay for it. Measure first either way: the eval harness is where the failure list comes from.
Start a lexicon
Take the names, product terms and abbreviations your agent says most often. Run each through your engine once and keep the ones it gets wrong. For each, write the fix at the cheapest layer the engine has, add the word to a fixed test sentence, and re-run the whole list after every change.
Next: how text-to-speech works, where the symbols from this front end meet the acoustic model.
Common questions
How do you change how a TTS voice pronounces a word?
In order of cost: respell the word in the input text, add an entry to the pronunciation dictionary the front end consults before G2P, pass phonemes directly where the engine accepts them, or wrap the word in an SSML phoneme tag where the engine supports SSML. Only the first works on a character model like ours; the others need a phoneme front end.
Does SSML support IPA pronunciations?
The W3C SSML 1.1 specification defines a phoneme element with a required ph attribute and an optional alphabet attribute, and says synthesis processors should support the value "ipa". Support is up to each engine. Amazon Polly, for example, documents the phoneme tag with IPA and X-SAMPA alphabets.
When is a pronunciation problem a reason to fine-tune?
When fixing words one at a time does not shrink the failure list. Fix ten failures by hand and re-run: if the list gets shorter and stays short, keep a dictionary. If new failures keep arriving at the same rate, the model has not learned a pattern, such as an accent or a domain register, and that needs data.
We do this work for teams shipping voice agents: Self-Hosted Voice Agent .
Edit this lesson on GitHub ↗Discussion
Questions, corrections and war stories welcome. Sign in with GitHub to comment.