Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using dispatched makes it impossible to use torchaudio.save with ogg files #3643

Closed
adefossez opened this issue Oct 9, 2023 · 5 comments
Closed

Comments

@adefossez
Copy link
Contributor

🐛 Describe the bug

Since torchaudio 2.1.0, the following snippet fails:

import torch
import torchaudio as ta

x = torch.randn(1, 16000)
ta.save('/tmp/test.ogg', x, 16000)

When exporting first TORCHAUDIO_USE_BACKEND_DISPATCHER=0 it works again as expected. Note that passing encoding='PCM_F' doesn't seem to solve the issue (the error message complains about the format being passed to ffmpeg being s16 not fltp, but this doesn't seem fixable no matter the arguments passed to torchaudio.

Versions

Collecting environment information...
PyTorch version: 2.1.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.5.2 (x86_64)
GCC version: Could not collect
Clang version: 14.0.3 (clang-1403.0.22.14.1)
CMake version: version 3.21.3
Libc version: N/A

Python version: 3.8.12 (default, Oct 13 2021, 06:42:42) [Clang 13.0.0 (clang-1300.0.29.3)] (64-bit runtime)
Python platform: macOS-13.5.2-x86_64-i386-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz

Versions of relevant libraries:
[pip3] flake8==6.1.0
[pip3] mypy==1.5.1
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.23.5
[pip3] torch==2.1.0
[pip3] torch-stoi==0.1.2
[pip3] torchaudio==2.1.0
[pip3] torchmetrics==1.0.2
[conda] blas 1.0 mkl
[conda] mkl 2019.4 233
[conda] mkl-service 2.3.0 py38h9ed2024_0
[conda] mkl_fft 1.3.0 py38ha059aab_0
[conda] mkl_random 1.1.1 py38h959d312_0
[conda] numpy 1.20.2 pypi_0 pypi
[conda] torch 1.10.2 pypi_0 pypi
[conda] torchaudio 0.10.2 pypi_0 pypi
[conda] torchvision 0.11.3 pypi_0 pypi

@adefossez
Copy link
Contributor Author

adefossez commented Oct 9, 2023

Also noticed that the compression argument for torchaudio.save is gone :(

With both those recent changes it is becoming quite hard to use the simple torchaudio.save API which used to be great for most of our use cases!

@mthrok
Copy link
Collaborator

mthrok commented Oct 9, 2023

Hi @adefossez

In 2.1, we stopped shipping sox and we ask users to install sox by themselves.
This is regardless of use of dispatcher or not.
Can you confirm that you have sox installed and the sox supports OSS?
Running list_write_formats should tell if you have the libsox that supports OGG.

python -c 'import torchaudio;print(torchaudio.utils.sox_utils.list_write_formats())'
['aifc', ..., 'ogg']

@mthrok
Copy link
Collaborator

mthrok commented Oct 9, 2023

Also noticed that the compression argument for torchaudio.save is gone :(

With both those recent changes it is becoming quite hard to use the simple torchaudio.save API which used to be great for most of our use cases!

Sorry this was missed on our end. let me try to revive it. The notion of compression level is different from library to library, so I am not entirely sure what the signature should be on save function.

@mthrok
Copy link
Collaborator

mthrok commented Oct 19, 2023

#3662 put back the compression argument. So with compression and backend="sox", the original behavior should be recovered. I will add this to 2.1.1 minor release.

@mthrok
Copy link
Collaborator

mthrok commented Nov 17, 2023

2.1.1 was released with the compression argument. Using sox backend should recover the original behavior.

@mthrok mthrok closed this as completed Nov 17, 2023
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

No branches or pull requests

2 participants