-
Notifications
You must be signed in to change notification settings - Fork 695
Refactor test backend #719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,17 +10,17 @@ | |
from .functional_impl import Lfilter | ||
|
||
|
||
class TestLFilterFloat32(Lfilter, common_utils.TestCase): | ||
class TestLFilterFloat32(Lfilter, common_utils.PytorchTestCase): | ||
dtype = torch.float32 | ||
device = torch.device('cpu') | ||
|
||
|
||
class TestLFilterFloat64(Lfilter, common_utils.TestCase): | ||
class TestLFilterFloat64(Lfilter, common_utils.PytorchTestCase): | ||
dtype = torch.float64 | ||
device = torch.device('cpu') | ||
|
||
|
||
class TestComputeDeltas(unittest.TestCase): | ||
class TestComputeDeltas(common_utils.TorchaudioTestCase): | ||
"""Test suite for correctness of compute_deltas""" | ||
def test_one_channel(self): | ||
specgram = torch.tensor([[[1.0, 2.0, 3.0, 4.0]]]) | ||
|
@@ -57,7 +57,7 @@ def _test_istft_is_inverse_of_stft(kwargs): | |
_compare_estimate(sound, estimate) | ||
|
||
|
||
class TestIstft(unittest.TestCase): | ||
class TestIstft(common_utils.TorchaudioTestCase): | ||
"""Test suite for correctness of istft with various input""" | ||
number_of_trials = 100 | ||
|
||
|
@@ -273,7 +273,9 @@ def test_linearity_of_istft4(self): | |
self._test_linearity_of_istft(data_size, kwargs4, atol=1e-5, rtol=1e-8) | ||
|
||
|
||
class TestDetectPitchFrequency(unittest.TestCase): | ||
class TestDetectPitchFrequency(common_utils.TorchaudioTestCase): | ||
backend = 'default' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this is the only one that needs a backend to be specified? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are couple of them, the less class requires backend, the better. yet still the backend is reset for the each class. |
||
|
||
def test_pitch(self): | ||
test_filepath_100 = common_utils.get_asset_path("100Hz_44100Hz_16bit_05sec.wav") | ||
test_filepath_440 = common_utils.get_asset_path("440Hz_44100Hz_16bit_05sec.wav") | ||
|
@@ -294,7 +296,7 @@ def test_pitch(self): | |
self.assertFalse(s) | ||
|
||
|
||
class TestDB_to_amplitude(unittest.TestCase): | ||
class TestDB_to_amplitude(common_utils.TorchaudioTestCase): | ||
def test_DB_to_amplitude(self): | ||
# Make some noise | ||
x = torch.rand(1000) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import math | ||
import os | ||
import math | ||
import unittest | ||
|
||
import torch | ||
import torchaudio | ||
import torchaudio.compliance.kaldi as kaldi | ||
import unittest | ||
|
||
from . import common_utils | ||
from .compliance import utils as compliance_utils | ||
from .common_utils import AudioBackendScope, BACKENDS | ||
|
||
|
||
def extract_window(window, wave, f, frame_length, frame_shift, snip_edges): | ||
|
@@ -46,7 +46,10 @@ def first_sample_of_frame(frame, window_size, window_shift, snip_edges): | |
window[f, s] = wave[s_in_wave] | ||
|
||
|
||
class Test_Kaldi(unittest.TestCase): | ||
@common_utils.skipIfNoSoxBackend | ||
class Test_Kaldi(common_utils.TorchaudioTestCase): | ||
backend = 'sox' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: only one the method in tests below needs sox, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
test_filepath = common_utils.get_asset_path('kaldi_file.wav') | ||
test_8000_filepath = common_utils.get_asset_path('kaldi_file_8000.wav') | ||
kaldi_output_dir = common_utils.get_asset_path('kaldi') | ||
|
@@ -162,8 +165,6 @@ def test_mfcc_empty(self): | |
# Passing in an empty tensor should result in an error | ||
self.assertRaises(AssertionError, kaldi.mfcc, torch.empty(0)) | ||
|
||
@unittest.skipIf("sox" not in BACKENDS, "sox not available") | ||
@AudioBackendScope("sox") | ||
def test_resample_waveform(self): | ||
def get_output_fn(sound, args): | ||
output = kaldi.resample_waveform(sound, args[1], args[2]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would merge these two bullet points