Text normalization: from raw strings to correct speech

An engineer tracing written values into spoken output
An engineer tracing written values into spoken output

Text normalization converts text into a consistent form for a particular task. A search index may need case-insensitive words; a voice agent needs an amount, date, or reference number spoken correctly. Those goals require different transformations. The useful starting point is deciding which distinctions can disappear and which must survive, then separating the original text from every derived value.

What text normalization means

Text normalization maps different representations of text to a form an application can use consistently. The target form depends on the job: matching strings, preparing model input, displaying a transcript, or generating speech.

There is no universal cleanup sequence that suits all four. Lowercasing US to us loses a distinction. Removing punctuation from 12.50 changes an amount. Converting 0027 into an integer destroys information if the value is a reference code.

TaskExample transformationPurpose
Unicode normalizatione plus a combining acute accent → é under Normalization Form C (NFC)Give canonically equivalent character sequences a consistent representation
Natural language processing (NLP) preprocessingRunning → running, when case is irrelevantReduce variation for a defined search or model task
Speech text normalizationUSD 42.01 → “forty-two US dollars and one cent”Produce a spoken form for text-to-speech (TTS)
Inverse text normalization“forty-two dollars and one cent” → $42.01, with the currency context resolvedProduce readable written output from recognized speech

Text normalization changes text or its representation. Audio normalization changes signal levels, such as peak amplitude or perceived loudness. Making audio louder cannot resolve whether 03/04 means March 4 or April 3.

Common NLP normalization techniques

NLP pipelines often normalize text to reduce superficial differences. Each transformation needs a reason tied to the downstream task.

  • Case normalization: Lowercasing or case folding can support case-insensitive matching. Names, acronyms, and case-sensitive identifiers may need the original case.
  • Whitespace normalization: Trimming or collapsing spaces can help ordinary prose matching. Indentation, fixed-width data, and some identifiers need different treatment.
  • Spelling and abbreviation expansion: A domain dictionary can map a known abbreviation to its intended words. The same abbreviation can have several meanings.
  • Punctuation handling: Punctuation can be separated into tokens or omitted from a derived search representation. Decimal points, minus signs, apostrophes, and identifier separators carry meaning.
  • Stemming and lemmatization: Stemming reduces words through string rules; lemmatization maps inflected words to dictionary forms using linguistic information. These can help retrieval tasks, while making text unsuitable for direct speech output.

Tokenization, splitting text into units, is a related step. Stop-word removal is another possible preprocessing choice. Neither means every application should discard short words: removing “not” from a request changes its meaning.

A pretrained model's input contract also matters. Adding a separate lowercasing or punctuation-removal stage can change the input the model was designed to receive. A normalized search key, model input, display string, and spoken response can therefore be separate derivatives of the same source.

Unicode normalization is a separate decision

Unicode normalization handles defined equivalences between character sequences. For example, é can be one code point or an e followed by a combining acute accent. It does not interpret dates or amounts.

The four forms are:

FormTreatment
NFC (Normalization Form C)Canonical decomposition, then composition where possible
NFD (Normalization Form D)Canonical decomposition
NFKC (Normalization Form KC)Compatibility decomposition, then canonical composition
NFKD (Normalization Form KD)Compatibility decomposition

NFC and NFD preserve compatibility distinctions. NFKC and NFKD also fold characters such as ① into 1 and fi into fi. The Unicode normalization standard warns that compatibility normalization can erase meaningful distinctions.

NFC is a conservative choice for canonical equivalence. A separate NFKC matching key can suit a constrained domain where the lost distinctions are acceptable. Neither should overwrite the source text.

Speech normalization starts with the value's type

For speech, a string of digits is insufficient information. 123 could be a quantity, part of an address, or three characters in a code. The application needs a semantic type, meaning what the value represents, before choosing its spoken form.

These examples use explicit English rendering policies. They are application choices, not promises that every speech engine produces the same wording.

Input and contextIntended spoken formInformation that must survive
123, quantity“one hundred twenty-three”Numeric value
3.05, decimal“three point zero five”Decimal position and fractional digits
2026-04-03, calendar date“April third, twenty twenty-six”Year, month, and day
USD 42.01, money“forty-two US dollars and one cent”Amount and currency code
AB-0207, reference code“A B dash zero two zero seven”Letters, leading zero, order, and separator
Dr. Patel, title“Doctor Patel”Intended meaning of the abbreviation
12 kg, measurement“twelve kilograms”Numeric value and unit

