The Viterbi algorithm has been previously used to perform forced alignment of audio to text to mine training data from online resources. However, many existing implementations have quadratic time and space complexity, scaling poorly to long input sequences. We propose two optimizations to address this issue. First, we apply the Hirschberg algorithm to perform the alignment in place using linear memory. Second, we model the alignment between speech and text as a constrained random walk, allowing us to prune the search space with arbitrary confidence while accounting for transcription errors. The Hirschberg optimization reduces memory usage from 140 GB to 5 MB for three-hour inputs while producing identical alignments in one-third the time of torchaudio when both run on a CPU. We achieve an additional 2x speedup with pruning on inputs longer than 20 minutes while preserving alignment accuracy in more than 98% of tested cases.
Figures & tables
Figure 1: Logarithmic heatmaps showing a random sample of alignments from the CJCLDS-GC dataset (left), and the alignment prior that we use to predict FA pruning bounds (right). This prior is created from the assumption that phoneme durations are randomly distributed and stationary.
Buckeye
CJCLDS-GC
EuroSpeech
Overall
Method
Exact
<250 ms
Exact
<250 ms
Exact
<250 ms
Failure
Time
Max Time
Max Mem.
Unpruned HV
100%
100%
100%
100%
100%
100%
0%
59:36:39
2:50:44
22.4 MB
Uncut
HV + VAD Hint
100% †‡
100% †‡
98.2% †‡
98.3% ‡
100% †‡
100% ‡
0%
32:38:36
1:22:26
41.5 MB
Kaldi
67.5% ‡
75.0% ‡
93.8% ‡
99.5% ∗‡
69.6% ‡
94.2% ‡
0.03%
287:58:12
> 3 days
21.5 GB
ctc-seg
0%
52.5%
0%
70.0%
0%
18.8%
6.0%
10:15:45
1:04:20
> 80 GB
VAD
HV
0%
77.5% ‡
1.97% †‡
93.4% ‡
0%
82.0% ‡
0%
11:40:39
27:23
1.9 GB
Table 1: Pruning performance for different methods with their default parameters. We include metrics when VAD is used to cut periods of silence before processing. Runtime and memory usage is aggregated across all datasets. The longest input across the test sets is 16 hours. Systems marked with ∗ , † , and ‡ significantly outperformed our system, Kaldi, and ctc-seg, respectively, with p-values under 0.05 .
Figure 2: Runtime and memory usage of various implementations of the Viterbi algorithm. Note that torchaudio and NeMo have the same memory usage and overlap in the graph. The GPU used has only 80 GB of VRAM, so that line for NeMo ends early once it no longer has enough VRAM to run.
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 3: Visualization of the Hirschberg algorithm applied to forced alignment. The algorithm works from both sides to compute an optimal pivot point in the middle, then recurses to the lower left and upper right areas in the figure.
Figure 4: In this specific alignment, which is for the Bulgarian interpretation of Russell Nelson’s discourse ”Think Celestial!” from 2023, the interpreter did not read a list of cities at the end of the discourse, instead using the original English audio. The city names are in the transcription, but there is no Bulgarian audio corresponding to them. The list of city names occupies 3.7% of the transcription, and adjusting the pruning bound for 96.3% transcription precision produces the outer pruning bounds, which fully contain the alignment.
Figure 5: The alignments in the EuroSpeech dataset after removing audio between labeled sentences. We color the heatmap using the CER of the transcription. Hue depicts CER, while color intensity indicates logarithmic frequency in the dataset. We note that alignments further from their expected position tend to have higher CER.
Figure 6: After removing labeled periods of silence from the Buckeye dataset, all transcription alignments were contained within their predicted pruning space. The lines on the right depict the pruning space for s2002a, one of the shorter recordings with a wider relative pruning space. Note that these depict the segmented interview labels available with dataset, not our reconstruction of the 40 interviews.
Dataset
Languages
Files
Total Duration (h)
Minimum Length
Maximum Length
Buckeye
1
40
38
39:25
1:17:54
CGCLDS-GC
85
63961
12509
00:04
41:28
— Our Test Split
73
5766
1128
01:03
32:16
EuroSpeech
22
27683
77031
00:10
17:42:45
— Test Split
21
140
794
00:22
16:20:36
Appendix
Table 2: The size of each of the datasets used in our study. Note that this details our reconstructions of the unsegmented audio files for each dataset. We use the full Buckeye dataset in our tests, both only evaluate our pruning on the test sets for CGCLDS-GC and EuroSpeech. The CGCLDS-GC dataset contains the data through 2023, when we took a snapshot of the data at the time. There is one fewer language in the EuroSpeech test set, becuase EuroSpeech on HuggingFace is missing a test set for Italian. There are 12 fewer languages in our test set from the CGCLDS-GC dataset, because we limit our experiments to languages supported by MMS.
Word-level forced alignment estimates when each transcript word occurs in an audio recording. It underpins text-based media editing, subtitling, speech-data curation, and phonetic analysis. Existing evaluations understate the difficulty of forced alignment by relying on short, clean speech, perfect transcripts, and metrics that obscure consequential alignment errors. In contrast, real-world media and data-processing pipelines operate on long and diverse recordings. Additionally, forced aligners often operate on error-prone automatic speech recognition (ASR) output. We address these gaps with improved evaluation metrics, a scoring protocol for real ASR transcripts, and AlignBench, a benchmark spanning diverse speaker, acoustic, and text conditions. We further introduce FuseAlign, a transformer-based aligner trained on large-scale pseudo-labeled speech with online label correction. FuseAlign performs joint contextualization of audio and text for the localization of coarse words. The model then refines boundaries at millisecond resolution and detects missing transcript words in the audio without lexicon-based or Viterbi decoding. On AlignBench, FuseAlign substantially outperforms all baselines and remains robust under real ASR transcripts. Ablations show that convolutional upsampling and EMA-snapshot label correction matter more than model properties such as parameter count.
Forced aligners locate each word of a known transcript in the audio, and many speech pipelines depend on them. In our own data, a widely used CTC aligner inserts a pause at nearly every word boundary, and we found almost no aligner evaluated on telephone audio. We compare nine aligner configurations against human word boundaries on read, conversational and telephone English. The Montreal Forced Aligner (MFA) is the most precise, while CTC aligners consistently start words late, because most frames inside a word go to the blank token. We then fine-tune Whisper with LoRA to predict each word's start and end as timestamp tokens, training only on boundaries placed by people: 47 hours in 87 languages. The resulting aligner is more precise than MFA on every English test condition, and than MFA's own Korean and Dutch models. With FA-Bench's protocol and code on TIMIT, its word-boundary error is 11.6 ms, against 18.2 ms for the best published system. Two choices matter most on telephone conversations: placing the timestamp slots after the word they time, and training on noisy transcripts, which also makes the aligner nearly insensitive to errors in the transcript. The released model reaches 16.0 ms on real landline calls, against 36.5 ms for MFA. The models are available at https://huggingface.co/collections/Scicom-intl/force-alignment
Speech-to-text alignment is a critical component of neural text to speech (TTS) models. Autoregressive TTS models typically use an attention mechanism to learn these alignments on-line, while non-autoregressive end to end TTS models rely on durations extracted from external sources. In this paper, we propose a novel duration prediction framework that can give promising phoneme-level duration distribution with given text. In our experiments, the proposed duration model has more precise prediction and adaptation ability to conditions, compared to previous baseline models. Specifically, it makes a considerable improvement on phoneme-level alignment accuracy and makes the performance of zero-shot TTS models more robust to the mismatch between prompt audio and input audio.
Junjie Cao
Tsinghua Shenzhen International Graduate School, Tsinghua University