Datasets:
Update dataset script to provide paths to audio files
Browse files- the-mc-speech-dataset.py +15 -5
the-mc-speech-dataset.py
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
# coding=utf-8
|
|
|
|
|
|
|
2 |
|
3 |
import datasets
|
4 |
|
@@ -34,7 +37,7 @@ class MCSpeech(datasets.GeneratorBasedBuilder):
|
|
34 |
description=_DESCRIPTION,
|
35 |
features=datasets.Features(
|
36 |
{
|
37 |
-
"
|
38 |
"transcript": datasets.Value("string"),
|
39 |
},
|
40 |
),
|
@@ -48,20 +51,27 @@ class MCSpeech(datasets.GeneratorBasedBuilder):
|
|
48 |
transcripts_path = dl_manager.download_and_extract(
|
49 |
"https://huggingface.co/datasets/czyzi0/the-mc-speech-dataset/raw/main/transcripts.tsv"
|
50 |
)
|
|
|
|
|
|
|
51 |
return [
|
52 |
datasets.SplitGenerator(
|
53 |
name="train",
|
54 |
-
gen_kwargs={"transcripts_path": transcripts_path}
|
55 |
)
|
56 |
]
|
57 |
|
58 |
-
def _generate_examples(self, transcripts_path):
|
|
|
59 |
with open(transcripts_path, "r") as fh:
|
60 |
header = next(fh).strip().split("\t")
|
61 |
for item_idx, line in enumerate(fh):
|
62 |
line = line.strip().split("\t")
|
|
|
|
|
|
|
63 |
item = {
|
64 |
-
"
|
65 |
-
"transcript":
|
66 |
}
|
67 |
yield item_idx, item
|
|
|
1 |
# coding=utf-8
|
2 |
+
"""The MC Speech Dataset"""
|
3 |
+
|
4 |
+
import pathlib
|
5 |
|
6 |
import datasets
|
7 |
|
|
|
37 |
description=_DESCRIPTION,
|
38 |
features=datasets.Features(
|
39 |
{
|
40 |
+
"wav_path": datasets.Value("string"),
|
41 |
"transcript": datasets.Value("string"),
|
42 |
},
|
43 |
),
|
|
|
51 |
transcripts_path = dl_manager.download_and_extract(
|
52 |
"https://huggingface.co/datasets/czyzi0/the-mc-speech-dataset/raw/main/transcripts.tsv"
|
53 |
)
|
54 |
+
wavs_path = dl_manager.download_and_extract(
|
55 |
+
"https://huggingface.co/datasets/czyzi0/the-mc-speech-dataset/resolve/main/wavs.tar.gz"
|
56 |
+
)
|
57 |
return [
|
58 |
datasets.SplitGenerator(
|
59 |
name="train",
|
60 |
+
gen_kwargs={"transcripts_path": transcripts_path, "wavs_path": wavs_path}
|
61 |
)
|
62 |
]
|
63 |
|
64 |
+
def _generate_examples(self, transcripts_path, wavs_path):
|
65 |
+
wavs_path = pathlib.Path(wavs_path)
|
66 |
with open(transcripts_path, "r") as fh:
|
67 |
header = next(fh).strip().split("\t")
|
68 |
for item_idx, line in enumerate(fh):
|
69 |
line = line.strip().split("\t")
|
70 |
+
id_ = line[header.index("id")]
|
71 |
+
wav_path = wavs_path / f"{id_}.wav"
|
72 |
+
transcript = line[header.index("transcript")]
|
73 |
item = {
|
74 |
+
"wav_path": str(wav_path.absolute()),
|
75 |
+
"transcript": transcript,
|
76 |
}
|
77 |
yield item_idx, item
|