Fix int16 audio overflow in ASR Gradio demo#383
Open
hobostay wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix int16 audio overflow in ASR Gradio demo#383hobostay wants to merge 1 commit intomicrosoft:mainfrom
hobostay wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Use 32767.0 instead of 32768.0 when converting float32 audio to int16. Values of 1.0 multiplied by 32768.0 overflow int16's max of 32767, causing wrap-around to negative values and audible distortion. Also add np.clip to guard against out-of-range values. This aligns with the fix already applied in gradio_asr_demo_api_video.py. Co-Authored-By: Claude Opus 4.7 <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 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
32768.0instead of32767.0, causing integer overflow when audio amplitude >= 1.0np.clipto guard against out-of-range valuesgradio_asr_demo_api_video.py(line 586) which already uses32767.0with the comment "Use 32767.0 instead of 32768.0 to avoid potential overflow"Details
Affected file:
demo/vibevoice_asr_gradio_demo.py(lines 298 and 491)The int16 range is [-32768, 32767]. Multiplying a float value of
1.0by32768.0gives32768.0, which overflows to-32768when cast tonp.int16.Test plan
gradio_asr_demo_api_video.py🤖 Generated with Claude Code