Skip to content

Fix Audio normalization of silent waveforms 🤖🤖 - #15414

Open
kokotatan wants to merge 1 commit into
ipython:mainfrom
kokotatan:fix-audio-silence-normalization
Open

kokotatan wants to merge 1 commit into
ipython:mainfrom
kokotatan:fix-audio-silence-normalization

Conversation

@kokotatan

Copy link
Copy Markdown

Audio([0.0] * 16, rate=8000) computes a zero normalization factor for a silent waveform. The pure Python path raises ZeroDivisionError; the NumPy path emits invalid divide and cast warnings.

This uses a factor of 1 for an all-zero waveform so the samples stay silent. Nonzero waveforms are still scaled by their maximum absolute value, and normalize=False keeps its existing range check.

The new tests read back the WAV header and PCM frames for mono/stereo NumPy input and for mono input without NumPy, with normalization on and off.

🤖🤖 AI assistance was used to investigate and prepare this change.

Use a unit normalization factor for all-zero waveforms, so silent input
stays silent instead of raising ZeroDivisionError (pure Python) or
emitting invalid-value warnings (NumPy). Add tests that read back the
WAV frames for NumPy and pure Python input, with and without
normalization.

AI assistance was used to investigate and prepare this change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant