Skip to content

Commit

Permalink
Remove skipIfNoSoxBackend (#1390)
Browse files Browse the repository at this point in the history
Co-authored-by: krishnakalyan3 <skalyan@cloudera.com>
  • Loading branch information
krishnakalyan3 and krishnakalyan3 committed Mar 29, 2021
1 parent 14dd917 commit 512c2fa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
1 change: 0 additions & 1 deletion test/torchaudio_unittest/common_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
skipIfNoModule,
skipIfNoKaldi,
skipIfNoSox,
skipIfNoSoxBackend,
)
from .wav_utils import (
get_wav_data,
Expand Down
3 changes: 0 additions & 3 deletions test/torchaudio_unittest/common_utils/case_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import torch
from torch.testing._internal.common_utils import TestCase as PytorchTestCase
import torchaudio
from torchaudio._internal.module_utils import (
is_module_available,
is_sox_available,
Expand Down Expand Up @@ -96,8 +95,6 @@ def skipIfNoModule(module, display_name=None):
return unittest.skipIf(not is_module_available(module), f'"{display_name}" is not available')


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')
skipIfNoKaldi = unittest.skipIf(not is_kaldi_available(), reason='Kaldi not available')
3 changes: 1 addition & 2 deletions test/torchaudio_unittest/compliance_kaldi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def first_sample_of_frame(frame, window_size, window_shift, snip_edges):

@common_utils.skipIfNoSox
class Test_Kaldi(common_utils.TempDirMixin, common_utils.TorchaudioTestCase):
backend = 'sox_io'

kaldi_output_dir = common_utils.get_asset_path('kaldi')
test_filepath = common_utils.get_asset_path('kaldi_file.wav')
Expand Down Expand Up @@ -113,7 +112,7 @@ def _create_data_set(self):
# clear the last 16 bits because they aren't used anyways
y = ((y >> 16) << 16).float()
torchaudio.save(self.test_filepath, y, sr)
sound, sample_rate = torchaudio.load(self.test_filepath, normalization=False)
sound, sample_rate = common_utils.load_wav(self.test_filepath, normalize=False)
print(y >> 16)
self.assertTrue(sample_rate == sr)
self.assertEqual(y, sound)
Expand Down
4 changes: 2 additions & 2 deletions test/torchaudio_unittest/functional/sox_compatibility_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import torchaudio.functional as F

from torchaudio_unittest.common_utils import (
skipIfNoSoxBackend,
skipIfNoSox,
skipIfNoExec,
TempDirMixin,
TorchaudioTestCase,
Expand All @@ -14,7 +14,7 @@
)


@skipIfNoSoxBackend
@skipIfNoSox
@skipIfNoExec('sox')
class TestFunctionalFiltering(TempDirMixin, TorchaudioTestCase):
def run_sox_effect(self, input_file, effect):
Expand Down
14 changes: 12 additions & 2 deletions test/torchaudio_unittest/transforms/sox_compatibility_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
from parameterized import parameterized

from torchaudio_unittest.common_utils import (
skipIfNoSoxBackend,
skipIfNoSox,
skipIfNoExec,
TempDirMixin,
TorchaudioTestCase,
get_asset_path,
sox_utils,
load_wav,
save_wav,
get_whitenoise,
)


@skipIfNoSoxBackend
@skipIfNoSox
@skipIfNoExec('sox')
class TestFunctionalFiltering(TempDirMixin, TorchaudioTestCase):
def run_sox_effect(self, input_file, effect):
Expand All @@ -24,6 +26,14 @@ def assert_sox_effect(self, result, input_path, effects, atol=1e-04, rtol=1e-5):
expected, _ = self.run_sox_effect(input_path, effects)
self.assertEqual(result, expected, atol=atol, rtol=rtol)

def get_whitenoise(self, sample_rate=8000):
noise = get_whitenoise(
sample_rate=sample_rate, duration=3, scale_factor=0.9,
)
path = self.get_temp_path("whitenoise.wav")
save_wav(path, noise, sample_rate)
return noise, path

@parameterized.expand([
('q', 'quarter_sine'),
('h', 'half_sine'),
Expand Down

0 comments on commit 512c2fa

Please sign in to comment.