pytorch / audio

Data manipulation and transformation for audio signal processing, powered by PyTorch
https://pytorch.org/audio
BSD 2-Clause "Simplified" License
2.5k stars 644 forks source link

Vol silently clamps outputs to range [-1,1] #3730

Open CookiePPP opened 8 months ago

CookiePPP commented 8 months ago

📚 The doc issue

https://pytorch.org/audio/stable/generated/torchaudio.transforms.Vol.html

The current doc for torchaudio.transforms.Vol just says "Adjust volume of waveform." but it also clamps the output using torch.clamp(waveform, -1, 1) which can be hard to realise and debug (in my case, I have millions of audio files and around 10% of them had enough dynamic range to trigger this clipping, making it harder to reproduce, but still enough files to cause audio quality issues and disrupt training stability).

Suggest a potential alternative/fix

I would suggest adding a warning to the method that prints once if an output waveform has samples that will be clamped and updating the torchaudio doc to make it clear that the function clamps the output.