Numbers, currency, and measurements

Quantities can use cardinal numbers, such as “twelve.” Rankings can use ordinals, such as “twelfth.” Phone numbers and identifiers need a digit or character policy, including whether zero is spoken as “zero” and whether separators are spoken or represented by pauses.

Money needs a decimal amount and a currency code. $ alone cannot identify a currency: several currencies share the symbol. Unicode recommends three-letter currency codes when exact currency identity matters. A record containing amount: "42.01" and currency: "USD" has enough information for an explicit rendering policy; $42.01 alone may not.

Measurements similarly need a known unit. Expanding m to “meters” is wrong when the field means minutes. Normalization should preserve the quantity and unit rather than silently perform a unit conversion.

Dates and times

03/04/2026 is ambiguous without an input-format contract. A US month/day/year field means March 4. A day/month/year field means April 3. The interface language alone may not establish the format of imported data.

A date parser needs the source format; a speech renderer needs the output language and locale. An appointment time also needs the relevant date and time zone. A calendar date, such as a birthday, should remain a date rather than acquire an arbitrary time zone.

When context is missing, the correct result is an unresolved value and a clarification, such as “Do you mean March fourth or April third?” Fluent speech does not justify choosing one interpretation.

Abbreviations and identifiers

St. can mean “Street” or “Saint.” Dr. can be a title or part of an address. A domain dictionary needs field context and exceptions, rather than a global replacement rule.

Acronyms also need explicit treatment. Some are spoken as words; others are spelled out. A product lexicon can record the approved form without changing the stored name.

Identifiers need stricter boundaries. A code such as AB-0207 remains a string throughout parsing and storage. Converting its numeric suffix to an integer loses the zero. Changing case or dropping the hyphen is valid only if the identifier's own contract declares those distinctions irrelevant.

Preserve raw, canonical, display, and spoken values

A useful normalization record separates four representations:

  1. Raw text: The exact source string received at the application boundary.
  2. Canonical value: A typed value for application logic, such as a calendar date, decimal amount plus currency, or identifier string.
  3. Display text: A readable written representation for a user interface or transcript.
  4. Spoken form: Words or supported speech markup sent to synthesis.

The raw string stays unchanged within the retention period. Each derivative carries its own purpose. Retention and access controls still apply; preserving source data does not mean logging sensitive values everywhere indefinitely.

Raw text is preserved while typed interpretation produces separate display and spoken forms.

For example, a proposed application record can look like this:

JSON
{ "raw_text": "AB-0207", "semantic_type": "reference_code", "canonical_value": "AB-0207", "display_text": "AB-0207", "spoken_form": "A B dash zero two zero seven", "output_locale": "en-US", "status": "resolved", "rule_version": "reference-code-v1" }

This is an application schema, not a Dasha API payload. Dates need input-format metadata; amounts need currency; measurements need unit codes. An unresolved record should have no executable canonical value. A model confidence score alone should not promote an ambiguous amount or date to a resolved value.

A normalization pipeline with clear boundaries

A production pipeline can make each decision inspectable:

  1. Capture the source and its context. Keep the original string, field name, source format, and relevant locale or business context.
  2. Create any character-normalized derivative. Apply the chosen Unicode policy without losing the original or invalidating source-span mappings.
  3. Classify the value. Prefer a known field type, such as reference_code, over guesses from appearance. Unstructured text may need contextual classification.
  4. Parse and validate. Resolve calendar dates, decimal amounts, units, and identifiers under their own contracts. Invalid or ambiguous input stays unresolved.
  5. Render separately. Produce display and spoken forms from the resolved value, retaining rule and engine configuration versions.
  6. Record the outcome. Keep the status and decision provenance so a changed output can be traced to parsing, rendering, or synthesis.

Rule-based systems suit bounded formats and explicit exceptions. Finite-state grammars express those transformations as constrained paths between inputs and outputs. Models can help interpret surrounding language, but a plausible rewrite can still change a value. A hybrid design can use contextual interpretation to propose a type, then require typed validation before rendering it.

Streaming output needs the same boundary. When an amount field or phrase is still incomplete, a formatter that has received 12 before .50 must not commit “twelve dollars” and later discover the cents. Buffering through that complete value preserves meaning, with a corresponding delay. The commitment unit can be a typed field or a complete phrase rather than an arbitrary text chunk.

A small Python example that preserves identifiers

