fix(asr): align acoustic and semantic feature lengths to prevent tensor mismatch#309
Open
JasonOA888 wants to merge 1 commit intomicrosoft:mainfrom
Open
fix(asr): align acoustic and semantic feature lengths to prevent tensor mismatch#309JasonOA888 wants to merge 1 commit intomicrosoft:mainfrom
JasonOA888 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…or mismatch The acoustic and semantic tokenizers use different encoder architectures with different downsampling ratios. When processing audio of certain lengths, they can produce slightly different frame counts (e.g. 228 vs 223 frames), causing a tensor size mismatch when the features are combined via element-wise addition. This fix truncates both feature sequences to the minimum length before combination, applied consistently to both the short-audio (direct) and long-audio (streaming) code paths. Fixes microsoft#220
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #220
Root Cause
The acoustic and semantic tokenizers use different encoder architectures with different downsampling ratios. For certain audio lengths, they produce slightly different frame counts (e.g. 228 vs 223 frames).
When the element-wise addition
acoustic_features + semantic_featuresis attempted with mismatched temporal dimensions, PyTorch raises:Fix
Truncate both feature sequences to the minimum common length before the addition, applied consistently to:
Both paths already had the alignment logic for streaming but it was missing from the direct processing path.