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

_audio_backends platform independent #554

Closed
cpuhrsch opened this issue Apr 16, 2020 · 3 comments · Fixed by #579
Closed

_audio_backends platform independent #554

cpuhrsch opened this issue Apr 16, 2020 · 3 comments · Fixed by #579

Comments

@cpuhrsch
Copy link
Contributor

cpuhrsch commented Apr 16, 2020

🐛 Bug

The constant _audio_backends is referenced by BACKENDS in the common utilities of the test folder. test_batch_mfcc is skipped if the 'sox' key is not present in that constant, but it always is. That means this test will be executed in environments where the package may not exist.

(base) PS C:\Users\chris\dev\audio> python .\test\test_batch_consistency.py TestTransforms.test_batch_mfcc
E
======================================================================
ERROR: test_batch_mfcc (__main__.TestTransforms)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\tools\Anaconda3\lib\contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File ".\test\test_batch_consistency.py", line 185, in test_batch_mfcc
    waveform, _ = torchaudio.load(test_filepath)
  File "c:\users\chris\dev\audio\torchaudio\__init__.py", line 87, in load
    filetype=filetype,
  File "c:\users\chris\dev\audio\torchaudio\_sox_backend.py", line 38, in load
    import _torch_sox
ModuleNotFoundError: No module named '_torch_sox'

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

To Reproduce

Steps to reproduce the behavior:

  1. Remove sox from your environment
  2. Run python test/test_batch_consistency.py TestTransform.test_batch_mfcc

I can provide more detailed information if required.

Expected behavior

The test should be skipped if sox is not available.

Environment

(base) PS C:\Users\chris\dev\audio> python .\collect_env_1.py
Collecting environment information...
PyTorch version: 1.6.0a0+8a60d8b
Is debug build: No
CUDA used to build PyTorch: None

OS: Microsoft Windows 10 Home
GCC version: Could not collect
CMake version: version 3.14.0

Python version: 3.7
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip] numpy==1.18.1
[pip] numpydoc==0.9.2
[pip] torch==1.6.0a0+8a60d8b
[pip] torchaudio==0.5.0a0+5a75b63
[conda] blas                      1.0                         mkl
[conda] mkl                       2020.0                      166
[conda] mkl-include               2020.0                      166
[conda] mkl-service               2.3.0            py37hb782905_0
[conda] mkl_fft                   1.0.15           py37h14836fe_0
[conda] mkl_random                1.1.0            py37h675688f_0
[conda] numpy                     1.18.1           py37h93ca92e_0
[conda] numpy-base                1.18.1           py37hc3f5095_1
[conda] numpydoc                  0.9.2                      py_0
[conda] torch                     1.6.0a0+8a60d8b           dev_0    <develop>
[conda] torchaudio                0.5.0a0+5a75b63           dev_0    <develop>

Additional context

@vincentqb
Copy link
Contributor

A simple fix would be to make _audio_backends also depend on platform here.

#561 fixed the particular error you saw.

@mthrok
Copy link
Collaborator

mthrok commented Apr 17, 2020

It would be nice if it can detect which backend is available at run time.

Also we need to document which one is the default backend.
soundfile seems to be a reasonable default as it's available on Windows too (also it is easy to install), but looking at setup.py, it expects SoX.

@vincentqb
Copy link
Contributor

It would be nice if it can detect which backend is available at run time.

Yes. In some sense and depending on the definition of run time, this is already the case, see here and here.

There's also a partial discussion of backend dispatch in #425.

Also we need to document which one is the default backend.
soundfile seems to be a reasonable default as it's available on Windows too (also it is easy to install), but looking at setup.py, it expects SoX.

The default backend for torchaudio has been sox. torchaudio only officially support macos and linux. We do not officially support windows, but there the default is soundfile, see #425 for discussion.

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 a pull request may close this issue.

3 participants