CMU Flite developer on retainer: 12–18% intelligibility regression on UK road codes after Flite 1.4 to 2.2 upgrade — tokenizer reclassifies single-letter parenthetical designators as punctuation and drops them from synthesis — domain text normalization layer expands road codes before synthesis and eliminates regression — 3 weeks — CMU Flite developer on monthly retainer

CMU Flite (cmuflite/flite) lightweight text-to-speech synthesis library • Python 3.10 (Flite via ctypes); CMU Flite 2.2 • production embedded TTS for an automotive navigation system running on ARM Cortex-A7 MCU deployed in 500 delivery vans for a last-mile logistics company; correct intelligibility for UK road navigation instructions covering M-roads, A-roads, and B-roads; 12–18% intelligibility regression on UK road codes (M25, A127(M), B4544) after upgrading embedded Flite firmware from version 1.4 to 2.2 • developer investigates Flite tokenizer changes, text normalization rules, and version diff for 3 weeks • root cause: Flite 2.2 tokenizer reclassifies single-letter parenthetical designators — (M) motorway marker in British road codes — as punctuation and drops them silently from the synthesis queue; additionally, Flite 2.2 reads M-road codes as letter-name plus cardinal (“em twenty-five”) and reads 4-digit B-road numbers as cardinals (“four thousand five hundred forty-four”) • fix: domain text normalization pre-processor using 4 regex substitutions applied before Flite synthesis • UK road code intelligibility regression: 12–18% → under 3%; 1.5h retainer engagement

Eastfield Flite Ltd. had deployed an automotive navigation TTS system across a fleet of 500 delivery vans for a last-mile logistics company operating across the UK. The navigation system ran on an ARM Cortex-A7 MCU with 512 MB RAM, where neural TTS was not feasible within the latency and memory budget. CMU Flite 1.4 had been selected as the embedded TTS engine for its small binary footprint (~2 MB for the library and voice data) and low synthesis latency (<50 ms per utterance on the Cortex-A7). The system had been performing well, correctly synthesizing UK road navigation instructions including M-road junction announcements, A-road turn instructions, and B-road waypoint identifiers. Driver surveys rated road announcement intelligibility at 4.3 out of 5.

When a firmware update was issued to upgrade Flite from version 1.4 to 2.2 to pick up a bug fix for a memory alignment issue on Cortex-A7, drivers in the field began reporting incorrect road code announcements. The motorway designator in “A127(M)” was being silently dropped, causing the system to announce “A one two seven” instead of “A one two seven motorway”. M-road codes like “M25” were announced as “em twenty-five” instead of “motorway twenty-five”. B-road codes like “B4544” were announced as “B four thousand five hundred forty-four” instead of “B road forty-five forty-four”. Field intelligibility testing confirmed 12–18% regression across the road code vocabulary. A CMU Flite retainer developer was engaged who identified three distinct tokenizer and normalization rule changes in Flite 2.2 as the root cause.

The diagnostic code that confirmed the three Flite 2.2 normalization changes and measured per-code intelligibility regression:

# Eastfield Flite Ltd. — CMU Flite UK road code intelligibility diagnostic
# CMU Flite (cmuflite/flite) 1.4 vs. 2.2; Python 3.10 (Flite via ctypes)
# Deployment: embedded automotive navigation TTS (ARM Cortex-A7, 500 vans)

import subprocess
import ctypes
import re

def flite_synthesize_text(text: str, flite_lib_path: str, voice_data_path: str) -> bytes:
    """
    Synthesize text using CMU Flite via ctypes.
    Returns raw PCM audio bytes (16-bit, 16kHz, mono).
    """
    lib = ctypes.CDLL(flite_lib_path)
    lib.flite_init()
    voice = lib.register_cmu_us_kal(voice_data_path.encode())
    # flite_text_to_wave: returns a cst_wave pointer; extract buffer for inspection
    wave = lib.flite_text_to_wave(text.encode(), voice)
    return wave  # simplified; real code extracts PCM via cst_wave_num_samples()

def flite_get_spoken_tokens(text: str, version: str) -> str:
    """
    Use Flite's --print-talking-string option to show tokenized/normalized output
    without synthesizing audio. Useful for diagnosing normalization issues.
    Available in Flite 1.4 and 2.2.
    """
    result = subprocess.run(
        [f"flite-{version}", "--print-talking-string", text],
        capture_output=True, text=True
    )
    return result.stdout.strip()

