概述
它支持单词定时字幕、语音研究和语音数据集准备,在 2024 年的比较中,基于 HMM 的蒙特利尔强制对齐器仍然比新的神经系统更精确地放置单词边界。
主要要点
- 强制对齐将已知的转录内容放在音频上,并返回每个单词或音素的开始和结束时间;它不检查转录是否正确。
- 蒙特利尔强制对准器等经典对准器使用发音词典、HMM 声学模型和分辨率为 10 毫秒的维特比算法。
- 神经对齐器使用 CTC 模型,例如 wav2vec 2.0,每 20 毫秒输出一帧,不需要发音词典。
- 在 2024 年的 Interspeech 比较中,MFA 将 72.8% 的 TIMIT 单词边界放置在 25 毫秒内,而 WhisperX 为 52.7%,MMS 为 43.5%。
- 重叠的语音、转录中缺失的不流畅以及未标准化的数字或符号是不良对齐的最常见原因。
深入探讨
Forced alignment is the job of placing a known transcript onto a recording in time. The inputs are an audio file and the text of what was said. The output is a start and end time for each word, and often for each phone, the smallest unit of sound that tells words apart, such as the k sound at the start of cat. It is called forced because the system is not allowed to decide what was said: it must explain the audio using exactly the given words in the given order. That separates it from speech recognition, which has to guess the words. With the word sequence fixed, the search is much smaller, so an aligner can be precise about timing. It also means an aligner does not check the transcript. If the text is wrong, the wrong words still get placed somewhere.
The classic method uses a hidden Markov model (HMM), a statistical model that treats speech as a walk through a chain of hidden states. The Montreal Forced Aligner (MFA) documentation describes forced alignment as turning an orthographic transcript into a time-aligned version by using a pronunciation dictionary to look up the phones for each word. Step one is that lookup: each word becomes a phone sequence, and words missing from the dictionary can be handled by a grapheme-to-phoneme model that guesses pronunciations from spelling. Step two converts the audio into acoustic features. According to the 2024 Interspeech comparison by Rousso and colleagues, MFA uses 39 mel-frequency cepstral coefficient (MFCC) features, compact summaries of the spectrum's shape, computed every 10 ms over a 25 ms window.
Step three strings the phones of every word into one long left-to-right chain of HMM states, usually with optional silence between words. A Gaussian mixture model (GMM) scores how well each 10 ms frame of features matches each state. Step four runs the Viterbi algorithm, a dynamic programming search that finds the single most probable way to assign every frame to a state while moving through the chain in order. Wherever the best path crosses from one phone to the next is a phone boundary, and word boundaries follow from the phones. The resolution is therefore one frame, 10 ms.
MFA trains its acoustic models in passes, which the user guide lists as monophone models that ignore context, triphone models that consider the phone on each side, an LDA plus MLLT feature transform that makes phones easier to tell apart, and a final pass with per-speaker adaptation. Because training needs only transcripts, not hand-marked boundaries, MFA can be trained on the very data it is asked to align. The 2017 Interspeech paper by Michael McAuliffe, Michaela Socolof, Sarah Mihuc, Michael Wagner and Morgan Sonderegger introduced MFA as an update of the earlier Prosodylab-Aligner, moving from the HTK toolkit to Kaldi, adding triphones and speaker adaptation, and enabling parallel processing. It reported better boundaries than Prosodylab-Aligner and FAVE on English conversational and laboratory speech, and found that training on the target data generally helped. The documentation is now at version 3.4, which adds model formats that work with Hugging Face.
Neural aligners arrived with models trained using connectionist temporal classification (CTC), a training objective that lets a network learn to output characters from audio without being told where each character occurs. Wav2vec 2.0 models produce one output frame every 20 ms, per the Rousso paper. Meta's Massively Multilingual Speech (MMS) paper, posted in May 2023, built a single recognizer for 1,107 languages, and torchaudio packages an MMS model as MMS_FA for alignment. In March 2023 Max Bain, Jaesung Huh, Tengda Han and Andrew Zisserman posted WhisperX, accepted at Interspeech 2023, which adds voice activity detection and forced phoneme alignment to Whisper to get word timestamps, and reports a twelve-fold transcription speedup from batching pre-segmented audio.
The two families can be compared directly. Rousso, Cohen, Keshet and Chodroff scored MFA, WhisperX and MMS on TIMIT, read speech, and Buckeye, conversational speech, counting only words each neural system recognized correctly. Within 25 ms of the hand-labeled boundary, MFA placed 72.8% of TIMIT word boundaries, against 52.7% for WhisperX and 43.5% for MMS. On Buckeye the figures were 69.9%, 43.1% and 52.7%. At a looser 100 ms tolerance the TIMIT gap shrank to 97.4%, 94.2% and 94.7%. The authors suggest CTC training without aligned data and the coarser 20 ms frame rate as likely causes, though they did not test these directly. The practical trade-off is that neural pipelines need no pronunciation dictionary and can produce a transcript when none exists, while HMM aligners give tighter boundaries but need a lexicon and acoustic model for each language.
Failure modes are predictable. Transcripts that leave out filled pauses, false starts or repeated words force the aligner to stretch neighboring words over the extra sound. The WhisperX README says overlapping speech is not handled particularly well, and that tokens containing characters missing from the alignment dictionary, such as 2014. or a price in pounds, get no timing at all, so numbers and symbols should be written out as words first. The torchaudio tutorial warns that CTC models are peaky, meaning a character's probability spike may cover only one or two frames rather than its full duration, and that blank frames make word edges ambiguous. In the 2024 comparison, MFA and WhisperX were both less accurate on conversational Buckeye than on read TIMIT.
Requirements differ by tool. MFA is a command-line package built on Kaldi that needs a pronunciation dictionary and acoustic model for the language, either downloaded or trained on your own corpus. WhisperX targets GPUs; its README claims about 70 times real-time speed with the large-v2 model and under 8 GB of GPU memory with a beam size of 5. The torchaudio alignment APIs were deprecated in version 2.8 and removed in 2.9, so code based on the tutorial needs a pinned version or a replacement. In every case the honest check is to compare a sample of output boundaries with hand-marked ones before trusting the timings.
04工作示例
使用蒙特利尔强制对准器对准简短的采访片段
收集一个或多个发言者的几个 WAV 文件,并为每个发言者编写一份精确的纯文本记录,包括您可以听到的重复单词和充满停顿的内容。
将数字和符号写成单词,例如二十四个而不是 2014,这样每个标记都可以在发音词典中找到。
安装 MFA 并从 MFA 模型列表中下载预训练的声学模型和该语言的匹配发音词典。
运行 MFA 的验证步骤以列出字典中缺少的单词,然后为它们添加发音或使用字素到音素模型生成它们。
在语料库文件夹上运行对齐器,为每个文件生成时间对齐的单词和音素层。
打开音频旁边的输出样本,手动标记十个单词边界,并测量每个预测边界与您的标记的距离。
它显示了什么
每次录音都有一个单词和电话计时文件,以及一个小的准确性检查。如果大部分手动检查的边界都在 25 毫秒左右,则对齐情况在 2024 年 MFA 基准报告的范围内;大错误通常可以追溯到转录本不匹配。
现实世界的实施
使用 WhisperX 将单词级时间戳添加到 Whisper 转录中,WhisperX 在转录后运行单独的 wav2vec2 对齐模型,因为根据其自述文件,Whisper 自己的时间戳是话语级的,并且可能会偏差几秒钟。
使用蒙特利尔强制对齐器生成用于语音研究的单词和音素边界层,该对齐器在发音词典中查找每个单词并提供多种语言的可下载声学模型。
使用 torchaudio 的 MMS_FA 管道对齐多种语言的语音,这是来自 Meta 大规模多语言语音项目的 wav2vec 2.0 模型,可发出用于 CTC 强制对齐的字符概率。
通过添加 torchaudio CTC 教程中描述的星号标记来处理缺少第一个单词的转录,该标记会吸收未转录的音频,以便剩余的单词仍然对齐。
根据 TIMIT(阅读语音语料库)和 Buckeye(对话语料库)中的手动标记边界对对齐器进行基准测试,这两个数据集用于 2024 年 MFA、WhisperX 和 MMS 的语音间比较。
强制对齐的未来
The main open problem is closing the precision gap between neural and HMM aligners. The 2024 Interspeech comparison by Rousso and colleagues found MFA best at every tolerance on both TIMIT and Buckeye, and named CTC's lack of alignment supervision and its 20 ms frame rate as probable causes, which points research toward neural models trained or fine-tuned with explicit boundary information and finer time resolution. A second direction is coverage. Meta's 2023 MMS work extended recognition to 1,107 languages, and alignment quality for low-resource languages, where no pronunciation dictionary or hand-labeled test set exists, remains hard to measure. Conversational audio is a third gap: overlapping talkers, disfluencies and transcripts that do not match the audio word for word still break most pipelines, which is why tools add wildcard tokens and voice activity detection. Tooling is also shifting, since torchaudio moved into maintenance mode and removed its alignment APIs in version 2.9, so users depend on where those functions are maintained next. Whether neural aligners will match HMM boundary accuracy on conversational speech is an open question rather than a settled trend.
付诸实践
为什么这很重要
- 交通与覆盖范围. 它通过转录、旁白和语音界面提高了可访问性。
- 成本与预算. 媒体团队可以用更少的预算更快地交付精美的音频。
- 速度与规模. 面向客户的系统可以处理更大规模的语音交互。
留意
- 如果未征得同意,语音滥用和冒充风险就会增加。
- 由于口音、方言或嘈杂的环境,准确性可能会下降。
- 如果没有明确的标签,合成音频可能会被误认为是真实的语音。
后续步骤
- 获得语音捕获、克隆和重用的明确同意。
- 测试不同扬声器和背景条件下的质量。
- 定义人员必须审查或批准输出的时间。
- 标记合成音频并保留来源记录以供问责。
资料来源与延伸阅读
- ISCA (Interspeech 2017)蒙特利尔强制对齐器:使用 Kaldi 进行可训练的文本语音对齐
- Montreal Forced Aligner用户指南,蒙特利尔强制对准器文档
- arXiv (Interspeech 2024)传统还是创新:现代 ASR 强制对齐方法的比较
- PyTorch (torchaudio)CTC强制对齐API教程
- arXiv (Interspeech 2023)WhisperX:长格式音频的时间精确语音转录
- GitHubm-bain/whisperX
- arXiv (Meta AI)将语音技术扩展到 1,000 多种语言
不断探索
常见问题
什么是强制对齐?
强制对齐需要已知的录音和文字记录,并计算出每个单词(通常是每个语音)的开始和结束时间。它支持单词定时字幕、语音研究和语音数据集准备,在 2024 年的比较中,基于 HMM 的蒙特利尔强制对齐器仍然比新的神经系统更精确地放置单词边界。
给定音频及其转录内容,强制对齐会产生什么输出?
对齐器估计提供的转录文本中的单位在音频中出现的位置。
为什么对齐被称为“强制”?
转录文本是固定输入;对齐器搜索符合它的时间。
经典对齐器中的发音词典提供了什么?
MFA使用发音词典在对齐前将单词映射到音位。
经典基于Kaldi的蒙特利尔强制对齐器使用哪种搜索方法来找到语音中的可能序列?
MFA论文描述了其基于Kaldi的声学模型对齐流程和Viterbi式解码。
在WhisperX中,什么有助于在单词级强制对齐之前处理长文本音频?
WhisperX使用语音活动检测对音频进行分段,然后再进行转录和音位对齐。