-
Notifications
You must be signed in to change notification settings - Fork 741
Description
🐛 Bug
UPDATE: SoxEffectsChain has been marked as deprecated. Please use the new apply_effects_tensor or apply_effects_file functions.
SoxEffectsChain returns wrong result for 32 bit floating point WAV format.
TOP Input wav
MIDDLE Output from SoxEffectsChain with lowpass -1 300
BOTTOM Output from sox command with lowpass -1 300
To Reproduce
Steps to reproduce the behavior:
Run the following script from the top to generate input and result. Run sox command to get refertence.
Other bit depths (int32, int16, uint8) seem to work.
import torch
import torchaudio
from test.common_utils import save_wav, get_whitenoise
for dtype in ['float32', 'int32', 'int16', 'uint8']:
sample_rate = 8000
input_path = f'data/input_{dtype}.wav'
output_path = f'data/result_{dtype}.wav'
data = get_whitenoise(sample_rate=sample_rate, dtype=dtype)
save_wav(input_path, data, sample_rate)
sec = torchaudio.sox_effects.SoxEffectsChain()
sec.append_effect_to_chain("lowpass", ["-1", "300"])
sec.set_input_file(input_path)
t, sr = sec.sox_build_flow_effects()
save_wav(output_path, t, sr)Expected behavior
SoxEffectsChain should return correct result on float32 wav.
Environment
$ python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.7.0a0+49e12d8
Is debug build: No
CUDA used to build PyTorch: 10.1
OS: Ubuntu 18.04.3 LTS
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
CMake version: version 3.10.2
Python version: 3.8
Is CUDA available: Yes
CUDA runtime version: 10.1.243
GPU models and configuration:
GPU 0: Quadro GP100
GPU 1: Quadro GP100
Nvidia driver version: 418.116.00
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
Versions of relevant libraries:
[pip] numpy==1.18.1
[pip] torch==1.7.0a0+49e12d8
[pip] torchaudio==0.7.0a0+b3c6b0f
[pip] torchtext==0.6.0a0+e823aca
[pip] torchvision==0.7.0a0+f9ef235
[conda] magma-cuda101 2.5.2 1 pytorch
[conda] mkl 2020.1 217
[conda] mkl-include 2020.1 217 conda-forge
[conda] numpy 1.18.1 py38h8854b6b_1 conda-forge
[conda] torch 1.7.0a0+49e12d8 dev_0 <develop>
[conda] torchaudio 0.7.0a0+b3c6b0f dev_0 <develop>
[conda] torchtext 0.6.0a0+e823aca dev_0 <develop>
[conda] torchvision 0.7.0a0+f9ef235 dev_0 <develop>
Additional context
I am adding a new sox effect implementation #760 that does not have this problem and, once this lands I will mark SoxEffectsChain as deprecated and users are encouraged to migrate to the new implementation.