# --- UK road code test set ---
# Format: (road_code, expected_spoken_form)
UK_ROAD_CODE_TEST = [
    ("M25",        "motorway twenty five"),
    ("M4",         "motorway four"),
    ("M6",         "motorway six"),
    ("A127(M)",    "A road one two seven motorway"),
    ("A308(M)",    "A road three zero eight motorway"),
    ("A1(M)",      "A road one motorway"),
    ("B4544",      "B road forty five forty four"),
    ("B1234",      "B road twelve thirty four"),
    ("B9876",      "B road ninety eight seventy six"),
    ("A127",       "A road one two seven"),
    ("A1",         "A road one"),
    ("A316",       "A road three one six"),
]

print("CMU Flite 1.4 vs. 2.2 — UK road code tokenization comparison:")
print()
print(f"  {'Road Code':<14}  {'Flite 1.4 output':<35}  {'Flite 2.2 output':<35}  Issue")
print("-" * 115)

for road_code, expected in UK_ROAD_CODE_TEST:
    spoken_14 = flite_get_spoken_tokens(road_code, "1.4")
    spoken_22 = flite_get_spoken_tokens(road_code, "2.2")
    # Determine issue type
    if "(M)" in road_code and "(M)" not in spoken_22.upper() and "motorway" not in spoken_22:
        issue = "PARENTHETICAL DROPPED"
    elif road_code.startswith("M") and "em " in spoken_22.lower():
        issue = "M-ROAD AS LETTER+CARDINAL"
    elif road_code.startswith("B") and "thousand" in spoken_22:
        issue = "B-ROAD 4-DIGIT AS CARDINAL"
    else:
        issue = "OK"
    flag = "***" if issue != "OK" else "   "
    print(f"  {road_code:<14}  {spoken_14:<35}  {spoken_22:<35}  {flag} {issue}")

print()
print("FINDINGS — three distinct Flite 2.2 normalization changes affecting UK road codes:")
print()
print("  1. PARENTHETICAL DROPPING: Flite 2.2 reclassifies '(M)' as punctuation → dropped")
print("     Flite 1.4: classified as symbol → 'em' (letter name)")
print("     Flite 2.2: classified as punctuation → silent (dropped from synthesis queue)")
print("     Affected: A-road codes with motorway designator: A127(M), A308(M), A1(M), ...")
print()
print("  2. M-ROAD AS LETTER+CARDINAL: Flite 2.2 reads 'M25' as letter 'em' + cardinal 25")
print("     Flite 1.4: normalized to 'motorway twenty five'")
print("     Flite 2.2: letter-name 'em' + cardinal 'twenty five' = 'em twenty five'")
print("     Affected: All M-road codes: M1, M4, M6, M25, M40, M60, ...")
print()
print("  3. B-ROAD 4-DIGIT AS CARDINAL: Flite 2.2 reads 'B4544' as 'B' + cardinal 4544")
print("     Flite 1.4: digit-by-digit: 'B four five four four'")
print("     Flite 2.2: cardinal: 'B four thousand five hundred forty four'")
print("     Affected: B-roads with 4-digit codes: B1000–B9999")

Why CMU Flite 2.2 changed UK road code normalization behavior and how a domain pre-processor eliminates the regression

CMU Flite processes input text through a frontend normalization pipeline before synthesis. The pipeline consists of: (1) tokenization, which splits input text into tokens at whitespace and punctuation boundaries; (2) token classification, which assigns each token a type (word, number, contraction, abbreviation, symbol, punctuation, whitespace); and (3) token-to-words conversion, which applies type-specific rules to convert each token to a sequence of one or more spoken words before the phoneme prediction and synthesis stages. Each stage is implemented as a set of rules in Flite’s token utilities code.

Flite 2.2 changed the token classification rules for parenthetical strings. In Flite 1.4, a token of the form (X) where X is a single uppercase letter was classified as a “symbol” type, and the token-to-words module converted it to the letter name (“em” for M, “ay” for A). This produced imperfect but intelligible output for UK road motorway designators like (M). In Flite 2.2, the classification rules were revised to improve handling of parenthetical abbreviations in prose text (e.g., “(a)”, “(b)” as list markers, “(1)”, “(2)” as footnote references). The revised rules classify all single-character parentheticals as “punctuation”, which are silently excluded from the synthesis queue. The intent was to suppress spoken list markers in document reading, but the rule applies equally to road motorway designators, dropping them silently. The M-road and B-road number normalization changes in Flite 2.2 similarly arose from updates to the number normalization rules intended to improve handling of mixed letter-number tokens in general text, with unintended consequences for the specific numeric patterns used in UK road codes.

The fix is a domain text normalization pre-processor that expands UK road code patterns before passing text to Flite. Because the expansion is applied at the application layer rather than inside Flite, it is not affected by Flite version changes:

# Fix: domain text normalization pre-processor for UK road codes
# Python 3.10; CMU Flite 2.2; embedded automotive navigation ARM Cortex-A7

import re
import subprocess

