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
c4a17027
Unverified
Commit
c4a17027
authored
May 22, 2021
by
jachymuv
Committed by
GitHub
May 22, 2021
Browse files
Do not use IO functions in batch consistency test (#1521)
parent
ae9560da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
12 deletions
+6
-12
test/torchaudio_unittest/transforms/batch_consistency_test.py
.../torchaudio_unittest/transforms/batch_consistency_test.py
+6
-12
No files found.
test/torchaudio_unittest/transforms/batch_consistency_test.py
View file @
c4a17027
...
@@ -74,8 +74,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
...
@@ -74,8 +74,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
self
.
assertEqual
(
computed
,
expected
)
self
.
assertEqual
(
computed
,
expected
)
def
test_batch_mulaw
(
self
):
def
test_batch_mulaw
(
self
):
test_filepath
=
common_utils
.
get_asset_path
(
'steam-train-whistle-daniel_simon.wav'
)
waveform
=
common_utils
.
get_whitenoise
(
sample_rate
=
8000
,
duration
=
1
,
n_channels
=
2
)
waveform
,
_
=
torchaudio
.
load
(
test_filepath
)
# (2, 278756), 44100
# Single then transform then batch
# Single then transform then batch
waveform_encoded
=
torchaudio
.
transforms
.
MuLawEncoding
()(
waveform
)
waveform_encoded
=
torchaudio
.
transforms
.
MuLawEncoding
()(
waveform
)
...
@@ -99,8 +98,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
...
@@ -99,8 +98,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
self
.
assertEqual
(
computed
,
expected
)
self
.
assertEqual
(
computed
,
expected
)
def
test_batch_spectrogram
(
self
):
def
test_batch_spectrogram
(
self
):
test_filepath
=
common_utils
.
get_asset_path
(
'steam-train-whistle-daniel_simon.wav'
)
waveform
=
common_utils
.
get_whitenoise
(
sample_rate
=
8000
,
duration
=
1
,
n_channels
=
2
)
waveform
,
_
=
torchaudio
.
load
(
test_filepath
)
# (2, 278756), 44100
# Single then transform then batch
# Single then transform then batch
expected
=
torchaudio
.
transforms
.
Spectrogram
()(
waveform
).
repeat
(
3
,
1
,
1
,
1
)
expected
=
torchaudio
.
transforms
.
Spectrogram
()(
waveform
).
repeat
(
3
,
1
,
1
,
1
)
...
@@ -110,8 +108,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
...
@@ -110,8 +108,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
self
.
assertEqual
(
computed
,
expected
)
self
.
assertEqual
(
computed
,
expected
)
def
test_batch_melspectrogram
(
self
):
def
test_batch_melspectrogram
(
self
):
test_filepath
=
common_utils
.
get_asset_path
(
'steam-train-whistle-daniel_simon.wav'
)
waveform
=
common_utils
.
get_whitenoise
(
sample_rate
=
8000
,
duration
=
1
,
n_channels
=
2
)
waveform
,
_
=
torchaudio
.
load
(
test_filepath
)
# (2, 278756), 44100
# Single then transform then batch
# Single then transform then batch
expected
=
torchaudio
.
transforms
.
MelSpectrogram
()(
waveform
).
repeat
(
3
,
1
,
1
,
1
)
expected
=
torchaudio
.
transforms
.
MelSpectrogram
()(
waveform
).
repeat
(
3
,
1
,
1
,
1
)
...
@@ -121,8 +118,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
...
@@ -121,8 +118,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
self
.
assertEqual
(
computed
,
expected
)
self
.
assertEqual
(
computed
,
expected
)
def
test_batch_mfcc
(
self
):
def
test_batch_mfcc
(
self
):
test_filepath
=
common_utils
.
get_asset_path
(
'steam-train-whistle-daniel_simon.wav'
)
waveform
=
common_utils
.
get_whitenoise
(
sample_rate
=
8000
,
duration
=
1
,
n_channels
=
2
)
waveform
,
_
=
torchaudio
.
load
(
test_filepath
)
# Single then transform then batch
# Single then transform then batch
expected
=
torchaudio
.
transforms
.
MFCC
()(
waveform
).
repeat
(
3
,
1
,
1
,
1
)
expected
=
torchaudio
.
transforms
.
MFCC
()(
waveform
).
repeat
(
3
,
1
,
1
,
1
)
...
@@ -160,8 +156,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
...
@@ -160,8 +156,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
self
.
assertEqual
(
computed
,
expected
,
atol
=
1e-5
,
rtol
=
1e-5
)
self
.
assertEqual
(
computed
,
expected
,
atol
=
1e-5
,
rtol
=
1e-5
)
def
test_batch_Fade
(
self
):
def
test_batch_Fade
(
self
):
test_filepath
=
common_utils
.
get_asset_path
(
'steam-train-whistle-daniel_simon.wav'
)
waveform
=
common_utils
.
get_whitenoise
(
sample_rate
=
8000
,
duration
=
1
,
n_channels
=
2
)
waveform
,
_
=
torchaudio
.
load
(
test_filepath
)
# (2, 278756), 44100
fade_in_len
=
3000
fade_in_len
=
3000
fade_out_len
=
3000
fade_out_len
=
3000
...
@@ -173,8 +168,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
...
@@ -173,8 +168,7 @@ class TestTransforms(common_utils.TorchaudioTestCase):
self
.
assertEqual
(
computed
,
expected
)
self
.
assertEqual
(
computed
,
expected
)
def
test_batch_Vol
(
self
):
def
test_batch_Vol
(
self
):
test_filepath
=
common_utils
.
get_asset_path
(
'steam-train-whistle-daniel_simon.wav'
)
waveform
=
common_utils
.
get_whitenoise
(
sample_rate
=
8000
,
duration
=
1
,
n_channels
=
2
)
waveform
,
_
=
torchaudio
.
load
(
test_filepath
)
# (2, 278756), 44100
# Single then transform then batch
# Single then transform then batch
expected
=
torchaudio
.
transforms
.
Vol
(
gain
=
1.1
)(
waveform
).
repeat
(
3
,
1
,
1
)
expected
=
torchaudio
.
transforms
.
Vol
(
gain
=
1.1
)(
waveform
).
repeat
(
3
,
1
,
1
)
...
...
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