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
d88c2449
Unverified
Commit
d88c2449
authored
Oct 29, 2019
by
Vincent QB
Committed by
GitHub
Oct 29, 2019
Browse files
dataset path. (#316)
Fix test for datasets.
parent
5023bd27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
test/assets/LibriSpeech/dev-clean/1272/128104/1272-128104.trans.txt
...s/LibriSpeech/dev-clean/1272/128104/1272-128104.trans.txt
+1
-1
test/test_datasets.py
test/test_datasets.py
+4
-1
torchaudio/datasets/librispeech.py
torchaudio/datasets/librispeech.py
+7
-4
No files found.
test/assets/LibriSpeech/dev-clean/1272/128104/1272-128104.trans.txt
View file @
d88c2449
1272-128104-0000
THIS IS A TEST.
1272-128104-0000
MISTER QUILTER
test/test_datasets.py
View file @
d88c2449
...
...
@@ -7,9 +7,12 @@ from torchaudio.datasets.utils import DiskCache
from
torchaudio.datasets.vctk
import
VCTK
from
torchaudio.datasets.yesno
import
YESNO
import
common_utils
class
TestDatasets
(
unittest
.
TestCase
):
path
=
"assets"
test_dirpath
,
test_dir
=
common_utils
.
create_temp_assets_dir
()
path
=
os
.
path
.
join
(
test_dirpath
,
"assets"
)
def
test_yesno
(
self
):
data
=
YESNO
(
self
.
path
,
return_dict
=
True
)
...
...
torchaudio/datasets/librispeech.py
View file @
d88c2449
import
os
import
torchaudio
from
torch.utils.data
import
Dataset
import
torchaudio
from
torchaudio.datasets.utils
import
(
download_url
,
extract_archive
,
...
...
@@ -19,7 +20,9 @@ def load_librispeech_item(fileid, path, ext_audio, ext_txt):
file_text
=
speaker
+
"-"
+
chapter
+
ext_txt
file_text
=
os
.
path
.
join
(
path
,
speaker
,
chapter
,
file_text
)
file_audio
=
speaker
+
"-"
+
chapter
+
"-"
+
utterance
+
ext_audio
fileid_audio
=
speaker
+
"-"
+
chapter
+
"-"
+
utterance
file_audio
=
fileid_audio
+
ext_audio
file_audio
=
os
.
path
.
join
(
path
,
speaker
,
chapter
,
file_audio
)
# Load audio
...
...
@@ -28,11 +31,11 @@ def load_librispeech_item(fileid, path, ext_audio, ext_txt):
# Load text
for
line
in
open
(
file_text
):
fileid_text
,
content
=
line
.
strip
().
split
(
" "
,
1
)
if
file_audio
==
fileid_text
:
if
file
id
_audio
==
fileid_text
:
break
else
:
# Translation not found
raise
ValueError
raise
FileNotFoundError
(
"Translation not found for "
+
fileid_audio
)
return
{
"speaker_id"
:
speaker
,
...
...
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