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
33f762f6
Unverified
Commit
33f762f6
authored
Jul 28, 2020
by
suraj813
Committed by
GitHub
Jul 28, 2020
Browse files
Added test for CMUArctic Dataset (#829)
parent
db38fc88
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
6 deletions
+67
-6
test/assets/ARCTIC/cmu_us_aew_arctic/etc/txt.done.data
test/assets/ARCTIC/cmu_us_aew_arctic/etc/txt.done.data
+0
-1
test/assets/ARCTIC/cmu_us_aew_arctic/wav/arctic_a0024.wav
test/assets/ARCTIC/cmu_us_aew_arctic/wav/arctic_a0024.wav
+0
-0
test/datasets/cmuarctic_test.py
test/datasets/cmuarctic_test.py
+67
-0
test/datasets/datasets_test.py
test/datasets/datasets_test.py
+0
-5
No files found.
test/assets/ARCTIC/cmu_us_aew_arctic/etc/txt.done.data
deleted
100644 → 0
View file @
db38fc88
( arctic_a0024 "This is the test text." )
test/assets/ARCTIC/cmu_us_aew_arctic/wav/arctic_a0024.wav
deleted
100644 → 0
View file @
db38fc88
File deleted
test/datasets/cmuarctic_test.py
0 → 100644
View file @
33f762f6
import
os
from
torchaudio.datasets
import
cmuarctic
from
..common_utils
import
(
TempDirMixin
,
TorchaudioTestCase
,
get_whitenoise
,
save_wav
,
normalize_wav
,
)
class
TestCMUARCTIC
(
TempDirMixin
,
TorchaudioTestCase
):
backend
=
"default"
root_dir
=
None
samples
=
[]
@
classmethod
def
setUpClass
(
cls
):
cls
.
root_dir
=
cls
.
get_base_temp_dir
()
sample_rate
=
16000
utterance
=
"This is a test utterance."
base_dir
=
os
.
path
.
join
(
cls
.
root_dir
,
"ARCTIC"
,
"cmu_us_aew_arctic"
)
txt_dir
=
os
.
path
.
join
(
base_dir
,
"etc"
)
os
.
makedirs
(
txt_dir
,
exist_ok
=
True
)
txt_file
=
os
.
path
.
join
(
txt_dir
,
"txt.done.data"
)
audio_dir
=
os
.
path
.
join
(
base_dir
,
"wav"
)
os
.
makedirs
(
audio_dir
,
exist_ok
=
True
)
seed
=
42
with
open
(
txt_file
,
"w"
)
as
txt
:
for
c
in
[
"a"
,
"b"
]:
for
i
in
range
(
5
):
utterance_id
=
f
"arctic_
{
c
}{
i
:
04
d
}
"
path
=
os
.
path
.
join
(
audio_dir
,
f
"
{
utterance_id
}
.wav"
)
data
=
get_whitenoise
(
sample_rate
=
sample_rate
,
duration
=
3
,
n_channels
=
1
,
dtype
=
"int16"
,
seed
=
seed
,
)
save_wav
(
path
,
data
,
sample_rate
)
sample
=
(
normalize_wav
(
data
),
sample_rate
,
utterance
,
utterance_id
.
split
(
"_"
)[
1
],
)
cls
.
samples
.
append
(
sample
)
txt
.
write
(
f
'(
{
utterance_id
}
"
{
utterance
}
" )
\n
'
)
seed
+=
1
def
test_cmuarctic
(
self
):
dataset
=
cmuarctic
.
CMUARCTIC
(
self
.
root_dir
)
n_ite
=
0
for
i
,
(
waveform
,
sample_rate
,
utterance
,
utterance_id
)
in
enumerate
(
dataset
):
expected_sample
=
self
.
samples
[
i
]
assert
sample_rate
==
expected_sample
[
1
]
assert
utterance
==
expected_sample
[
2
]
assert
utterance_id
==
expected_sample
[
3
]
self
.
assertEqual
(
expected_sample
[
0
],
waveform
,
atol
=
5e-5
,
rtol
=
1e-8
)
n_ite
+=
1
assert
n_ite
==
len
(
self
.
samples
)
test/datasets/datasets_test.py
View file @
33f762f6
from
torchaudio.datasets.librispeech
import
LIBRISPEECH
from
torchaudio.datasets.librispeech
import
LIBRISPEECH
from
torchaudio.datasets.speechcommands
import
SPEECHCOMMANDS
from
torchaudio.datasets.speechcommands
import
SPEECHCOMMANDS
from
torchaudio.datasets.vctk
import
VCTK
from
torchaudio.datasets.vctk
import
VCTK
from
torchaudio.datasets.cmuarctic
import
CMUARCTIC
from
..common_utils
import
(
from
..common_utils
import
(
TorchaudioTestCase
,
TorchaudioTestCase
,
...
@@ -16,7 +15,3 @@ class TestDatasets(TorchaudioTestCase):
...
@@ -16,7 +15,3 @@ class TestDatasets(TorchaudioTestCase):
def
test_vctk
(
self
):
def
test_vctk
(
self
):
data
=
VCTK
(
self
.
path
)
data
=
VCTK
(
self
.
path
)
data
[
0
]
data
[
0
]
def
test_cmuarctic
(
self
):
data
=
CMUARCTIC
(
self
.
path
)
data
[
0
]
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