def test_list_read_formats(self): """`list_read_formats` returns the list of supported formats""" formats = sox_utils.list_read_formats() assert 'wav' in formats
from torchaudio.utils import sox_utils from torchaudio.backend import sox_io_backend from torchaudio._internal.module_utils import is_module_available from parameterized import parameterized from torchaudio_unittest.common_utils import ( TempDirMixin, TorchaudioTestCase, skipIfNoExtension, get_wav_data, ) from .common import name_func skipIfNoMP3 = unittest.skipIf( not is_module_available('torchaudio._torchaudio') 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') @skipIfNoExtension class SmokeTest(TempDirMixin, TorchaudioTestCase): """Run smoke test on various audio format The purpose of this test suite is to verify that sox_io_backend functionalities do not exhibit abnormal behaviors. This test suite should be able to run without any additional tools (such as sox command), however without such tools, the correctness of each function cannot be verified. """ def run_smoke_test(self,
from torchaudio.utils import sox_utils from torchaudio.backend import sox_io_backend from torchaudio._internal.module_utils import is_sox_available from parameterized import parameterized from torchaudio_unittest.common_utils import ( TempDirMixin, TorchaudioTestCase, skipIfNoSox, get_wav_data, ) from .common import name_func skipIfNoMP3 = unittest.skipIf( 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') @skipIfNoSox class SmokeTest(TempDirMixin, TorchaudioTestCase): """Run smoke test on various audio format The purpose of this test suite is to verify that sox_io_backend functionalities do not exhibit abnormal behaviors. This test suite should be able to run without any additional tools (such as sox command), however without such tools, the correctness of each function cannot be verified. """ def run_smoke_test(self,
import torchaudio from torchaudio.utils import sox_utils from torchaudio._internal.module_utils import is_module_available from torchaudio_unittest.common_utils import get_asset_path BACKENDS = [] BACKENDS_MP3 = [] if is_module_available('soundfile'): BACKENDS.append('soundfile') if is_module_available('torchaudio._torchaudio'): BACKENDS.append('sox') if ('mp3' in sox_utils.list_read_formats() and 'mp3' in sox_utils.list_write_formats()): BACKENDS_MP3 = ['sox'] def create_temp_assets_dir(): """ Creates a temporary directory and moves all files from test/assets there. Returns a Tuple[string, TemporaryDirectory] which is the folder path and object. """ tmp_dir = tempfile.TemporaryDirectory() shutil.copytree(get_asset_path(), os.path.join(tmp_dir.name, "assets")) return tmp_dir.name, tmp_dir