Datasets:
Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- dataset_infos.json +1 -1
- librispeech_asr.py +45 -26
dataset_infos.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"clean": {"description": "LibriSpeech is a corpus of approximately 1000 hours of read English speech with sampling rate of 16 kHz,\nprepared by Vassil Panayotov with the assistance of Daniel Povey. The data is derived from read\naudiobooks from the LibriVox project, and has been carefully segmented and aligned.87\n\nNote that in order to limit the required storage for preparing this dataset, the audio\nis stored in the .flac format and is not converted to a float32 array. To convert, the audio\nfile to a float32 array, please make use of the `.map()` function as follows:\n\n\n```python\nimport soundfile as sf\n\ndef map_to_array(batch):\n speech_array, _ = sf.read(batch[\"file\"])\n batch[\"speech\"] = speech_array\n return batch\n\ndataset = dataset.map(map_to_array, remove_columns=[\"file\"])\n", "citation": "@inproceedings{panayotov2015librispeech,\n title={Librispeech: an ASR corpus based on public domain audio books},\n author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},\n booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},\n pages={5206--5210},\n year={2015},\n organization={IEEE}\n}\n", "homepage": "http://www.openslr.org/12", "license": "", "features": {"file": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "speaker_id": {"dtype": "int64", "id": null, "_type": "Value"}, "chapter_id": {"dtype": "int64", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": {"input": "
|
|
|
1 |
+
{"clean": {"description": "LibriSpeech is a corpus of approximately 1000 hours of read English speech with sampling rate of 16 kHz,\nprepared by Vassil Panayotov with the assistance of Daniel Povey. The data is derived from read\naudiobooks from the LibriVox project, and has been carefully segmented and aligned.87\n\nNote that in order to limit the required storage for preparing this dataset, the audio\nis stored in the .flac format and is not converted to a float32 array. To convert, the audio\nfile to a float32 array, please make use of the `.map()` function as follows:\n\n\n```python\nimport soundfile as sf\n\ndef map_to_array(batch):\n speech_array, _ = sf.read(batch[\"file\"])\n batch[\"speech\"] = speech_array\n return batch\n\ndataset = dataset.map(map_to_array, remove_columns=[\"file\"])\n```\n", "citation": "@inproceedings{panayotov2015librispeech,\n title={Librispeech: an ASR corpus based on public domain audio books},\n author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},\n booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},\n pages={5206--5210},\n year={2015},\n organization={IEEE}\n}\n", "homepage": "http://www.openslr.org/12", "license": "", "features": {"file": {"dtype": "string", "id": null, "_type": "Value"}, "audio": {"sampling_rate": 16000, "mono": true, "_storage_dtype": "struct", "id": null, "_type": "Audio"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "speaker_id": {"dtype": "int64", "id": null, "_type": "Value"}, "chapter_id": {"dtype": "int64", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": {"input": "file", "output": "text"}, "task_templates": [{"task": "automatic-speech-recognition", "audio_file_path_column": "file", "transcription_column": "text"}], "builder_name": "librispeech_asr", "config_name": "clean", "version": {"version_str": "2.1.0", "description": "", "major": 2, "minor": 1, "patch": 0}, "splits": {"train.100": {"name": "train.100", "num_bytes": 6619683041, "num_examples": 28539, "dataset_name": "librispeech_asr"}, "train.360": {"name": "train.360", "num_bytes": 23898214592, "num_examples": 104014, "dataset_name": "librispeech_asr"}, "validation": {"name": "validation", "num_bytes": 359572231, "num_examples": 2703, "dataset_name": "librispeech_asr"}, "test": {"name": "test", "num_bytes": 367705423, "num_examples": 2620, "dataset_name": "librispeech_asr"}}, "download_checksums": {"http://www.openslr.org/resources/12/dev-clean.tar.gz": {"num_bytes": 337926286, "checksum": "76f87d090650617fca0cac8f88b9416e0ebf80350acb97b343a85fa903728ab3"}, "http://www.openslr.org/resources/12/test-clean.tar.gz": {"num_bytes": 346663984, "checksum": "39fde525e59672dc6d1551919b1478f724438a95aa55f874b576be21967e6c23"}, "http://www.openslr.org/resources/12/train-clean-100.tar.gz": {"num_bytes": 6387309499, "checksum": "d4ddd1d5a6ab303066f14971d768ee43278a5f2a0aa43dc716b0e64ecbbbf6e2"}, "http://www.openslr.org/resources/12/train-clean-360.tar.gz": {"num_bytes": 23049477885, "checksum": "146a56496217e96c14334a160df97fffedd6e0a04e66b9c5af0d40be3c792ecf"}}, "download_size": 30121377654, "post_processing_size": null, "dataset_size": 31245175287, "size_in_bytes": 61366552941}, "other": {"description": "LibriSpeech is a corpus of approximately 1000 hours of read English speech with sampling rate of 16 kHz,\nprepared by Vassil Panayotov with the assistance of Daniel Povey. The data is derived from read\naudiobooks from the LibriVox project, and has been carefully segmented and aligned.87\n\nNote that in order to limit the required storage for preparing this dataset, the audio\nis stored in the .flac format and is not converted to a float32 array. To convert, the audio\nfile to a float32 array, please make use of the `.map()` function as follows:\n\n\n```python\nimport soundfile as sf\n\ndef map_to_array(batch):\n speech_array, _ = sf.read(batch[\"file\"])\n batch[\"speech\"] = speech_array\n return batch\n\ndataset = dataset.map(map_to_array, remove_columns=[\"file\"])\n```\n", "citation": "@inproceedings{panayotov2015librispeech,\n title={Librispeech: an ASR corpus based on public domain audio books},\n author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},\n booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},\n pages={5206--5210},\n year={2015},\n organization={IEEE}\n}\n", "homepage": "http://www.openslr.org/12", "license": "", "features": {"file": {"dtype": "string", "id": null, "_type": "Value"}, "audio": {"sampling_rate": 16000, "mono": true, "_storage_dtype": "struct", "id": null, "_type": "Audio"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "speaker_id": {"dtype": "int64", "id": null, "_type": "Value"}, "chapter_id": {"dtype": "int64", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": {"input": "file", "output": "text"}, "task_templates": [{"task": "automatic-speech-recognition", "audio_file_path_column": "file", "transcription_column": "text"}], "builder_name": "librispeech_asr", "config_name": "other", "version": {"version_str": "2.1.0", "description": "", "major": 2, "minor": 1, "patch": 0}, "splits": {"train.500": {"name": "train.500", "num_bytes": 31810256902, "num_examples": 148688, "dataset_name": "librispeech_asr"}, "validation": {"name": "validation", "num_bytes": 337283304, "num_examples": 2864, "dataset_name": "librispeech_asr"}, "test": {"name": "test", "num_bytes": 352396474, "num_examples": 2939, "dataset_name": "librispeech_asr"}}, "download_checksums": {"http://www.openslr.org/resources/12/test-other.tar.gz": {"num_bytes": 328757843, "checksum": "d09c181bba5cf717b3dee7d4d592af11a3ee3a09e08ae025c5506f6ebe961c29"}, "http://www.openslr.org/resources/12/dev-other.tar.gz": {"num_bytes": 314305928, "checksum": "12661c48e8c3fe1de2c1caa4c3e135193bfb1811584f11f569dd12645aa84365"}, "http://www.openslr.org/resources/12/train-other-500.tar.gz": {"num_bytes": 30593501606, "checksum": "ddb22f27f96ec163645d53215559df6aa36515f26e01dd70798188350adcb6d2"}}, "download_size": 31236565377, "post_processing_size": null, "dataset_size": 32499936680, "size_in_bytes": 63736502057}}
|
librispeech_asr.py
CHANGED
@@ -17,9 +17,6 @@
|
|
17 |
"""Librispeech automatic speech recognition dataset."""
|
18 |
|
19 |
|
20 |
-
import glob
|
21 |
-
import os
|
22 |
-
|
23 |
import datasets
|
24 |
from datasets.tasks import AutomaticSpeechRecognition
|
25 |
|
@@ -93,6 +90,7 @@ class LibrispeechASRConfig(datasets.BuilderConfig):
|
|
93 |
class LibrispeechASR(datasets.GeneratorBasedBuilder):
|
94 |
"""Librispeech dataset."""
|
95 |
|
|
|
96 |
BUILDER_CONFIGS = [
|
97 |
LibrispeechASRConfig(name="clean", description="'Clean' speech."),
|
98 |
LibrispeechASRConfig(name="other", description="'Other', more challenging, speech."),
|
@@ -118,41 +116,62 @@ class LibrispeechASR(datasets.GeneratorBasedBuilder):
|
|
118 |
)
|
119 |
|
120 |
def _split_generators(self, dl_manager):
|
121 |
-
archive_path = dl_manager.
|
122 |
|
123 |
if self.config.name == "clean":
|
124 |
train_splits = [
|
125 |
-
datasets.SplitGenerator(
|
126 |
-
|
|
|
|
|
|
|
|
|
127 |
]
|
128 |
elif self.config.name == "other":
|
129 |
train_splits = [
|
130 |
-
datasets.SplitGenerator(
|
|
|
|
|
131 |
]
|
132 |
|
133 |
return train_splits + [
|
134 |
-
datasets.SplitGenerator(
|
135 |
-
|
|
|
|
|
|
|
|
|
136 |
]
|
137 |
|
138 |
-
def _generate_examples(self,
|
139 |
"""Generate examples from a LibriSpeech archive_path."""
|
140 |
-
transcripts_glob = os.path.join(archive_path, "LibriSpeech", "*/*/*/*.txt")
|
141 |
key = 0
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
145 |
for line in f:
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
key += 1
|
|
|
|
|
|
17 |
"""Librispeech automatic speech recognition dataset."""
|
18 |
|
19 |
|
|
|
|
|
|
|
20 |
import datasets
|
21 |
from datasets.tasks import AutomaticSpeechRecognition
|
22 |
|
|
|
90 |
class LibrispeechASR(datasets.GeneratorBasedBuilder):
|
91 |
"""Librispeech dataset."""
|
92 |
|
93 |
+
DEFAULT_WRITER_BATCH_SIZE = 256
|
94 |
BUILDER_CONFIGS = [
|
95 |
LibrispeechASRConfig(name="clean", description="'Clean' speech."),
|
96 |
LibrispeechASRConfig(name="other", description="'Other', more challenging, speech."),
|
|
|
116 |
)
|
117 |
|
118 |
def _split_generators(self, dl_manager):
|
119 |
+
archive_path = dl_manager.download(_DL_URLS[self.config.name])
|
120 |
|
121 |
if self.config.name == "clean":
|
122 |
train_splits = [
|
123 |
+
datasets.SplitGenerator(
|
124 |
+
name="train.100", gen_kwargs={"files": dl_manager.iter_archive(archive_path["train.100"])}
|
125 |
+
),
|
126 |
+
datasets.SplitGenerator(
|
127 |
+
name="train.360", gen_kwargs={"files": dl_manager.iter_archive(archive_path["train.360"])}
|
128 |
+
),
|
129 |
]
|
130 |
elif self.config.name == "other":
|
131 |
train_splits = [
|
132 |
+
datasets.SplitGenerator(
|
133 |
+
name="train.500", gen_kwargs={"files": dl_manager.iter_archive(archive_path["train.500"])}
|
134 |
+
),
|
135 |
]
|
136 |
|
137 |
return train_splits + [
|
138 |
+
datasets.SplitGenerator(
|
139 |
+
name=datasets.Split.VALIDATION, gen_kwargs={"files": dl_manager.iter_archive(archive_path["dev"])}
|
140 |
+
),
|
141 |
+
datasets.SplitGenerator(
|
142 |
+
name=datasets.Split.TEST, gen_kwargs={"files": dl_manager.iter_archive(archive_path["test"])}
|
143 |
+
),
|
144 |
]
|
145 |
|
146 |
+
def _generate_examples(self, files):
|
147 |
"""Generate examples from a LibriSpeech archive_path."""
|
|
|
148 |
key = 0
|
149 |
+
audio_data = {}
|
150 |
+
transcripts = []
|
151 |
+
for path, f in files:
|
152 |
+
if path.endswith(".flac"):
|
153 |
+
id_ = path.split("/")[-1][: -len(".flac")]
|
154 |
+
audio_data[id_] = f.read()
|
155 |
+
elif path.endswith(".trans.txt"):
|
156 |
for line in f:
|
157 |
+
if line:
|
158 |
+
line = line.decode("utf-8").strip()
|
159 |
+
id_, transcript = line.split(" ", 1)
|
160 |
+
audio_file = f"{id_}.flac"
|
161 |
+
speaker_id, chapter_id = [int(el) for el in id_.split("-")[:2]]
|
162 |
+
transcripts.append(
|
163 |
+
{
|
164 |
+
"id": id_,
|
165 |
+
"speaker_id": speaker_id,
|
166 |
+
"chapter_id": chapter_id,
|
167 |
+
"file": audio_file,
|
168 |
+
"text": transcript,
|
169 |
+
}
|
170 |
+
)
|
171 |
+
if audio_data and len(audio_data) == len(transcripts):
|
172 |
+
for transcript in transcripts:
|
173 |
+
audio = {"path": transcript["file"], "bytes": audio_data[transcript["id"]]}
|
174 |
+
yield key, {"audio": audio, **transcript}
|
175 |
key += 1
|
176 |
+
audio_data = {}
|
177 |
+
transcripts = []
|