I ported Meta's MMS forced aligner to TypeScript: word-level timestamps in Node.js, 42% faster than Python
说明与用途
mms-forced-align npm 包在 Node.js 中实现 Meta MMS 强制对齐,速度比 Python 快 42%,内存使用减少 32%,并与参考时间完全一致。
问题
Need word-level timestamps for captions in a Node.js service without running a heavy Python sidecar.
结果
The TypeScript port matches Python outputs exactly, runs 42 % faster, uses 32 % less memory, and supports 17 Indic languages via a romanizer.
工作流
- 1. Accept mono 16 kHz Float32Array audio
- 2. Normalize audio (zero mean, unit variance)
- 3. Split into 20 ms frames (320 samples)
- 4. Run ONNX model to get logits per frame
- 5. Apply log_softmax to obtain log-probabilities
- 6. Convert transcript words to extended CTC sequence with blanks
- 7. Run custom TypeScript CTC Viterbi decoder over the grid
- 8. Map Viterbi path to letter and word spans in seconds
证据
mms-forced-align runs Meta's MMS forced-aligner model in Node.js through ONNX Runtime, with a CTC Viterbi decoder I wrote from scratch in TypeScript (~170 lines).
~42% faster than Python's torchaudio on the same fp32 model, with ~32% less peak memory.
37 of 37 reference words match torchaudio to 0.0 ms. On a real 116-word clip, 110 words are identical.
- 记录日期: 2026-10-10T00:41:02.687Z