From 2f470eda80c71237f25d1c99654435e0da35bf4f Mon Sep 17 00:00:00 2001 From: Vincent Quenneville-Belair Date: Thu, 6 Feb 2020 15:38:30 -0500 Subject: [PATCH] use wav instead of mp3 for testing functions. --- test/test_functional.py | 2 +- test/test_transforms.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/test_functional.py b/test/test_functional.py index 6afc14302bc..15219b8d3b7 100644 --- a/test/test_functional.py +++ b/test/test_functional.py @@ -40,7 +40,7 @@ class TestFunctional(unittest.TestCase): test_dirpath, test_dir = common_utils.create_temp_assets_dir() test_filepath = os.path.join(test_dirpath, 'assets', - 'steam-train-whistle-daniel_simon.mp3') + 'steam-train-whistle-daniel_simon.wav') waveform_train, sr_train = torchaudio.load(test_filepath) def test_torchscript_spectrogram(self): diff --git a/test/test_transforms.py b/test/test_transforms.py index 8cca3085e06..697ca1ba1d5 100644 --- a/test/test_transforms.py +++ b/test/test_transforms.py @@ -19,6 +19,8 @@ RUN_CUDA = torch.cuda.is_available() print("Run test with cuda:", RUN_CUDA) +BACKENDS = torchaudio._backend._audio_backends + def _test_script_module(f, tensor, *args, **kwargs): @@ -55,7 +57,7 @@ class Tester(unittest.TestCase): # file for stereo stft test test_dirpath, test_dir = common_utils.create_temp_assets_dir() test_filepath = os.path.join(test_dirpath, 'assets', - 'steam-train-whistle-daniel_simon.mp3') + 'steam-train-whistle-daniel_simon.wav') def scale(self, waveform, factor=float(2**31)): # scales a waveform by a factor @@ -469,8 +471,12 @@ def test_batch_melspectrogram(self): self.assertTrue(computed.shape == expected.shape, (computed.shape, expected.shape)) self.assertTrue(torch.allclose(computed, expected)) + @unittest.skipIf(set("sox") not in set(BACKENDS), "sox are not available") def test_batch_mfcc(self): - waveform, sample_rate = torchaudio.load(self.test_filepath) + test_filepath = os.path.join( + test_dirpath, 'assets', 'steam-train-whistle-daniel_simon.mp3' + ) + waveform, sample_rate = torchaudio.load(test_filepath) # Single then transform then batch expected = transforms.MFCC()(waveform).repeat(3, 1, 1, 1)