Forced alignment

Forced alignment computes the start and end time of every word of an audio file given its transcript. For instance, for the audio

李雷和韩梅梅是好朋友

we can obtain that 李 is from 0.16 s to 0.38 s, 雷 is from 0.38 s to 0.62 s, and so on.

sherpa-onnx supports forced alignment with GMM acoustic models trained with the Montreal Forced Aligner (MFA). The models and their pronunciation lexicons are packaged in the fa-models release; see scripts/mfa/README.md for what is inside a package and where the models come from.

Hint

It runs locally on your device, without internet connection. No audio is uploaded anywhere.

The alignment runs with the same sherpa-onnx APIs as the other functions, in every supported language (C, C++, Python, Java, Kotlin, JavaScript, …). Given a wave and its transcript, the result contains a phone tier and a word tier with the time interval of each phone/word; it can also be written as a Praat TextGrid file.

In the following, we describe how to use pre-built apps for forced alignment on Android and in a web browser.