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
93c3025f
Unverified
Commit
93c3025f
authored
Dec 30, 2020
by
Aziz
Committed by
GitHub
Dec 30, 2020
Browse files
Make Dataset utility test independent of CommonVoice (#1132)
parent
71214b48
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
18 deletions
+16
-18
test/torchaudio_unittest/assets/CommonVoice/cv-corpus-4-2019-12-10/tt/clips/common_voice_tt_00000000.wav
...corpus-4-2019-12-10/tt/clips/common_voice_tt_00000000.wav
+0
-0
test/torchaudio_unittest/assets/CommonVoice/cv-corpus-4-2019-12-10/tt/train.tsv
...st/assets/CommonVoice/cv-corpus-4-2019-12-10/tt/train.tsv
+0
-3
test/torchaudio_unittest/datasets/utils_test.py
test/torchaudio_unittest/datasets/utils_test.py
+16
-15
No files found.
test/torchaudio_unittest/assets/CommonVoice/cv-corpus-4-2019-12-10/tt/clips/common_voice_tt_00000000.wav
deleted
100644 → 0
View file @
71214b48
File deleted
test/torchaudio_unittest/assets/CommonVoice/cv-corpus-4-2019-12-10/tt/train.tsv
deleted
100644 → 0
View file @
71214b48
client_id path sentence up_votes down_votes age gender accent
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 common_voice_tt_00000000.wav test. 1 0 thirties female
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 common_voice_tt_00000000.wav test. 1 0 thirties female
test/torchaudio_unittest/datasets/utils_test.py
View file @
93c3025f
import
torch
from
torchaudio_unittest.common_utils
import
(
from
torchaudio_unittest.common_utils
import
(
TorchaudioTestCase
,
TorchaudioTestCase
,
get_asset_path
,
TempDirMixin
)
)
from
torchaudio.datasets
import
utils
as
dataset_utils
from
torchaudio.datasets
import
utils
as
dataset_utils
from
torchaudio.datasets.commonvoice
import
COMMONVOICE
original_ext_audio
=
COMMONVOICE
.
_ext_audio
class
Dataset
(
torch
.
utils
.
data
.
Dataset
):
def
__getitem__
(
self
,
n
):
sample_rate
=
8000
waveform
=
n
*
torch
.
ones
(
2
,
256
)
return
waveform
,
sample_rate
class
TestIterator
(
TorchaudioTestCase
):
def
__len__
(
self
)
->
int
:
@
classmethod
return
2
def
setUpClass
(
cls
):
COMMONVOICE
.
_ext_audio
=
".wav"
@
classmethod
def
__iter__
(
self
):
def
tearDownClass
(
cls
):
for
i
in
range
(
len
(
self
)
):
COMMONVOICE
.
_ext_audio
=
original_ext_audio
yield
self
[
i
]
class
TestIterator
(
TorchaudioTestCase
,
TempDirMixin
):
backend
=
'default'
backend
=
'default'
path
=
get_asset_path
(
'CommonVoice'
,
'cv-corpus-4-2019-12-10'
,
'tt'
)
def
test_disckcache_iterator
(
self
):
def
test_disckcache_iterator
(
self
):
data
=
COMMONVOICE
(
self
.
path
,
url
=
"tatar"
)
data
=
dataset_utils
.
diskcache_iterator
(
Dataset
(),
self
.
get_base_temp_dir
())
data
=
dataset_utils
.
diskcache_iterator
(
data
)
# Save
# Save
data
[
0
]
data
[
0
]
# Load
# Load
data
[
0
]
data
[
0
]
def
test_bg_iterator
(
self
):
def
test_bg_iterator
(
self
):
data
=
COMMONVOICE
(
self
.
path
,
url
=
"tatar"
)
data
=
dataset_utils
.
bg_iterator
(
Dataset
(),
5
)
data
=
dataset_utils
.
bg_iterator
(
data
,
5
)
for
_
in
data
:
for
_
in
data
:
pass
pass
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