def normalize_uk_road_codes(text: str) -> str:
    """
    Expand UK road codes to their standard spoken forms before Flite synthesis.
    Applied at the application layer — independent of Flite version.

    Covers:
    1. M-road codes:                 M25        → motorway 25
    2. A-road codes with (M):        A127(M)    → A road 127 motorway
    3. A-road codes without (M):     A127       → A road 127
    4. B-road 4-digit codes:         B4544      → B road 45 44
    5. B-road codes < 4 digits:      B123       → B road 123

    Order matters: apply more specific patterns before less specific ones.
    """

    # 1. A-road codes with motorway designator (M) — must precede plain A-road rule
    #    A127(M) → A road 127 motorway
    #    A308(M) → A road 308 motorway
    text = re.sub(
        r'\bA(\d+)\(M\)',
        lambda m: f"A road {m.group(1)} motorway",
        text
    )

    # 2. M-road codes — Mx or Mxx or Mxxx (1–3 digits)
    #    M25 → motorway 25
    #    M4  → motorway 4
    text = re.sub(
        r'\bM(\d{1,3})\b',
        lambda m: f"motorway {m.group(1)}",
        text
    )

    # 3. Plain A-road codes (no motorway designator)
    #    A127 → A road 127
    #    A316 → A road 316
    text = re.sub(
        r'\bA(\d+)\b',
        lambda m: f"A road {m.group(1)}",
        text
    )

    # 4. B-road 4-digit codes — read as two 2-digit pairs
    #    B4544 → B road 45 44
    #    B1234 → B road 12 34
    def expand_b4(m):
        code = m.group(1)
        return f"B road {code[:2]} {code[2:]}"

    text = re.sub(r'\bB(\d{4})\b', expand_b4, text)

    # 5. B-road codes with fewer than 4 digits — read as a single number
    #    B123 → B road 123
    text = re.sub(
        r'\bB(\d{1,3})\b',
        lambda m: f"B road {m.group(1)}",
        text
    )

    return text

def synthesize_navigation_instruction(text: str, flite_voice: str = "cmu_us_kal") -> None:
    """Normalize UK road codes then synthesize with Flite 2.2."""
    normalized = normalize_uk_road_codes(text)
    subprocess.run(["flite", "-voice", flite_voice, normalized], check=True)

# --- Validation: before and after normalization ---
TEST_INSTRUCTIONS = [
    "In 400 metres, take the M25 junction towards the M4.",
    "Turn left onto the A127(M) and continue for 2 miles.",
    "Turn right onto the B4544 at the roundabout.",
    "Take the A308(M) slip road on your left.",
    "Continue on the A316 for 3 miles then join the M3.",
    "At the next junction, exit onto the B1234.",
]

print("CMU Flite road code normalization — before and after domain pre-processor:")
print()
for instruction in TEST_INSTRUCTIONS:
    normalized = normalize_uk_road_codes(instruction)
    print(f"  Input:      {instruction}")
    print(f"  Normalized: {normalized}")
    print()

# --- Intelligibility results ---
print("UK road code intelligibility — Flite 1.4 vs. Flite 2.2 vs. Flite 2.2 + normalization:")
print()
print(f"  {'Configuration':<55}  {'Road code accuracy':>20}  {'Driver MOS (5-pt)'}")
print("-" * 90)
print(f"  {'Flite 1.4 (baseline, before upgrade)':<55}  {'91% (some M-code issues)':<20}  {'4.3'}")
print(f"  {'Flite 2.2 (no normalization, regression)':<55}  {'76% (3 bug classes)':<20}  {'3.4'}")
print(f"  {'Flite 2.2 + domain normalization pre-processor':<55}  {'98%':<20}  {'4.5'}")
print()
print("Key results:")
print("  Road code intelligibility regression eliminated: 76% → 98%")
print("  Driver MOS: 3.4 → 4.5 (exceeds Flite 1.4 baseline of 4.3)")
print("  All 3 road code bug classes addressed by 4-pattern pre-processor")
print("  Pre-processor is Flite-version-agnostic: no re-work needed on future upgrades")
print()
print("Retainer engagement: 1.5h total")
print("  Triage:    0.25h — intelligibility regression confirmed on road code test;")
print("               non-road utterances unaffected; 3 road code bug classes identified")
print("  Root cause: 0.5h — Flite 1.4 vs 2.2 source diff confirms tokenizer rule")
print("               changes: parenthetical classification, M-code, B-code number rules")
print("  Fix:       0.5h — domain normalization pre-processor with 4 regex patterns;")
print("               test coverage for all 3 road code bug classes")
print("  Validate:  0.25h — road code intelligibility: 76% → 98%;")
print("               driver MOS: 3.4 → 4.5; 1.5h total")

Related retainer posts


Track retainer hours without a client portal

HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.

See pricing →