Python's standard library supports Unicode normalization. It does not infer a safe speech policy for an arbitrary date, amount, or identifier. This bounded example accepts only an uppercase, two-letter reference prefix followed by a hyphen and four ASCII digits. It rejects other formats rather than repairing them silently.

Python
import re import unicodedata DIGITS = dict(zip("0123456789", ( "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" ))) def normalize_reference(raw: str) -> dict: result = { "raw_text": raw, "unicode_text": unicodedata.normalize("NFC", raw), "semantic_type": "reference_code", "canonical_value": None, "spoken_form": None, "status": "unresolved", "rule_version": "reference-code-v1", } if not re.fullmatch(r"[A-Z]{2}-[0-9]{4}", raw): return result prefix, digits = raw.split("-") result.update( canonical_value=raw, spoken_form=" ".join([ *prefix, "dash", *(DIGITS[d] for d in digits) ]), status="resolved", ) return result record = normalize_reference("AB-0207") assert record["raw_text"] == record["canonical_value"] == "AB-0207" assert record["spoken_form"] == "A B dash zero two zero seven" assert normalize_reference("AB-207")["status"] == "unresolved" assert normalize_reference("ab-0207")["status"] == "unresolved"

The identifier validator intentionally uses the raw string. A compatibility-normalized matching key must not silently turn an out-of-contract identifier into an accepted one. Spoken letter names and pacing still belong to the selected voice's rendering behavior.

Inverse text normalization does not recover the original

Inverse text normalization (ITN) converts spoken-domain recognition output into written-domain text. For example, “twenty-three” can become 23. The Interspeech ITN paper describes readability as its purpose and highlights the low tolerance for unrecoverable errors.

“Inverse” does not imply a lossless round trip. Speech may not reveal whether the speaker intended 23, twenty-three, or digits in a code. Recognition output may already include punctuation and number formatting. A field named raw therefore needs an explicit definition: raw application input is not necessarily a verbatim record of the audio.

For agent actions, recognized wording, interpreted fields, and permission to act remain separate. Our real-time transcription guide explains why a finalized transcript can still precede a correction or an unresolved request.

Speech markup and regression fixtures

Speech Synthesis Markup Language (SSML) provides hints such as say-as to indicate how text should be interpreted. It is a rendering interface, not a substitute for deciding whether a string is a date or an identifier.

The W3C SSML specification defines interpret-as, format, and detail, without defining a universal vocabulary of supported values. Unsupported interpretation hints can fall back to ordinary rendering. A tag accepted by one engine therefore does not establish compatibility with another voice, language, or API.

A speech adapter can use supported markup or explicit spoken words according to its engine contract. Either path needs output evidence: an accurate text string does not establish that the generated audio preserved every digit.

A versioned regression corpus should cover both expected wording and semantic invariants:

FixtureRequired invariant
03/04/2026, no known input formatRemains unresolved; no calendar date is invented
The same date with explicit month/day/year and day/month/year formatsProduces the two intended dates
$42.01, no currency contextDoes not invent USD or another currency
AB-0207, AB-207, and ab-0207Preserves raw strings and applies the identifier contract exactly
3.05 beside an identifier containing 305Keeps decimal and identifier policies separate
Dr. Patel beside an address ending in Dr.Uses context-specific expansions
Unsupported speech-markup hintExposes the fallback behavior of the deployed engine

Release comparisons need the parser, rules, model, locale data, provider, voice, and API configuration that produced each result. Changed expectations deserve an explicit decision. Exact-string equality catches wording changes; typed-value assertions catch semantic changes; audio review catches pronunciation and missing-character errors. None substitutes for the others.

Keep normalization visible in voice-agent operations

For a search index or document processor, a dedicated text-processing library may be all the infrastructure required. A production voice agent also needs a way to connect the source value, tool result, response text, and audible outcome.

At Dasha, we give technical teams a managed runtime, REST APIs, and a web application for building and running production voice AI agents. Our completed-call inspection includes transcripts, recordings, model interactions, tool executions, and timeline events. Those views support investigation alongside your application's normalization records. Your application still owns its normalization policy and raw-to-derived data contract; call inspection does not establish semantic correctness automatically.

When investigating an amount, date, or identifier in a completed call, use our call inspection workflow to review the transcript, tool and timeline evidence, and recording together.

Share

Subscribe

Sign up to our e-mail list to get the best of the Dasha blog sent directly to your inbox.

We use cookies for functional and analytical purposes. Please refer to our Privacy Policy for details.