Skip to content

fix: save_audio can write distorted audio due to missing clamp - #25

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/utils-c0eaacda
Open

fix: save_audio can write distorted audio due to missing clamp#25
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/utils-c0eaacda

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Jul 27, 2026

Copy link
Copy Markdown

Problem

fix: save_audio can write distorted audio due to missing clamp

Fix

Replace:

def save_audio(audio, path, sr):
    # wav: torch with 1d shape
    audio = audio * MAX_WAV_VALUE
    audio = audio.cpu().numpy().astype("int16")
    write(path, sr, audio)

with:

def save_audio(audio, path, sr):
    # wav: torch with 1d shape
    audio = audio.clamp(min=-1, max=1)
    audio = audio * MAX_WAV_VALUE
    audio = audio.cpu().numpy().astype("int16")
    write(path, sr, audio)

Files changed

  • utils.py

@andrewwhitecdw
andrewwhitecdw marked this pull request as ready for review July 28, 2026 00:34
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