From df1bded958fdd8c92404efc77ace3cf42b8f28a8 Mon Sep 17 00:00:00 2001 From: moto <855818+mthrok@users.noreply.github.com> Date: Fri, 12 Jun 2020 17:47:00 +0000 Subject: [PATCH] Set individual backends --- test/test_batch_consistency.py | 10 ++++++++++ test/test_librosa_compatibility.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/test/test_batch_consistency.py b/test/test_batch_consistency.py index 029ef2f97bd..f5eeecb85bd 100644 --- a/test/test_batch_consistency.py +++ b/test/test_batch_consistency.py @@ -47,6 +47,7 @@ def test_griffinlim(self): ) def test_detect_pitch_frequency(self): + common_utils.set_audio_backend('default') filenames = [ 'steam-train-whistle-daniel_simon.wav', # 2ch 44100Hz # Files from https://www.mediacollege.com/audio/tone/download/ @@ -79,6 +80,7 @@ def test_overdrive(self): self.assert_batch_consistencies(F.overdrive, waveform, gain=45, colour=30) def test_phaser(self): + common_utils.set_audio_backend('default') filepath = common_utils.get_asset_path("whitenoise.wav") waveform, sample_rate = torchaudio.load(filepath) self.assert_batch_consistencies(F.phaser, waveform, sample_rate) @@ -97,6 +99,7 @@ def test_sliding_window_cmn(self): self.assert_batch_consistencies(F.sliding_window_cmn, waveform, center=False, norm_vars=False) def test_vad(self): + common_utils.set_audio_backend('default') filepath = common_utils.get_asset_path("vad-go-mono-32000.wav") waveform, sample_rate = torchaudio.load(filepath) self.assert_batch_consistencies(F.vad, waveform, sample_rate=sample_rate) @@ -168,6 +171,7 @@ def test_batch_compute_deltas(self): self.assertEqual(computed, expected) def test_batch_mulaw(self): + common_utils.set_audio_backend('default') test_filepath = common_utils.get_asset_path('steam-train-whistle-daniel_simon.wav') waveform, _ = torchaudio.load(test_filepath) # (2, 278756), 44100 @@ -193,6 +197,7 @@ def test_batch_mulaw(self): self.assertEqual(computed, expected) def test_batch_spectrogram(self): + common_utils.set_audio_backend('default') test_filepath = common_utils.get_asset_path('steam-train-whistle-daniel_simon.wav') waveform, _ = torchaudio.load(test_filepath) # (2, 278756), 44100 @@ -204,6 +209,7 @@ def test_batch_spectrogram(self): self.assertEqual(computed, expected) def test_batch_melspectrogram(self): + common_utils.set_audio_backend('default') test_filepath = common_utils.get_asset_path('steam-train-whistle-daniel_simon.wav') waveform, _ = torchaudio.load(test_filepath) # (2, 278756), 44100 @@ -215,6 +221,7 @@ def test_batch_melspectrogram(self): self.assertEqual(computed, expected) def test_batch_mfcc(self): + common_utils.set_audio_backend('default') test_filepath = common_utils.get_asset_path('steam-train-whistle-daniel_simon.wav') waveform, _ = torchaudio.load(test_filepath) @@ -226,6 +233,7 @@ def test_batch_mfcc(self): self.assertEqual(computed, expected, atol=1e-4, rtol=1e-5) def test_batch_TimeStretch(self): + common_utils.set_audio_backend('default') test_filepath = common_utils.get_asset_path('steam-train-whistle-daniel_simon.wav') waveform, _ = torchaudio.load(test_filepath) # (2, 278756), 44100 @@ -260,6 +268,7 @@ def test_batch_TimeStretch(self): self.assertEqual(computed, expected, atol=1e-5, rtol=1e-5) def test_batch_Fade(self): + common_utils.set_audio_backend('default') test_filepath = common_utils.get_asset_path('steam-train-whistle-daniel_simon.wav') waveform, _ = torchaudio.load(test_filepath) # (2, 278756), 44100 fade_in_len = 3000 @@ -273,6 +282,7 @@ def test_batch_Fade(self): self.assertEqual(computed, expected) def test_batch_Vol(self): + common_utils.set_audio_backend('default') test_filepath = common_utils.get_asset_path('steam-train-whistle-daniel_simon.wav') waveform, _ = torchaudio.load(test_filepath) # (2, 278756), 44100 diff --git a/test/test_librosa_compatibility.py b/test/test_librosa_compatibility.py index 65bfe6c26f0..f90a463ad9d 100644 --- a/test/test_librosa_compatibility.py +++ b/test/test_librosa_compatibility.py @@ -159,6 +159,7 @@ def _load_audio_asset(*asset_paths, **kwargs): class TestTransforms(common_utils.TorchaudioTestCase): """Test suite for functions in `transforms` module.""" def assert_compatibilities(self, n_fft, hop_length, power, n_mels, n_mfcc, sample_rate): + common_utils.set_audio_backend('default') sound, sample_rate = _load_audio_asset('sinewave.wav') sound_librosa = sound.cpu().numpy().squeeze() # (64000) @@ -275,6 +276,7 @@ def test_MelScale(self): hop_length = n_fft // 4 # Prepare spectrogram input. We use torchaudio to compute one. + common_utils.set_audio_backend('default') sound, sample_rate = _load_audio_asset('whitenoise_1min.mp3') sound = sound.mean(dim=0, keepdim=True) spec_ta = F.spectrogram( @@ -297,6 +299,7 @@ def test_InverseMelScale(self): hop_length = n_fft // 4 # Prepare mel spectrogram input. We use torchaudio to compute one. + common_utils.set_audio_backend('default') sound, sample_rate = _load_audio_asset( 'steam-train-whistle-daniel_simon.wav', offset=2**10, num_frames=2**14) sound = sound.mean(dim=0, keepdim=True)