Why is forced_align disappearing from Torchaudio 2.8?

The function that aligns speech labels to audio frames has been marked deprecated in the latest release. It will be removed entirely in version 2.9 as part of a broader shift toward maintenance mode.

The deprecation banner sits at the top of the reference page

A warning block marks the function as deprecated in capital letters. The notice states this function will be removed from the 2.9 release. This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. The documentation points to GitHub issue 3902 for more information. No timeline for the maintenance phase is given in the notice.

What the function signature requires

The function accepts five parameters. The first parameter log_probs is a tensor of shape batch, time, classes. This tensor holds the log probability of the CTC emission output. The second parameter targets is a tensor of shape batch, label length. This tensor holds the target sequence. The third parameter input_lengths is an optional one-dimensional tensor of shape batch. The fourth parameter target_lengths is also an optional one-dimensional tensor of shape batch. The fifth parameter blank_id is an integer defaulting to zero. This integer represents the index of the blank symbol in the CTC emission. The return type is a tuple of two tensors. The first tensor contains a label for each time step in the alignment path computed using forced alignment. The second tensor contains log probability scores of the labels for each time step. Both tensors correspond to the input time dimension.

A mathematical constraint governs valid inputs

The sequence length of log_probs must satisfy a specific inequality. The length must be greater than or equal to the label length plus the number of consecutively repeated tokens. The documentation gives an example: in the string "aabbc" the number of repeats is two. This constraint exists because CTC requires blank tokens between repeated labels. The current version only supports batch size equal to one. This limitation is noted explicitly in the documentation.

Tutorials that reference this function

Four tutorials are listed. The CTC forced alignment API tutorial appears twice. Forced alignment for multilingual data also appears twice. Forced Alignment with Wav2Vec2 appears twice. The duplication suggests multiple entry points or versions. Whether these tutorials have been updated for a replacement API is not stated in the deprecation notice.

The maintenance phase context

The deprecation notice describes a large refactoring effort. The project is transitioning into a maintenance phase. The GitHub issue 3902 is the only reference provided for details. The function documentation does not explain what maintenance phase means for other APIs. It does not list other functions being deprecated. It does not provide a migration guide.

What this means for existing code

Code that imports and calls forced_align will continue to function in version 2.8. The function will be removed in version 2.9. The documentation does not name a direct replacement. The documentation does not provide a migration example. Developers must consult the GitHub issue or wait for updated tutorials. The tutorials listed may or may not reflect the new approach.

The sources this article was written from

  • "Torchaudio 2.8.0 documentation
    https://docs.pytorch.org/audio/2.8/generated/torchaudio.functional.forced_align.html"

Read next