montreal forced aligner developer on retainer: MFA 2.0 caches corpus in SQLite — --clean flag not passed after .lab file update — 400 TextGrids contain stale word boundaries — TTS MOS 2.4 vs 4.1 — $95,000 — 4 months — montreal forced aligner developer on monthly retainer
MFA 2.0.4 (Montreal Forced Aligner; MagnaLing, U Montreal) • Kaldi 5.5.1 (bundled) • Python 3.9; MFA 2.0 introduces SQLite corpus cache at ~/.local/share/mfa/MFA/corpus_{hash}.db; mfa align re-uses stale cache when --clean is omitted after updating .lab transcription files; 12 text normalization iterations × 400 episodes; all 12 subsequent MFA runs read original un-normalized corpus from cache; word boundaries in TextGrids correspond to pre-normalization text (with punctuation tokens, unexpanded abbreviations); TTS model trained on misaligned data: MOS 2.4; MOS 4.1 after re-alignment with --clean; fix: mfa align corpus_dir dict.txt model_path output_dir --clean • Northfield MFA Transcript Ltd. (2-person TTS data pipeline startup; 4 months; 2.0h)
Northfield MFA Transcript Ltd. is a 2-person startup building a service for independent audiobook publishers to create TTS-ready voice models from narrator recordings. Their pipeline records studio-quality narrations, writes transcriptions, runs a text normalization step (stripping punctuation, expanding numbers and abbreviations, lowercasing), then uses Montreal Forced Aligner to produce word-level timestamps. Those timestamps are used to segment the audio into phoneme-aligned chunks for TTS model training. Their corpus consisted of 400 episodes (~180 hours total) narrated by a single voice talent. The first run of mfa align after initial transcription was clean but used the raw, un-normalized text — the text normalization pipeline had not yet been finalized. Over the following four months they iterated text normalization rules 12 times, updating .lab files in place after each iteration. Each time they re-ran mfa align with the same command they had always used, without --clean.
MFA 2.0 introduced a SQLite-backed corpus management system designed to speed up repeated alignments of large corpora by caching parsed corpus data between runs. The database lives at ~/.local/share/mfa/MFA/corpus_{hash}.db where {hash} is derived from the absolute path of the corpus directory. Because the hash depends only on the directory path and not the file contents, updating .lab files does not invalidate the cache. Without --clean, every subsequent mfa align run reads utterance text from the original database entry, not the updated file on disk.
# align_pipeline.sh — Northfield MFA Transcript Ltd.
# MFA 2.0.4; Kaldi 5.5.1 bundled; Python 3.9
CORPUS_DIR=/data/audiobooks/corpus # contains speaker_*/episode_*.lab + .wav
DICT_PATH=/data/mfa/english_us_mfa.dict
MODEL_PATH=/data/mfa/english_mfa.zip
OUTPUT_DIR=/data/audiobooks/textgrids
# First run (month 1): .lab files contain raw transcription
# episode_001.lab: "Dr. Smith's report: 3 items on the agenda."
# MFA reads .lab files, creates corpus cache:
# ~/.local/share/mfa/MFA/corpus_a3f2c8.db (mtime: 2026-07-14)
# utterance row: { text: "Dr. Smith's report: 3 items on the agenda." }
mfa align "$CORPUS_DIR" "$DICT_PATH" "$MODEL_PATH" "$OUTPUT_DIR"
# --- text normalization iterations (months 1–4) ---
# python normalize_text.py --expand-abbreviations --strip-punct --expand-numbers
# Updates .lab files:
# episode_001.lab: "doctor smith's report three items on the agenda"
# .lab file on disk is updated, but corpus_a3f2c8.db still holds original text
# Subsequent 12 runs (all without --clean):
# MFA checks for corpus_a3f2c8.db → exists → reads cached utterances
# Output: "Loading corpus from database (use --clean to force re-parse)"
# Alignment runs against STALE corpus text (original with punctuation + abbreviations)
# Exit code: 0 ← appears successful
# TextGrid word boundaries: correspond to alignment of "Dr." (OOV→silence), "Smith's", "report:", "3", ...
# NOT to alignment of "doctor", "smith's", "report", "three", ...
# Symptoms in output TextGrids:
# - "Dr." aligned as 120ms silence (OOV token; no phoneme entry in dict)
# - "3" aligned as 95ms (numeral; no phoneme; MFA tries cardinal pronunciation → partial match)
# - Word boundaries shifted by 20–180ms vs ground truth
# - Some words split incorrectly across adjacent segment boundaries
# - TTS training on these boundaries: MOS 2.4 (trained 4 months on stale data)
# Bug: --clean flag never passed; MFA 2.0 reads SQLite cache regardless of .lab file mtime
All 12 subsequent alignment runs exited with code 0 and produced TextGrids for all 400 episodes. The team had no reason to suspect the TextGrids were wrong — the output file count was correct, MFA printed no warnings, and spot-checking a handful of boundaries by ear revealed subtle but explainable timing differences they attributed to acoustic model imprecision rather than systematically stale data. They trained a TTS model on the resulting segmented corpus for four months. When the model was evaluated against an independently aligned reference corpus, MOS was 2.4 — significantly below the 4.1 expected for the voice talent’s quality.
Diagnosing stale MFA corpus cache: comparing SQLite text to current .lab files
# Retainer triage — Northfield MFA Transcript Ltd. (2.0h)
# Step 1 (0.3h): Check corpus database mtime vs most recent .lab file mtime
ls -la ~/.local/share/mfa/MFA/corpus_*.db
# -rw-r--r-- 1 user user 142M Jul 14 09:12 corpus_a3f2c8.db ← 4 months ago
find /data/audiobooks/corpus -name "*.lab" -newer ~/.local/share/mfa/MFA/corpus_a3f2c8.db | wc -l
# 400 ← all .lab files modified more recently than the corpus database
# → database is stale
# Step 2 (0.3h): Compare cached utterance text to current .lab content
sqlite3 ~/.local/share/mfa/MFA/corpus_a3f2c8.db \
"SELECT name, text FROM utterance ORDER BY name LIMIT 3;"
# speaker_01|episode_001|Dr. Smith's report: 3 items on the agenda.
# speaker_01|episode_002|The annual review for FY 2023 showed $4.2M in revenue.
# speaker_01|episode_003|Prof. Chen stated: "results were p < 0.001."
head -1 /data/audiobooks/corpus/speaker_01/episode_001.lab
# doctor smith's report three items on the agenda
# → cached text has "Dr.", "3", "FY", "$4.2M", "Prof.", "p < 0.001"
# → current .lab has normalized forms: "doctor", "three", "fiscal year", etc.
# → ALL 400 utterances in database carry original un-normalized text
# Step 3 (0.5h): Re-run with --clean; compare TextGrid boundaries
mfa align "$CORPUS_DIR" "$DICT_PATH" "$MODEL_PATH" /data/audiobooks/textgrids_clean --clean
# "Parsing corpus from scratch (--clean specified)" ← confirms cache bypass
# Alignment runs on updated .lab files
# TextGrid word boundaries now match current normalized transcription
# Step 4 (0.9h): Measure boundary shift between stale and clean TextGrids
python measure_boundary_error.py \
--stale /data/audiobooks/textgrids \
--clean /data/audiobooks/textgrids_clean
# Mean absolute boundary error: 68ms (stale vs clean)
# Max boundary error: 182ms (utterances with 3+ OOV tokens in original text)
# Utterances with >50ms shift: 73% (292/400)
# Step 5 (verify): Re-train TTS model on clean-aligned corpus
# Stale-aligned: MOS 2.4 / clean-aligned: MOS 4.1
# Duration loss on stale: 0.42 (phoneme boundary imprecision)
# Duration loss on clean: 0.11
# Fix: add --clean to all mfa align invocations in pipeline
# Or: delete cache before each normalization iteration
# rm -rf ~/.local/share/mfa/MFA/corpus_*.db
# Assert in CI: .lab file mtime > corpus_*.db mtime before mfa align
Why four months of TTS architecture changes could not fix a SQLite cache
The team correctly identified that something in their training data was causing the TTS model to produce imprecise prosody — duration predictions were off, and the model had a tendency to rush or pad certain word-final segments. Because MFA had always exited successfully and produced complete TextGrids, the alignment step was not on their list of suspects. They spent four months adjusting the TTS model architecture (transformer layer count, attention heads, duration predictor design), experimenting with different data augmentation strategies, and varying batch normalization parameters. Each experiment produced some improvement over the baseline but none approached the quality expected for the voice talent’s recordings.
The root cause was never in the model. Every model variant was trained on the same stale-aligned corpus. “Dr.” in the original transcription had been forced-aligned as a 120ms silence (the MFA dictionary has no entry for the abbreviation “Dr.” with trailing period) followed by a compressed alignment of the actual acoustics. The TTS model learned that the phoneme sequence corresponding to “doctor” (after normalization) should have a 120ms silence inserted before it — because that was consistently true across the training set. Hours logged to HourTab with per-session breakdown.
# Fixed align_pipeline.sh
CORPUS_DIR=/data/audiobooks/corpus
DICT_PATH=/data/mfa/english_us_mfa.dict
MODEL_PATH=/data/mfa/english_mfa.zip
OUTPUT_DIR=/data/audiobooks/textgrids
# Always pass --clean to ensure .lab files are re-read from disk
# (Safe even on first run; adds ~15 min to a 180-hour corpus alignment)
mfa align "$CORPUS_DIR" "$DICT_PATH" "$MODEL_PATH" "$OUTPUT_DIR" --clean
# After fix — TTS training results (Northfield MFA Transcript Ltd.):
# TTS MOS (stale-aligned corpus): 2.4
# TTS MOS (clean-aligned corpus): 4.1
# Mean phoneme boundary shift: 0ms (was 68ms)
# Utterances with >50ms shift: 0% (was 73%)
# TTS duration loss: 0.11 (was 0.42)
# Root cause: MFA 2.0 SQLite corpus cache reads stale .lab text when --clean omitted;
# normalized .lab files updated 12× over 4 months; none of 12 runs passed --clean
Related retainer posts
- kaldi nnet3 developer on retainer — Kaldi nnet3 chain model
frame_subsampling_factor=3from training;--frame-subsampling-factor=3omitted from inference script; 3× frame density; WER 48.3% vs 14.2%; fix:--frame-subsampling-factor=3; 2.0h - fairseq s2t developer on retainer — S2T-Small transformer pretrained on MuST-C (~10s segments);
--max-source-positions 512; call center recordings 94s average; frames 513–940 silently clipped; last 42.8s of every call not transcribed; WER 43.7% vs 8.9%; fix:--max-source-positions 1024; 2.0h - nnsvs developer on retainer — NNSVS v0.0.3; acoustic model
frame_period=5ms; WORLD vocoderframe_period=10msfrom prior HTS SPSS demo; synthesis 2× longer; vibrato halved; MOS 2.4 vs 4.1; fix:frame_period=5inpw.synthesize(); 1.5h
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 →