Datasets:
license: apache-2.0
language:
- th
task_categories:
- automatic-speech-recognition
tags:
- forced-alignment
- thai
- text-to-speech
- evaluation
- prosody
size_categories:
- 1K<n<10K
pretty_name: Thai Aligner Bench — forced-alignment benchmark with duration ground truth
configs:
- config_name: default
data_files: items.jsonl
Thai Aligner Bench
🚧 Development in progress. This benchmark is under active development. The aligner set, the metrics and the asset bundle may all change without notice, and every number below should be read as provisional. If you need reproducibility, pin a commit SHA rather than tracking
main.
Which forced aligner should score Thai TTS pauses? A self-contained benchmark:
one Python file (aligner_bench.py) plus 1,572 clips of Thai TTS audio carrying
frozen timing ground truth. No Thai NLP, no TTS model, no other code needed —
just numpy soundfile torch torchaudio transformers.
The ground truth is unusual and is what makes this dataset useful: the audio was
rendered by a TTS model whose duration predictor emitted an explicit frame count
per token (pred_dur, 25 ms/frame, sum(pred_dur) * 600 == len(audio) exactly at
24 kHz). The token boundaries in the audio therefore are the pred_dur
boundaries — no human annotation, no second aligner, no circularity. Any forced
aligner can be measured against them directly.
Two questions are answered per aligner:
- Delay / timing accuracy — onset error percentiles, signed bias, jitter (spread with bias removed), duration error, span coverage.
- Downstream pause accuracy — silences are detected, attributed to a text
juncture through the aligner's char timings, and classified
ok/bad_juncture/intra_word/unaligned. Scoring the same clips throughpred_durgives the reference, so each aligner also reports agreement with ground truth.
Quick start
git clone https://huggingface.co/datasets/kunato/thai-aligner-bench-dev
cd thai-aligner-bench-dev
pip install numpy soundfile torch torchaudio transformers
python aligner_bench.py run --bundle . --aligner ctc --out out/ctc
python aligner_bench.py run --bundle . --aligner mms --out out/mms
python aligner_bench.py report out/ctc out/mms
run = align (GPU, writes spans.jsonl) + score (CPU, writes metrics.json).
Run them separately to re-score without re-aligning. Pre-computed spans.jsonl for
all four arms is in results/, so you can reproduce every number below on CPU
alone:
cp -r results/ctc out/ctc && python aligner_bench.py score --bundle . --out out/ctc
Useful flags: --limit N / --speakers spk00,spk03 (fast subsets),
--word-seg {tltk,newmm} (which frozen word segmentation attributes the pause),
--quantize-ms 38.5 (round predicted onsets onto a coarser grid — tests whether an
aligner's deficit is really just its frame rate), --device, --batch-size.
Aligners included
| arm | model | note |
|---|---|---|
ctc |
airesearch/wav2vec2-large-xlsr-53-th |
Thai char CTC, 50 fps — the default |
mms |
torchaudio.pipelines.MMS_FA |
generic multilingual phone aligner; IPA mapped onto its roman labels |
qwen |
Qwen/Qwen3-ASR-1.7B-hf + a Thai char timestamp head |
--ctc-head-repo; head architecture is inferred from the weights, so a new head loads with no code change |
The qwen arm needs transformers>=5.13. Side-load rather than upgrade if pinned:
pip install --no-deps --target=/tmp/tf514 transformers==5.14.1
PYTHONPATH=/tmp/tf514 python aligner_bench.py run --bundle . --aligner qwen \
--ctc-head-repo <head-repo> --out out/qwen
Add your own aligner
Write one function returning [(char_idx, t0_ms, t1_ms)] over item["text"],
time-monotonic, and register it:
def mine_bundle(device, **_):
return SimpleNamespace(..., tag="mine:v1", batched=False)
def mine_char_spans(wav, sr, item, b):
... # item["_align"].phonemes / .units are there if you align on phones
return spans
ALIGNERS["mine"] = (mine_bundle, mine_char_spans, None)
Everything downstream — silence detection, attribution, classification, aggregation, agreement — is shared, so arms stay comparable.
If you batch, pass an explicit length mask. This is not a style note.
wav2vec2-large-xlsr-53-thshipsreturn_attention_mask: falsewhile being afeat_extract_norm='layer'model trained with masking. Running it unmasked scales each clip's whole char timeline bylen/batch_max— drift that reached −1670 ms by the end of a 7.5 s clip, silently destroying every downstream number until it was found. The Qwen arm has the identical trap (features padded to 30 s). Both shipped paths build the mask from raw input lengths.
Results
1,572 clips (12 synthetic speakers × 131 long-sentence texts), --word-seg tltk,
default thresholds, one RTX 3090. Produced by this exact file; raw artifacts in
results/.
Timing vs pred_dur ground truth (ms; lower is better):
| model | fps | onset p50 | p90 | >100 ms | bias | jitter | dur p50 | coverage | s/clip |
|---|---|---|---|---|---|---|---|---|---|
ctc xlsr-53-th |
50 | 17.26 | 40.74 | 0.2% | −15.91 | 11.96 | 15.21 | 0.401 | 0.209 |
mms MMS_FA |
50 | 28.43 | 46.91 | 0.4% | −28.39 | 9.38 | 14.52 | 0.709 | 0.154 |
qwen + ctc-head-v2 |
26 | 36.54 | 82.20 | 4.4% | −33.62 | 24.09 | 28.44 | 0.669 | 0.331 |
qwen + ctc-head-cv-only |
26 | 29.97 | 72.52 | 2.9% | −26.59 | 22.34 | 27.72 | 0.731 | 0.332 |
Downstream pause metrics + agreement with ground truth:
| model | /clip | precision | intra_word | PPER | bad/min | r(count) | verdict | per-spk r | bad-junc | Jaccard |
|---|---|---|---|---|---|---|---|---|---|---|
pred_dur (truth) |
2.291 | 0.8681 | 0.0878 | 0.2226 | 1.911 | — | — | — | — | — |
ctc |
2.268 | 0.8634 | 0.1018 | 0.2290 | 1.959 | 0.9603 | 95.2% | 0.9614 | 248/319 | 0.6685 |
mms |
2.414 | 0.7718 | 0.2265 | 0.3321 | 3.484 | 0.9411 | 85.4% | 0.7525 | 249/319 | 0.6587 |
qwen + v2 |
2.240 | 0.8606 | 0.1031 | 0.2284 | 1.975 | 0.9597 | 94.3% | 0.9353 | 241/319 | 0.6359 |
qwen + cv-only |
2.233 | 0.8390 | 0.1387 | 0.2665 | 2.273 | 0.9611 | 90.5% | 0.9388 | 240/319 | 0.6107 |
ctc wins every downstream column. Three results worth more than the ranking:
- Timing accuracy does not imply attribution accuracy. MMS has the tightest
jitter of any arm (9.38 ms vs
ctc's 11.96) and the best duration error — once its larger constant bias is removed it is the sharpest aligner here. It still loses 0.09 precision, drops per-speaker r to 0.75, and more than doublesintra_word. It aligns romanized Thai through a lossy map (length and tone dropped; ɛ/e, ɔ/o, ɯ/ɤ/u collapse), so it puts precisely-timed boundaries in the wrong places. Character identity beats milliseconds. - Below ~40 ms median onset error, timing stops mattering for this metric.
qwen+v2 has 2×ctc's onset error and 2× its duration error, yet lands within 0.003 precision and 0.026 per-speaker r. Pauses are ≥80 ms, so a 36 ms error rarely flips which juncture a silence belongs to. Do not tune an aligner for this metric past ~40 ms — spend the effort on character/tokenizer fidelity instead. - The qwen heads' deficit is not their frame rate. Rounding
ctc's own onsets onto qwen's 38.5 ms grid (--quantize-ms 38.5) moves it 17.26 → 19.0 ms p50 and 11.96 → 14.5 ms jitter. The grid costs ~1.7 ms against a ~19 ms gap. A bigger ConvTranspose upsample would not help either: it makes a finer output grid over the encoder's native 13 fps / 77 ms information floor. Beatingctcneeds a finer-resolution encoder, not a bigger head.
Between the two qwen heads, v2 (GigaSpeech2-th) beats cv-only (Common Voice)
downstream — 0.861 vs 0.839 precision, 94.3% vs 90.5% verdict agreement — despite
cv-only's better raw onsets (29.97 vs 36.54). Same architecture, so this is a
training-data effect, and it is the third instance here of better timing not
surviving into better attribution.
Reading the numbers
- Read
precisionnext to/clip. The masks are precision-side only — they mark where a break is allowed, never where one is required — so an aligner (or a TTS system) that finds no pauses scores 1.000. Precision alone is not a ranking. per-spk ris the real instrument test. It is whether the aligner ranks the 12 voices the way ground truth does. An aligner can hold aggregate precision and still be useless for comparing systems; this column catches it.biasis correctable,jitteris not. Aligners report the left edge of a frame, so each carries a systematic half-frame early bias that a constant shift removes. Jitter is what decides usability.- Never compare CTC span widths across aligners. They allocate blank frames
differently —
coverageruns from 0.40 to 0.73 here. Measuring duration as a span's own width reverses the ranking.dur p50therefore usesonset[i+1] − onset[i], the conventionpred_duritself uses.
Dataset structure
items.jsonl one JSON per clip (1,572)
audio/<id>.flac 24 kHz mono, lossless
aligner_bench.py the benchmark (single file)
results/<arm>/ metrics.json, align_meta.json, spans.jsonl
| field | meaning |
|---|---|
id / speaker / text_id |
clip key; text_id groups the same text across the 12 voices |
text |
the normalized text actually spoken — every char index, gold mark and word span below is in this coordinate space |
gold |
pause mask; | marks a juncture where a break is allowed (hand-calibrated, precision-side only) |
pred_dur |
duration-predictor frame counts, 25 ms/frame, one pad token at each end — the timing ground truth |
align.phonemes |
IPA, byte-identical to what the model was fed |
align.units |
syllable / English-word / punct atoms: [ph_a, ph_b) in phonemes, [ch_a, ch_b) in text |
align.words |
word spans with surfaces |
align.ph2unit |
phoneme char → unit index (−1 for spaces) |
align.tok2ph |
model token index → phoneme char index |
word_spans |
two independent word segmentations (tltk, newmm) so tokenizer choice can be varied with no Thai tokenizer installed |
Limitations
- The audio is vocoder output, not natural speech. It is out of domain for aligners trained on read speech. That is deliberate — it is the audio the metric has to work on — but results here are not a claim about natural speech, and an aligner that does well on real speech may not do well here.
pred_duris ground truth for this TTS model's rendering, not a human phonetic transcription. It is exact about where the model placed each token; it does not adjudicate whether that placement was phonetically ideal.- Precision-side only. No
‖"a break is required here" marks exist, so missing a break is unpenalized underpause_precision. - Synthetic speakers. 12 designed voices from one checkpoint, so speaker diversity is narrower than a natural-speech corpus.
- Earlier internal runs of this comparison reported larger gaps between aligners. Two things changed: a coordinate bug specific to the MMS arm (its char indices came from the G2P's units, which index normalized text, while attribution used raw text — they differ on 900/1,572 clips), and everything now aligning on the text actually spoken. Both raise agreement with ground truth across the board. The ranking is unchanged; the margins were overstated.