VibeVoice icon indicating copy to clipboard operation
VibeVoice copied to clipboard

fix(audio): soft-knee limiter in AudioNormalizer.avoid_clipping

Open aarochu opened this issue 4 months ago • 1 comments

Summary

AudioNormalizer.avoid_clipping used a hard max_val > 1.0 branch: peaks at or below 1.0 pass through untouched, while peaks just above 1.0 get scaled down by roughly max_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

  • [x] Verified peak never exceeds 1.0 across a sweep of max_val values (0.5 to 3.0)
  • [x] Verified scalar is continuous and monotonic across the knee (0.95 → 1.05), unlike the previous hard-branch behavior
  • [x] Confirmed audio below the knee (typical normalized speech) is untouched (scalar == 1.0)

Fixes #407

aarochu avatar Jul 30 '26 09:07 aarochu

@microsoft-github-policy-service agree

aarochu avatar Jul 30 '26 09:07 aarochu