Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
ecfed4d9
Unverified
Commit
ecfed4d9
authored
Mar 02, 2021
by
Caroline Chen
Committed by
GitHub
Mar 02, 2021
Browse files
Make sox selective (#1338)
parent
98d0d593
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
80 additions
and
58 deletions
+80
-58
test/torchaudio_unittest/backend/sox_io/info_test.py
test/torchaudio_unittest/backend/sox_io/info_test.py
+6
-6
test/torchaudio_unittest/backend/sox_io/load_test.py
test/torchaudio_unittest/backend/sox_io/load_test.py
+6
-6
test/torchaudio_unittest/backend/sox_io/roundtrip_test.py
test/torchaudio_unittest/backend/sox_io/roundtrip_test.py
+2
-2
test/torchaudio_unittest/backend/sox_io/save_test.py
test/torchaudio_unittest/backend/sox_io/save_test.py
+3
-3
test/torchaudio_unittest/backend/sox_io/smoke_test.py
test/torchaudio_unittest/backend/sox_io/smoke_test.py
+5
-5
test/torchaudio_unittest/backend/sox_io/torchscript_test.py
test/torchaudio_unittest/backend/sox_io/torchscript_test.py
+2
-2
test/torchaudio_unittest/backend/utils_test.py
test/torchaudio_unittest/backend/utils_test.py
+1
-1
test/torchaudio_unittest/common_utils/__init__.py
test/torchaudio_unittest/common_utils/__init__.py
+3
-2
test/torchaudio_unittest/common_utils/case_utils.py
test/torchaudio_unittest/common_utils/case_utils.py
+5
-1
test/torchaudio_unittest/datasets/tedlium_test.py
test/torchaudio_unittest/datasets/tedlium_test.py
+2
-0
test/torchaudio_unittest/functional/functional_cpu_test.py
test/torchaudio_unittest/functional/functional_cpu_test.py
+2
-2
test/torchaudio_unittest/sox_effect/dataset_test.py
test/torchaudio_unittest/sox_effect/dataset_test.py
+3
-3
test/torchaudio_unittest/sox_effect/smoke_test.py
test/torchaudio_unittest/sox_effect/smoke_test.py
+2
-2
test/torchaudio_unittest/sox_effect/sox_effect_test.py
test/torchaudio_unittest/sox_effect/sox_effect_test.py
+8
-8
test/torchaudio_unittest/sox_effect/torchscript_test.py
test/torchaudio_unittest/sox_effect/torchscript_test.py
+2
-2
test/torchaudio_unittest/utils/sox_utils_test.py
test/torchaudio_unittest/utils/sox_utils_test.py
+2
-2
third_party/CMakeLists.txt
third_party/CMakeLists.txt
+1
-5
torchaudio/_internal/module_utils.py
torchaudio/_internal/module_utils.py
+19
-0
torchaudio/backend/sox_io_backend.py
torchaudio/backend/sox_io_backend.py
+3
-3
torchaudio/backend/utils.py
torchaudio/backend/utils.py
+3
-3
No files found.
test/torchaudio_unittest/backend/sox_io/info_test.py
View file @
ecfed4d9
...
...
@@ -16,8 +16,8 @@ from torchaudio_unittest.common_utils import (
HttpServerMixin
,
PytorchTestCase
,
skipIfNoExec
,
skipIfNoExtension
,
skipIfNoModule
,
skipIfNoSox
,
get_asset_path
,
get_wav_data
,
save_wav
,
...
...
@@ -33,7 +33,7 @@ if _mod_utils.is_module_available("requests"):
@
skipIfNoExec
(
'sox'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestInfo
(
TempDirMixin
,
PytorchTestCase
):
@
parameterized
.
expand
(
list
(
itertools
.
product
(
[
'float32'
,
'int32'
,
'int16'
,
'uint8'
],
...
...
@@ -253,7 +253,7 @@ class TestInfo(TempDirMixin, PytorchTestCase):
assert
info
.
encoding
==
"PCM_S"
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestInfoOpus
(
PytorchTestCase
):
@
parameterized
.
expand
(
list
(
itertools
.
product
(
[
'96k'
],
...
...
@@ -271,7 +271,7 @@ class TestInfoOpus(PytorchTestCase):
assert
info
.
encoding
==
"OPUS"
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestLoadWithoutExtension
(
PytorchTestCase
):
def
test_mp3
(
self
):
"""Providing `format` allows to read mp3 without extension
...
...
@@ -306,7 +306,7 @@ class FileObjTestBase(TempDirMixin):
return
path
@
skipIfNo
Extension
@
skipIfNo
Sox
@
skipIfNoExec
(
'sox'
)
class
TestFileObject
(
FileObjTestBase
,
PytorchTestCase
):
def
_query_fileobj
(
self
,
ext
,
dtype
,
sample_rate
,
num_channels
,
num_frames
):
...
...
@@ -438,7 +438,7 @@ class TestFileObject(FileObjTestBase, PytorchTestCase):
assert
sinfo
.
encoding
==
get_encoding
(
ext
,
dtype
)
@
skipIfNo
Extension
@
skipIfNo
Sox
@
skipIfNoExec
(
'sox'
)
@
skipIfNoModule
(
"requests"
)
class
TestFileObjectHttp
(
HttpServerMixin
,
FileObjTestBase
,
PytorchTestCase
):
...
...
test/torchaudio_unittest/backend/sox_io/load_test.py
View file @
ecfed4d9
...
...
@@ -11,8 +11,8 @@ from torchaudio_unittest.common_utils import (
HttpServerMixin
,
PytorchTestCase
,
skipIfNoExec
,
skipIfNoExtension
,
skipIfNoModule
,
skipIfNoSox
,
get_asset_path
,
get_wav_data
,
load_wav
,
...
...
@@ -200,7 +200,7 @@ class LoadTestBase(TempDirMixin, PytorchTestCase):
@
skipIfNoExec
(
'sox'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestLoad
(
LoadTestBase
):
"""Test the correctness of `sox_io_backend.load` for various formats"""
@
parameterized
.
expand
(
list
(
itertools
.
product
(
...
...
@@ -332,7 +332,7 @@ class TestLoad(LoadTestBase):
@
skipIfNoExec
(
'sox'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestLoadParams
(
TempDirMixin
,
PytorchTestCase
):
"""Test the correctness of frame parameters of `sox_io_backend.load`"""
original
=
None
...
...
@@ -363,7 +363,7 @@ class TestLoadParams(TempDirMixin, PytorchTestCase):
self
.
assertEqual
(
found
,
expected
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestLoadWithoutExtension
(
PytorchTestCase
):
def
test_mp3
(
self
):
"""Providing format allows to read mp3 without extension
...
...
@@ -393,7 +393,7 @@ class CloggedFileObj:
return
ret
@
skipIfNo
Extension
@
skipIfNo
Sox
@
skipIfNoExec
(
'sox'
)
class
TestFileObject
(
TempDirMixin
,
PytorchTestCase
):
"""
...
...
@@ -553,7 +553,7 @@ class TestFileObject(TempDirMixin, PytorchTestCase):
self
.
assertEqual
(
expected
,
found
)
@
skipIfNo
Extension
@
skipIfNo
Sox
@
skipIfNoExec
(
'sox'
)
@
skipIfNoModule
(
"requests"
)
class
TestFileObjectHttp
(
HttpServerMixin
,
PytorchTestCase
):
...
...
test/torchaudio_unittest/backend/sox_io/roundtrip_test.py
View file @
ecfed4d9
...
...
@@ -7,7 +7,7 @@ from torchaudio_unittest.common_utils import (
TempDirMixin
,
PytorchTestCase
,
skipIfNoExec
,
skipIfNo
Extension
,
skipIfNo
Sox
,
get_wav_data
,
)
from
.common
import
(
...
...
@@ -17,7 +17,7 @@ from .common import (
@
skipIfNoExec
(
'sox'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestRoundTripIO
(
TempDirMixin
,
PytorchTestCase
):
"""save/load round trip should not degrade data for lossless formats"""
@
parameterized
.
expand
(
list
(
itertools
.
product
(
...
...
test/torchaudio_unittest/backend/sox_io/save_test.py
View file @
ecfed4d9
...
...
@@ -10,7 +10,7 @@ from torchaudio_unittest.common_utils import (
TorchaudioTestCase
,
PytorchTestCase
,
skipIfNoExec
,
skipIfNo
Extension
,
skipIfNo
Sox
,
get_wav_data
,
load_wav
,
save_wav
,
...
...
@@ -157,7 +157,7 @@ def nested_params(*params):
@
skipIfNoExec
(
'sox'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
SaveTest
(
SaveTestBase
):
@
nested_params
(
[
"path"
,
"fileobj"
,
"bytesio"
],
...
...
@@ -354,7 +354,7 @@ class SaveTest(SaveTestBase):
@
skipIfNoExec
(
'sox'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestSaveParams
(
TempDirMixin
,
PytorchTestCase
):
"""Test the correctness of optional parameters of `sox_io_backend.save`"""
@
parameterized
.
expand
([(
True
,
),
(
False
,
)],
name_func
=
name_func
)
...
...
test/torchaudio_unittest/backend/sox_io/smoke_test.py
View file @
ecfed4d9
...
...
@@ -4,26 +4,26 @@ import unittest
from
torchaudio.utils
import
sox_utils
from
torchaudio.backend
import
sox_io_backend
from
torchaudio._internal.module_utils
import
is_
module
_available
from
torchaudio._internal.module_utils
import
is_
sox
_available
from
parameterized
import
parameterized
from
torchaudio_unittest.common_utils
import
(
TempDirMixin
,
TorchaudioTestCase
,
skipIfNo
Extension
,
skipIfNo
Sox
,
get_wav_data
,
)
from
.common
import
name_func
skipIfNoMP3
=
unittest
.
skipIf
(
not
is_
module
_available
(
'torchaudio._torchaudio'
)
or
not
is_
sox
_available
()
or
'mp3'
not
in
sox_utils
.
list_read_formats
()
or
'mp3'
not
in
sox_utils
.
list_write_formats
(),
'"sox_io" backend does not support MP3'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
SmokeTest
(
TempDirMixin
,
TorchaudioTestCase
):
"""Run smoke test on various audio format
...
...
@@ -88,7 +88,7 @@ class SmokeTest(TempDirMixin, TorchaudioTestCase):
self
.
run_smoke_test
(
'flac'
,
sample_rate
,
num_channels
,
compression
=
compression_level
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
SmokeTestFileObj
(
TorchaudioTestCase
):
"""Run smoke test on various audio format
...
...
test/torchaudio_unittest/backend/sox_io/torchscript_test.py
View file @
ecfed4d9
...
...
@@ -9,7 +9,7 @@ from torchaudio_unittest.common_utils import (
TempDirMixin
,
TorchaudioTestCase
,
skipIfNoExec
,
skipIfNo
Extension
,
skipIfNo
Sox
,
get_wav_data
,
save_wav
,
load_wav
,
...
...
@@ -45,7 +45,7 @@ def py_save_func(
@
skipIfNoExec
(
'sox'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
SoxIO
(
TempDirMixin
,
TorchaudioTestCase
):
"""TorchScript-ability Test suite for `sox_io_backend`"""
backend
=
'sox_io'
...
...
test/torchaudio_unittest/backend/utils_test.py
View file @
ecfed4d9
...
...
@@ -25,7 +25,7 @@ class TestBackendSwitch_NoBackend(BackendSwitchMixin, common_utils.TorchaudioTes
backend_module
=
torchaudio
.
backend
.
no_backend
@
common_utils
.
skipIfNo
Extension
@
common_utils
.
skipIfNo
Sox
class
TestBackendSwitch_SoXIO
(
BackendSwitchMixin
,
common_utils
.
TorchaudioTestCase
):
backend
=
'sox_io'
backend_module
=
torchaudio
.
backend
.
sox_io_backend
...
...
test/torchaudio_unittest/common_utils/__init__.py
View file @
ecfed4d9
...
...
@@ -16,6 +16,7 @@ from .case_utils import (
skipIfNoExec
,
skipIfNoModule
,
skipIfNoExtension
,
skipIfNoSox
,
skipIfNoSoxBackend
,
)
from
.wav_utils
import
(
...
...
@@ -30,5 +31,5 @@ from .parameterized_utils import (
__all__
=
[
'get_asset_path'
,
'get_whitenoise'
,
'get_sinusoid'
,
'set_audio_backend'
,
'TempDirMixin'
,
'HttpServerMixin'
,
'TestBaseMixin'
,
'PytorchTestCase'
,
'TorchaudioTestCase'
,
'skipIfNoCuda'
,
'skipIfNoExec'
,
'skipIfNoModule'
,
'skipIfNoExtension'
,
'skipIfNoSox
Backend
'
,
'get_wav_data'
,
'normalize_wav'
,
'load_wav'
,
'save_wav'
,
'load_params'
]
'skipIfNoCuda'
,
'skipIfNoExec'
,
'skipIfNoModule'
,
'skipIfNoExtension'
,
'skipIfNoSox'
,
'skipIfNoSoxBackend'
,
'get_wav_data'
,
'normalize_wav'
,
'load_wav'
,
'save_wav'
,
'load_params'
]
test/torchaudio_unittest/common_utils/case_utils.py
View file @
ecfed4d9
...
...
@@ -8,7 +8,10 @@ import unittest
import
torch
from
torch.testing._internal.common_utils
import
TestCase
as
PytorchTestCase
import
torchaudio
from
torchaudio._internal.module_utils
import
is_module_available
from
torchaudio._internal.module_utils
import
(
is_module_available
,
is_sox_available
)
from
.backend_utils
import
set_audio_backend
...
...
@@ -95,6 +98,7 @@ def skipIfNoModule(module, display_name=None):
skipIfNoSoxBackend
=
unittest
.
skipIf
(
'sox'
not
in
torchaudio
.
list_audio_backends
(),
'Sox backend not available'
)
skipIfNoCuda
=
unittest
.
skipIf
(
not
torch
.
cuda
.
is_available
(),
reason
=
'CUDA not available'
)
skipIfNoSox
=
unittest
.
skipIf
(
not
is_sox_available
(),
reason
=
'Sox not available'
)
def
skipIfNoExtension
(
test_item
):
...
...
test/torchaudio_unittest/datasets/tedlium_test.py
View file @
ecfed4d9
...
...
@@ -7,6 +7,7 @@ from torchaudio_unittest.common_utils import (
TorchaudioTestCase
,
get_whitenoise
,
save_wav
,
skipIfNoSox
)
from
torchaudio.datasets
import
tedlium
...
...
@@ -144,5 +145,6 @@ class TestTedliumSoundfile(Tedlium, TorchaudioTestCase):
if
platform
.
system
()
!=
"Windows"
:
@
skipIfNoSox
class
TestTedliumSoxIO
(
Tedlium
,
TorchaudioTestCase
):
backend
=
"sox_io"
test/torchaudio_unittest/functional/functional_cpu_test.py
View file @
ecfed4d9
...
...
@@ -10,7 +10,7 @@ import itertools
from
torchaudio_unittest
import
common_utils
from
torchaudio_unittest.common_utils
import
(
TorchaudioTestCase
,
skipIfNo
Extension
,
skipIfNo
Sox
,
)
from
torchaudio_unittest.backend.sox_io.common
import
name_func
...
...
@@ -220,7 +220,7 @@ class TestMaskAlongAxisIID(common_utils.TorchaudioTestCase):
assert
(
num_masked_columns
<
mask_param
).
sum
()
==
num_masked_columns
.
numel
()
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestApplyCodec
(
TorchaudioTestCase
):
backend
=
"sox_io"
...
...
test/torchaudio_unittest/sox_effect/dataset_test.py
View file @
ecfed4d9
...
...
@@ -11,7 +11,7 @@ import torchaudio
from
torchaudio_unittest.common_utils
import
(
TempDirMixin
,
PytorchTestCase
,
skipIfNo
Extension
,
skipIfNo
Sox
,
get_whitenoise
,
save_wav
,
)
...
...
@@ -71,7 +71,7 @@ def init_random_seed(worker_id):
dataset
.
rng
=
np
.
random
.
RandomState
(
worker_id
)
@
skipIfNo
Extension
@
skipIfNo
Sox
@
skipIf
(
platform
.
system
()
==
'Darwin'
and
sys
.
version_info
.
major
==
3
and
...
...
@@ -134,7 +134,7 @@ def speed(path):
return
torchaudio
.
sox_effects
.
apply_effects_tensor
(
wav
,
sample_rate
,
effects
)[
0
]
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestProcessPoolExecutor
(
TempDirMixin
,
PytorchTestCase
):
backend
=
"sox_io"
...
...
test/torchaudio_unittest/sox_effect/smoke_test.py
View file @
ecfed4d9
...
...
@@ -4,7 +4,7 @@ from parameterized import parameterized
from
torchaudio_unittest.common_utils
import
(
TempDirMixin
,
TorchaudioTestCase
,
skipIfNo
Extension
,
skipIfNo
Sox
,
get_wav_data
,
get_sinusoid
,
save_wav
,
...
...
@@ -14,7 +14,7 @@ from .common import (
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
SmokeTest
(
TempDirMixin
,
TorchaudioTestCase
):
"""Run smoke test on various effects
...
...
test/torchaudio_unittest/sox_effect/sox_effect_test.py
View file @
ecfed4d9
...
...
@@ -11,7 +11,7 @@ from torchaudio_unittest.common_utils import (
TempDirMixin
,
HttpServerMixin
,
PytorchTestCase
,
skipIfNo
Extension
,
skipIfNo
Sox
,
skipIfNoModule
,
skipIfNoExec
,
get_asset_path
,
...
...
@@ -31,7 +31,7 @@ if _mod_utils.is_module_available("requests"):
import
requests
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestSoxEffects
(
PytorchTestCase
):
def
test_init
(
self
):
"""Calling init_sox_effects multiple times does not crush"""
...
...
@@ -39,7 +39,7 @@ class TestSoxEffects(PytorchTestCase):
sox_effects
.
init_sox_effects
()
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestSoxEffectsTensor
(
TempDirMixin
,
PytorchTestCase
):
"""Test suite for `apply_effects_tensor` function"""
@
parameterized
.
expand
(
list
(
itertools
.
product
(
...
...
@@ -91,7 +91,7 @@ class TestSoxEffectsTensor(TempDirMixin, PytorchTestCase):
self
.
assertEqual
(
expected
,
found
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestSoxEffectsFile
(
TempDirMixin
,
PytorchTestCase
):
"""Test suite for `apply_effects_file` function"""
@
parameterized
.
expand
(
list
(
itertools
.
product
(
...
...
@@ -163,7 +163,7 @@ class TestSoxEffectsFile(TempDirMixin, PytorchTestCase):
self
.
assertEqual
(
found
,
expected
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestFileFormats
(
TempDirMixin
,
PytorchTestCase
):
"""`apply_effects_file` gives the same result as sox on various file formats"""
@
parameterized
.
expand
(
list
(
itertools
.
product
(
...
...
@@ -256,7 +256,7 @@ class TestFileFormats(TempDirMixin, PytorchTestCase):
self
.
assertEqual
(
found
,
expected
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestApplyEffectFileWithoutExtension
(
PytorchTestCase
):
def
test_mp3
(
self
):
"""Providing format allows to read mp3 without extension
...
...
@@ -275,7 +275,7 @@ class TestApplyEffectFileWithoutExtension(PytorchTestCase):
@
skipIfNoExec
(
'sox'
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestFileObject
(
TempDirMixin
,
PytorchTestCase
):
@
parameterized
.
expand
([
(
'wav'
,
None
),
...
...
@@ -384,7 +384,7 @@ class TestFileObject(TempDirMixin, PytorchTestCase):
self
.
assertEqual
(
found
,
expected
)
@
skipIfNo
Extension
@
skipIfNo
Sox
@
skipIfNoExec
(
'sox'
)
@
skipIfNoModule
(
"requests"
)
class
TestFileObjectHttp
(
HttpServerMixin
,
PytorchTestCase
):
...
...
test/torchaudio_unittest/sox_effect/torchscript_test.py
View file @
ecfed4d9
...
...
@@ -7,7 +7,7 @@ from parameterized import parameterized
from
torchaudio_unittest.common_utils
import
(
TempDirMixin
,
PytorchTestCase
,
skipIfNo
Extension
,
skipIfNo
Sox
,
get_sinusoid
,
save_wav
,
)
...
...
@@ -43,7 +43,7 @@ class SoxEffectFileTransform(torch.nn.Module):
return
sox_effects
.
apply_effects_file
(
path
,
self
.
effects
,
self
.
channels_first
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestTorchScript
(
TempDirMixin
,
PytorchTestCase
):
@
parameterized
.
expand
(
load_params
(
"sox_effect_test_args.json"
),
...
...
test/torchaudio_unittest/utils/sox_utils_test.py
View file @
ecfed4d9
...
...
@@ -2,11 +2,11 @@ from torchaudio.utils import sox_utils
from
torchaudio_unittest.common_utils
import
(
PytorchTestCase
,
skipIfNo
Extension
,
skipIfNo
Sox
,
)
@
skipIfNo
Extension
@
skipIfNo
Sox
class
TestSoxUtils
(
PytorchTestCase
):
"""Smoke tests for sox_util module"""
def
test_set_seed
(
self
):
...
...
third_party/CMakeLists.txt
View file @
ecfed4d9
...
...
@@ -10,12 +10,8 @@ if (BUILD_SOX)
add_subdirectory
(
sox
)
target_include_directories
(
libsox INTERFACE
${
SOX_INCLUDE_DIR
}
)
target_link_libraries
(
libsox INTERFACE
${
SOX_LIBRARIES
}
)
else
()
# If not building and linking libsox statically, then we expect that
# sox library and header are found in search path
target_link_libraries
(
libsox INTERFACE -lsox
)
list
(
APPEND TORCHAUDIO_THIRD_PARTIES libsox
)
endif
()
list
(
APPEND TORCHAUDIO_THIRD_PARTIES libsox
)
################################################################################
# kaldi
...
...
torchaudio/_internal/module_utils.py
View file @
ecfed4d9
...
...
@@ -3,6 +3,8 @@ import importlib.util
from
typing
import
Optional
from
functools
import
wraps
import
torch
def
is_module_available
(
*
modules
:
str
)
->
bool
:
r
"""Returns if a top-level module with :attr:`name` exists *without**
...
...
@@ -56,3 +58,20 @@ def deprecated(direction: str, version: Optional[str] = None):
return
func
(
*
args
,
**
kwargs
)
return
wrapped
return
decorator
def
is_sox_available
():
return
is_module_available
(
'torchaudio._torchaudio'
)
and
torch
.
ops
.
torchaudio
.
is_sox_available
()
def
requires_sox
():
if
is_sox_available
():
def
decorator
(
func
):
return
func
else
:
def
decorator
(
func
):
@
wraps
(
func
)
def
wrapped
(
*
args
,
**
kwargs
):
raise
RuntimeError
(
f
'
{
func
.
__module__
}
.
{
func
.
__name__
}
requires sox'
)
return
wrapped
return
decorator
torchaudio/backend/sox_io_backend.py
View file @
ecfed4d9
...
...
@@ -10,7 +10,7 @@ import torchaudio
from
.common
import
AudioMetaData
@
_mod_utils
.
requires_
module
(
'torchaudio._torchaudio'
)
@
_mod_utils
.
requires_
sox
(
)
def
info
(
filepath
:
str
,
format
:
Optional
[
str
]
=
None
,
...
...
@@ -54,7 +54,7 @@ def info(
return
AudioMetaData
(
*
sinfo
)
@
_mod_utils
.
requires_
module
(
'torchaudio._torchaudio'
)
@
_mod_utils
.
requires_
sox
(
)
def
load
(
filepath
:
str
,
frame_offset
:
int
=
0
,
...
...
@@ -151,7 +151,7 @@ def load(
filepath
,
frame_offset
,
num_frames
,
normalize
,
channels_first
,
format
)
@
_mod_utils
.
requires_
module
(
'torchaudio._torchaudio'
)
@
_mod_utils
.
requires_
sox
(
)
def
save
(
filepath
:
str
,
src
:
torch
.
Tensor
,
...
...
torchaudio/backend/utils.py
View file @
ecfed4d9
...
...
@@ -3,7 +3,7 @@ import warnings
from
typing
import
Optional
,
List
import
torchaudio
from
torchaudio._internal
.
module_utils
import
is_module_available
from
torchaudio._internal
import
module_utils
as
_mod_utils
from
.
import
(
no_backend
,
sox_io_backend
,
...
...
@@ -24,9 +24,9 @@ def list_audio_backends() -> List[str]:
List[str]: The list of available backends.
"""
backends
=
[]
if
is_module_available
(
'soundfile'
):
if
_mod_utils
.
is_module_available
(
'soundfile'
):
backends
.
append
(
'soundfile'
)
if
is
_mod
ule_available
(
'torchaudio._torchaudio'
):
if
_mod
_utils
.
is_sox_available
(
):
backends
.
append
(
'sox_io'
)
return
backends
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment