fix(audio): soft-knee limiter in AudioNormalizer.avoid_clipping - #427
Open
Aaron (aarochu) wants to merge 1 commit into
Open
fix(audio): soft-knee limiter in AudioNormalizer.avoid_clipping#427Aaron (aarochu) wants to merge 1 commit into
Aaron (aarochu) wants to merge 1 commit into
Conversation
Replace the hard max_val > 1.0 threshold with a tanh soft-knee so a peak landing just below vs. just above 1.0 no longer flips between "untouched" and "scaled down by ~max_val". That on/off behavior meant a fraction of a dB of upstream gain could shift the overall level of otherwise-identical audio by a much larger amount, which is reported in microsoft#407 as a source of diarization instability. Fixes microsoft#407
Author
|
@microsoft-github-policy-service agree |
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.
Summary
AudioNormalizer.avoid_clippingused a hardmax_val > 1.0branch: peaks at or below 1.0 pass through untouched, while peaks just above 1.0 get scaled down by roughlymax_val. As reported in #407, this means two perceptually-identical inputs that differ by a fraction of a dB of upstream gain can land on opposite sides of that branch — one untouched, the other uniformly attenuated — producing a level difference much larger than the input difference that caused it. This is fed into diarization/transcription and was observed to affect speaker-count stability.This replaces the on/off threshold with a tanh soft-knee starting at
max_val = 0.95: output peak approaches but never reaches 1.0 (no clipping), and the scaling factor is continuous and smooth through the region where the old code used to flip behavior. Audio below the knee (the common case) is unaffected.Test plan
max_valvalues (0.5 to 3.0)scalaris continuous and monotonic across the knee (0.95 → 1.05), unlike the previous hard-branch behaviorscalar == 1.0)Fixes #407