Merged
Conversation
PR #986 ("support timestamps for numbers") introduced three changes that together broke CTC forced alignment: 1. Unknown chars (numbers, punctuation) were replaced with '*' wildcards mapped to token -1. get_wildcard_emission() scored these using torch.max() over all non-blank emissions, so wildcards greedily matched any speech-like signal in the segment window. 2. get_trellis() was rewritten with a different shape (num_frame, num_tokens) and incompatible initialization, discarding the original SoS-offset design from the PyTorch forced alignment tutorial. 3. backtrack() was replaced with backtrack_beam(), which always starts backtracking from the last frame of the segment window. The original backtrack() used torch.argmax() on the last token column to determine the starting frame. With padded segment boundaries (silence before/after speech), the new implementation spread all tokens across the full window, placing the first word at the start of the silence instead of the speech. This commit restores the original PyTorch tutorial implementation: - Unknown chars are skipped; words with only unknown chars become unalignable and get no timestamps (handled by interpolate_nans) - get_trellis: restored (num_frame+1, num_tokens+1) shape with SoS offset - backtrack: restored torch.argmax-based starting frame - Removed backtrack_beam, get_wildcard_emission, BeamState, Path Verified: v3.3.0 (pre-#986) produced correct timestamps with padded segment boundaries; this fix reproduces that behavior. Fixes #1220 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ktrack The original code accepted blank_id as a parameter but used hardcoded 0 in two places, breaking alignment for HuggingFace models where the blank token is [pad] (not index 0). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )