Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
6fc8953c
"vscode:/vscode.git/clone" did not exist on "92d70863663662669ee3c376909be1f876e00965"
Unverified
Commit
6fc8953c
authored
May 15, 2020
by
moto
Committed by
GitHub
May 15, 2020
Browse files
Adopt PyTorch's test util to SoX compatibility test (#645)
parent
c960b119
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
test/test_sox_compatibility.py
test/test_sox_compatibility.py
+25
-24
No files found.
test/test_sox_compatibility.py
View file @
6fc8953c
import
unittest
import
unittest
import
torch
import
torch
from
torch.testing._internal.common_utils
import
TestCase
import
torchaudio
import
torchaudio
import
torchaudio.functional
as
F
import
torchaudio.functional
as
F
import
torchaudio.transforms
as
T
import
torchaudio.transforms
as
T
...
@@ -9,7 +10,7 @@ import common_utils
...
@@ -9,7 +10,7 @@ import common_utils
from
common_utils
import
AudioBackendScope
,
BACKENDS
from
common_utils
import
AudioBackendScope
,
BACKENDS
class
TestFunctionalFiltering
(
unittest
.
TestCase
):
class
TestFunctionalFiltering
(
TestCase
):
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
def
test_gain
(
self
):
def
test_gain
(
self
):
...
@@ -24,7 +25,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -24,7 +25,7 @@ class TestFunctionalFiltering(unittest.TestCase):
E
.
append_effect_to_chain
(
"gain"
,
[
3
])
E
.
append_effect_to_chain
(
"gain"
,
[
3
])
sox_gain_waveform
=
E
.
sox_build_flow_effects
()[
0
]
sox_gain_waveform
=
E
.
sox_build_flow_effects
()[
0
]
torch
.
testing
.
assert_allclose
(
waveform_gain
,
sox_gain_waveform
,
atol
=
1e-04
,
rtol
=
1e-5
)
self
.
assertEqual
(
waveform_gain
,
sox_gain_waveform
,
atol
=
1e-04
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -40,13 +41,13 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -40,13 +41,13 @@ class TestFunctionalFiltering(unittest.TestCase):
E
.
append_effect_to_chain
(
"dither"
,
[])
E
.
append_effect_to_chain
(
"dither"
,
[])
sox_dither_waveform
=
E
.
sox_build_flow_effects
()[
0
]
sox_dither_waveform
=
E
.
sox_build_flow_effects
()[
0
]
torch
.
testing
.
assert_allclose
(
waveform_dithered
,
sox_dither_waveform
,
atol
=
1e-04
,
rtol
=
1e-5
)
self
.
assertEqual
(
waveform_dithered
,
sox_dither_waveform
,
atol
=
1e-04
,
rtol
=
1e-5
)
E
.
clear_chain
()
E
.
clear_chain
()
E
.
append_effect_to_chain
(
"dither"
,
[
"-s"
])
E
.
append_effect_to_chain
(
"dither"
,
[
"-s"
])
sox_dither_waveform_ns
=
E
.
sox_build_flow_effects
()[
0
]
sox_dither_waveform_ns
=
E
.
sox_build_flow_effects
()[
0
]
torch
.
testing
.
assert_allclose
(
waveform_dithered_noiseshaped
,
sox_dither_waveform_ns
,
atol
=
1e-02
,
rtol
=
1e-5
)
self
.
assertEqual
(
waveform_dithered_noiseshaped
,
sox_dither_waveform_ns
,
atol
=
1e-02
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -69,7 +70,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -69,7 +70,7 @@ class TestFunctionalFiltering(unittest.TestCase):
E
.
append_effect_to_chain
(
"dither"
,
[
"-s"
])
E
.
append_effect_to_chain
(
"dither"
,
[
"-s"
])
wf_vctk_sox
=
E
.
sox_build_flow_effects
()[
0
]
wf_vctk_sox
=
E
.
sox_build_flow_effects
()[
0
]
torch
.
testing
.
assert_allclose
(
wf_vctk
,
wf_vctk_sox
,
rtol
=
1e-03
,
atol
=
1e-03
)
self
.
assertEqual
(
wf_vctk
,
wf_vctk_sox
,
rtol
=
1e-03
,
atol
=
1e-03
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -89,7 +90,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -89,7 +90,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
lowpass_biquad
(
waveform
,
sample_rate
,
cutoff_freq
)
output_waveform
=
F
.
lowpass_biquad
(
waveform
,
sample_rate
,
cutoff_freq
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -110,7 +111,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -110,7 +111,7 @@ class TestFunctionalFiltering(unittest.TestCase):
output_waveform
=
F
.
highpass_biquad
(
waveform
,
sample_rate
,
cutoff_freq
)
output_waveform
=
F
.
highpass_biquad
(
waveform
,
sample_rate
,
cutoff_freq
)
# TBD - this fails at the 1e-4 level, debug why
# TBD - this fails at the 1e-4 level, debug why
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-3
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-3
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -131,7 +132,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -131,7 +132,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
allpass_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
)
output_waveform
=
F
.
allpass_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -153,7 +154,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -153,7 +154,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
bandpass_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
,
const_skirt_gain
)
output_waveform
=
F
.
bandpass_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
,
const_skirt_gain
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -175,7 +176,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -175,7 +176,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
bandpass_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
,
const_skirt_gain
)
output_waveform
=
F
.
bandpass_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
,
const_skirt_gain
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -196,7 +197,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -196,7 +197,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
bandreject_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
)
output_waveform
=
F
.
bandreject_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -218,7 +219,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -218,7 +219,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
band_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
,
noise
)
output_waveform
=
F
.
band_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
,
noise
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -240,7 +241,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -240,7 +241,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
band_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
,
noise
)
output_waveform
=
F
.
band_biquad
(
waveform
,
sample_rate
,
central_freq
,
q
,
noise
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -262,7 +263,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -262,7 +263,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
treble_biquad
(
waveform
,
sample_rate
,
gain
,
central_freq
,
q
)
output_waveform
=
F
.
treble_biquad
(
waveform
,
sample_rate
,
gain
,
central_freq
,
q
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -280,7 +281,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -280,7 +281,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
deemph_biquad
(
waveform
,
sample_rate
)
output_waveform
=
F
.
deemph_biquad
(
waveform
,
sample_rate
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -298,7 +299,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -298,7 +299,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
riaa_biquad
(
waveform
,
sample_rate
)
output_waveform
=
F
.
riaa_biquad
(
waveform
,
sample_rate
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -316,7 +317,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -316,7 +317,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
contrast
(
waveform
,
enhancement_amount
)
output_waveform
=
F
.
contrast
(
waveform
,
enhancement_amount
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -335,7 +336,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -335,7 +336,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
_
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
_
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
dcshift
(
waveform
,
shift
,
limiter_gain
)
output_waveform
=
F
.
dcshift
(
waveform
,
shift
,
limiter_gain
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -353,7 +354,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -353,7 +354,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
_
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
_
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
dcshift
(
waveform
,
shift
)
output_waveform
=
F
.
dcshift
(
waveform
,
shift
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -372,7 +373,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -372,7 +373,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
_
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
_
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
overdrive
(
waveform
,
gain
,
colour
)
output_waveform
=
F
.
overdrive
(
waveform
,
gain
,
colour
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -394,7 +395,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -394,7 +395,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
phaser
(
waveform
,
sample_rate
,
gain_in
,
gain_out
,
delay_ms
,
decay
,
speed
,
sinusoidal
=
True
)
output_waveform
=
F
.
phaser
(
waveform
,
sample_rate
,
gain_in
,
gain_out
,
delay_ms
,
decay
,
speed
,
sinusoidal
=
True
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -416,7 +417,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -416,7 +417,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
phaser
(
waveform
,
sample_rate
,
gain_in
,
gain_out
,
delay_ms
,
decay
,
speed
,
sinusoidal
=
False
)
output_waveform
=
F
.
phaser
(
waveform
,
sample_rate
,
gain_in
,
gain_out
,
delay_ms
,
decay
,
speed
,
sinusoidal
=
False
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -438,7 +439,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -438,7 +439,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
waveform
,
sample_rate
=
torchaudio
.
load
(
noise_filepath
,
normalization
=
True
)
output_waveform
=
F
.
equalizer_biquad
(
waveform
,
sample_rate
,
center_freq
,
gain
,
q
)
output_waveform
=
F
.
equalizer_biquad
(
waveform
,
sample_rate
,
center_freq
,
gain
,
q
)
torch
.
testing
.
assert_allclose
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
output_waveform
,
sox_output_waveform
,
atol
=
1e-4
,
rtol
=
1e-5
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
unittest
.
skipIf
(
"sox"
not
in
BACKENDS
,
"sox not available"
)
@
AudioBackendScope
(
"sox"
)
@
AudioBackendScope
(
"sox"
)
...
@@ -464,7 +465,7 @@ class TestFunctionalFiltering(unittest.TestCase):
...
@@ -464,7 +465,7 @@ class TestFunctionalFiltering(unittest.TestCase):
waveform
,
torch
.
tensor
([
a0
,
a1
,
a2
]),
torch
.
tensor
([
b0
,
b1
,
b2
])
waveform
,
torch
.
tensor
([
a0
,
a1
,
a2
]),
torch
.
tensor
([
b0
,
b1
,
b2
])
)
)
torch
.
testing
.
assert_allclose
(
waveform_lfilter_out
,
waveform_sox_out
,
atol
=
1e-4
,
rtol
=
1e-5
)
self
.
assertEqual
(
waveform_lfilter_out
,
waveform_sox_out
,
atol
=
1e-4
,
rtol
=
1e-5
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment