Patrick von Platen commited on
Commit
300618c
1 Parent(s): 1121abb
Files changed (3) hide show
  1. README.md +203 -1
  2. dataset_infos.json +1 -0
  3. librispeech_asr_self_contained.py +260 -0
README.md CHANGED
@@ -1,3 +1,205 @@
1
  ---
2
- license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ pretty_name: LibriSpeech
3
+ annotations_creators:
4
+ - expert-generated
5
+ language_creators:
6
+ - crowdsourced
7
+ - expert-generated
8
+ languages:
9
+ - en
10
+ licenses:
11
+ - cc-by-4.0
12
+ multilinguality:
13
+ - monolingual
14
+ paperswithcode_id: librispeech-1
15
+ size_categories:
16
+ - 100K<n<1M
17
+ source_datasets:
18
+ - original
19
+ task_categories:
20
+ - automatic-speech-recognition
21
+ - audio-classification
22
+ task_ids:
23
+ - audio-speaker-identification
24
  ---
25
+
26
+ # Dataset Card for librispeech_asr
27
+
28
+ ## Table of Contents
29
+ - [Dataset Description](#dataset-description)
30
+ - [Dataset Summary](#dataset-summary)
31
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
32
+ - [Languages](#languages)
33
+ - [Dataset Structure](#dataset-structure)
34
+ - [Data Instances](#data-instances)
35
+ - [Data Fields](#data-fields)
36
+ - [Data Splits](#data-splits)
37
+ - [Dataset Creation](#dataset-creation)
38
+ - [Curation Rationale](#curation-rationale)
39
+ - [Source Data](#source-data)
40
+ - [Annotations](#annotations)
41
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
42
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
43
+ - [Social Impact of Dataset](#social-impact-of-dataset)
44
+ - [Discussion of Biases](#discussion-of-biases)
45
+ - [Other Known Limitations](#other-known-limitations)
46
+ - [Additional Information](#additional-information)
47
+ - [Dataset Curators](#dataset-curators)
48
+ - [Licensing Information](#licensing-information)
49
+ - [Citation Information](#citation-information)
50
+ - [Contributions](#contributions)
51
+
52
+ ## Dataset Description
53
+
54
+ - **Homepage:** [LibriSpeech ASR corpus](http://www.openslr.org/12)
55
+ - **Repository:** [Needs More Information]
56
+ - **Paper:** [LibriSpeech: An ASR Corpus Based On Public Domain Audio Books](https://www.danielpovey.com/files/2015_icassp_librispeech.pdf)
57
+ - **Leaderboard:** [Paperswithcode Leaderboard](https://paperswithcode.com/sota/speech-recognition-on-librispeech-test-other)
58
+ - **Point of Contact:** [Daniel Povey](mailto:[email protected])
59
+
60
+ ### Dataset Summary
61
+
62
+ LibriSpeech is a corpus of approximately 1000 hours of 16kHz read English speech, prepared by Vassil Panayotov with the assistance of Daniel Povey. The data is derived from read audiobooks from the LibriVox project, and has been carefully segmented and aligned.
63
+
64
+ ### Supported Tasks and Leaderboards
65
+
66
+ - `automatic-speech-recognition`, `audio-speaker-identification`: The dataset can be used to train a model for Automatic Speech Recognition (ASR). The model is presented with an audio file and asked to transcribe the audio file to written text. The most common evaluation metric is the word error rate (WER). The task has an active leaderboard which can be found at https://paperswithcode.com/sota/speech-recognition-on-librispeech-test-clean and ranks models based on their WER.
67
+
68
+ ### Languages
69
+
70
+ The audio is in English. There are two configurations: `clean` and `other`.
71
+ The speakers in the corpus were ranked according to the WER of the transcripts of a model trained on
72
+ a different dataset, and were divided roughly in the middle,
73
+ with the lower-WER speakers designated as "clean" and the higher WER speakers designated as "other".
74
+
75
+ ## Dataset Structure
76
+
77
+ ### Data Instances
78
+
79
+ A typical data point comprises the path to the audio file, usually called `file` and its transcription, called `text`. Some additional information about the speaker and the passage which contains the transcription is provided.
80
+
81
+ ```
82
+ {'chapter_id': 141231,
83
+ 'file': '/home/patrick/.cache/huggingface/datasets/downloads/extracted/b7ded9969e09942ab65313e691e6fc2e12066192ee8527e21d634aca128afbe2/dev_clean/1272/141231/1272-141231-0000.flac',
84
+ 'audio': {'path': '/home/patrick/.cache/huggingface/datasets/downloads/extracted/b7ded9969e09942ab65313e691e6fc2e12066192ee8527e21d634aca128afbe2/dev_clean/1272/141231/1272-141231-0000.flac',
85
+ 'array': array([-0.00048828, -0.00018311, -0.00137329, ..., 0.00079346,
86
+ 0.00091553, 0.00085449], dtype=float32),
87
+ 'sampling_rate': 16000},
88
+ 'id': '1272-141231-0000',
89
+ 'speaker_id': 1272,
90
+ 'text': 'A MAN SAID TO THE UNIVERSE SIR I EXIST'}
91
+ ```
92
+
93
+
94
+ ### Data Fields
95
+
96
+ - file: A path to the downloaded audio file in .flac format.
97
+
98
+ - audio: A dictionary containing the path to the downloaded audio file, the decoded audio array, and the sampling rate. Note that when accessing the audio column: `dataset[0]["audio"]` the audio file is automatically decoded and resampled to `dataset.features["audio"].sampling_rate`. Decoding and resampling of a large number of audio files might take a significant amount of time. Thus it is important to first query the sample index before the `"audio"` column, *i.e.* `dataset[0]["audio"]` should **always** be preferred over `dataset["audio"][0]`.
99
+
100
+ - text: the transcription of the audio file.
101
+
102
+ - id: unique id of the data sample.
103
+
104
+ - speaker_id: unique id of the speaker. The same speaker id can be found for multiple data samples.
105
+
106
+ - chapter_id: id of the audiobook chapter which includes the transcription.
107
+
108
+ ### Data Splits
109
+
110
+ The size of the corpus makes it impractical, or at least inconvenient
111
+ for some users, to distribute it as a single large archive. Thus the
112
+ training portion of the corpus is split into three subsets, with approximate size 100, 360 and 500 hours respectively.
113
+ A simple automatic
114
+ procedure was used to select the audio in the first two sets to be, on
115
+ average, of higher recording quality and with accents closer to US
116
+ English. An acoustic model was trained on WSJ’s si-84 data subset
117
+ and was used to recognize the audio in the corpus, using a bigram
118
+ LM estimated on the text of the respective books. We computed the
119
+ Word Error Rate (WER) of this automatic transcript relative to our
120
+ reference transcripts obtained from the book texts.
121
+ The speakers in the corpus were ranked according to the WER of
122
+ the WSJ model’s transcripts, and were divided roughly in the middle,
123
+ with the lower-WER speakers designated as "clean" and the higher-WER speakers designated as "other".
124
+
125
+ For "clean", the data is split into train, validation, and test set. The train set is further split into train.100 and train.360
126
+ respectively accounting for 100h and 360h of the training data.
127
+ For "other", the data is split into train, validation, and test set. The train set contains approximately 500h of recorded speech.
128
+
129
+ | | Train.500 | Train.360 | Train.100 | Valid | Test |
130
+ | ----- | ------ | ----- | ---- | ---- | ---- |
131
+ | clean | - | 104014 | 28539 | 2703 | 2620|
132
+ | other | 148688 | - | - | 2864 | 2939 |
133
+
134
+
135
+
136
+ ## Dataset Creation
137
+
138
+ ### Curation Rationale
139
+
140
+ [Needs More Information]
141
+
142
+ ### Source Data
143
+
144
+ #### Initial Data Collection and Normalization
145
+
146
+ [Needs More Information]
147
+
148
+ #### Who are the source language producers?
149
+
150
+ [Needs More Information]
151
+
152
+ ### Annotations
153
+
154
+ #### Annotation process
155
+
156
+ [Needs More Information]
157
+
158
+ #### Who are the annotators?
159
+
160
+ [Needs More Information]
161
+
162
+ ### Personal and Sensitive Information
163
+
164
+ The dataset consists of people who have donated their voice online. You agree to not attempt to determine the identity of speakers in this dataset.
165
+
166
+ ## Considerations for Using the Data
167
+
168
+ ### Social Impact of Dataset
169
+
170
+ [More Information Needed]
171
+
172
+ ### Discussion of Biases
173
+
174
+ [More Information Needed]
175
+
176
+ ### Other Known Limitations
177
+
178
+ [Needs More Information]
179
+
180
+ ## Additional Information
181
+
182
+ ### Dataset Curators
183
+
184
+ The dataset was initially created by Vassil Panayotov, Guoguo Chen, Daniel Povey, and Sanjeev Khudanpur.
185
+
186
+ ### Licensing Information
187
+
188
+ [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
189
+
190
+ ### Citation Information
191
+
192
+ ```
193
+ @inproceedings{panayotov2015librispeech,
194
+ title={Librispeech: an ASR corpus based on public domain audio books},
195
+ author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},
196
+ booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},
197
+ pages={5206--5210},
198
+ year={2015},
199
+ organization={IEEE}
200
+ }
201
+ ```
202
+
203
+ ### Contributions
204
+
205
+ Thanks to [@patrickvonplaten](https://github.com/patrickvonplaten) for adding this dataset.
dataset_infos.json ADDED
@@ -0,0 +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```\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, "decode": true, "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_column": "audio", "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, "decode": true, "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_column": "audio", "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}, "all": {"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", "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, "decode": true, "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_column": "audio", "transcription_column": "text"}], "builder_name": "librispeech_asr", "config_name": "all", "version": {"version_str": "2.1.0", "description": "", "major": 2, "minor": 1, "patch": 0}, "splits": {"train.clean.100": {"name": "train.clean.100", "num_bytes": 6627791685, "num_examples": 28539, "dataset_name": "librispeech_asr"}, "train.clean.360": {"name": "train.clean.360", "num_bytes": 23927767570, "num_examples": 104014, "dataset_name": "librispeech_asr"}, "train.other.500": {"name": "train.other.500", "num_bytes": 31852502880, "num_examples": 148688, "dataset_name": "librispeech_asr"}, "validation.clean": {"name": "validation.clean", "num_bytes": 359505691, "num_examples": 2703, "dataset_name": "librispeech_asr"}, "validation.other": {"name": "validation.other", "num_bytes": 337213112, "num_examples": 2864, "dataset_name": "librispeech_asr"}, "test.clean": {"name": "test.clean", "num_bytes": 368449831, "num_examples": 2620, "dataset_name": "librispeech_asr"}, "test.other": {"name": "test.other", "num_bytes": 353231518, "num_examples": 2939, "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/dev-other.tar.gz": {"num_bytes": 314305928, "checksum": "12661c48e8c3fe1de2c1caa4c3e135193bfb1811584f11f569dd12645aa84365"}, "http://www.openslr.org/resources/12/test-clean.tar.gz": {"num_bytes": 346663984, "checksum": "39fde525e59672dc6d1551919b1478f724438a95aa55f874b576be21967e6c23"}, "http://www.openslr.org/resources/12/test-other.tar.gz": {"num_bytes": 328757843, "checksum": "d09c181bba5cf717b3dee7d4d592af11a3ee3a09e08ae025c5506f6ebe961c29"}, "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"}, "http://www.openslr.org/resources/12/train-other-500.tar.gz": {"num_bytes": 30593501606, "checksum": "ddb22f27f96ec163645d53215559df6aa36515f26e01dd70798188350adcb6d2"}}, "download_size": 61357943031, "post_processing_size": null, "dataset_size": 63826462287, "size_in_bytes": 125184405318}}
librispeech_asr_self_contained.py ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2021 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """Librispeech automatic speech recognition dataset."""
18
+
19
+
20
+ import os
21
+
22
+ import datasets
23
+ from datasets.tasks import AutomaticSpeechRecognition
24
+
25
+
26
+ _CITATION = """\
27
+ @inproceedings{panayotov2015librispeech,
28
+ title={Librispeech: an ASR corpus based on public domain audio books},
29
+ author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},
30
+ booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},
31
+ pages={5206--5210},
32
+ year={2015},
33
+ organization={IEEE}
34
+ }
35
+ """
36
+
37
+ _DESCRIPTION = """\
38
+ LibriSpeech is a corpus of approximately 1000 hours of read English speech with sampling rate of 16 kHz,
39
+ prepared by Vassil Panayotov with the assistance of Daniel Povey. The data is derived from read
40
+ audiobooks from the LibriVox project, and has been carefully segmented and aligned.87
41
+ """
42
+
43
+ _URL = "http://www.openslr.org/12"
44
+ _DL_URL = "http://www.openslr.org/resources/12/"
45
+
46
+
47
+ _DL_URLS = {
48
+ "clean": {
49
+ "dev": _DL_URL + "dev-clean.tar.gz",
50
+ "test": _DL_URL + "test-clean.tar.gz",
51
+ "train.100": _DL_URL + "train-clean-100.tar.gz",
52
+ "train.360": _DL_URL + "train-clean-360.tar.gz",
53
+ },
54
+ "other": {
55
+ "test": _DL_URL + "test-other.tar.gz",
56
+ "dev": _DL_URL + "dev-other.tar.gz",
57
+ "train.500": _DL_URL + "train-other-500.tar.gz",
58
+ },
59
+ "all": {
60
+ "dev.clean": _DL_URL + "dev-clean.tar.gz",
61
+ "dev.other": _DL_URL + "dev-other.tar.gz",
62
+ "test.clean": _DL_URL + "test-clean.tar.gz",
63
+ "test.other": _DL_URL + "test-other.tar.gz",
64
+ "train.clean.100": _DL_URL + "train-clean-100.tar.gz",
65
+ "train.clean.360": _DL_URL + "train-clean-360.tar.gz",
66
+ "train.other.500": _DL_URL + "train-other-500.tar.gz",
67
+ },
68
+ }
69
+
70
+
71
+ class LibrispeechASRConfig(datasets.BuilderConfig):
72
+ """BuilderConfig for LibriSpeechASR."""
73
+
74
+ def __init__(self, **kwargs):
75
+ """
76
+ Args:
77
+ data_dir: `string`, the path to the folder containing the files in the
78
+ downloaded .tar
79
+ citation: `string`, citation for the data set
80
+ url: `string`, url for information about the data set
81
+ **kwargs: keyword arguments forwarded to super.
82
+ """
83
+ super(LibrispeechASRConfig, self).__init__(version=datasets.Version("2.1.0", ""), **kwargs)
84
+
85
+
86
+ class LibrispeechASR(datasets.GeneratorBasedBuilder):
87
+ """Librispeech dataset."""
88
+
89
+ DEFAULT_WRITER_BATCH_SIZE = 256
90
+ DEFAULT_CONFIG_NAME = "all"
91
+ BUILDER_CONFIGS = [
92
+ LibrispeechASRConfig(name="clean", description="'Clean' speech."),
93
+ LibrispeechASRConfig(name="other", description="'Other', more challenging, speech."),
94
+ LibrispeechASRConfig(name="all", description="Combined clean and other dataset."),
95
+ ]
96
+
97
+ def _info(self):
98
+ return datasets.DatasetInfo(
99
+ description=_DESCRIPTION,
100
+ features=datasets.Features(
101
+ {
102
+ "file": datasets.Value("string"),
103
+ "audio": datasets.Audio(sampling_rate=16_000),
104
+ "text": datasets.Value("string"),
105
+ "speaker_id": datasets.Value("int64"),
106
+ "chapter_id": datasets.Value("int64"),
107
+ "id": datasets.Value("string"),
108
+ }
109
+ ),
110
+ supervised_keys=("file", "text"),
111
+ homepage=_URL,
112
+ citation=_CITATION,
113
+ task_templates=[AutomaticSpeechRecognition(audio_column="audio", transcription_column="text")],
114
+ )
115
+
116
+ def _split_generators(self, dl_manager):
117
+ archive_path = dl_manager.download(_DL_URLS[self.config.name])
118
+ # (Optional) In non-streaming mode, we can extract the archive locally to have actual local audio files:
119
+
120
+ if self.config.name == "clean":
121
+ train_splits = [
122
+ datasets.SplitGenerator(
123
+ name="train.100",
124
+ gen_kwargs={
125
+ "files": dl_manager.iter_archive(archive_path["train.100"]),
126
+ },
127
+ ),
128
+ datasets.SplitGenerator(
129
+ name="train.360",
130
+ gen_kwargs={
131
+ "local_extracted_archive": local_extracted_archive.get("train.360"),
132
+ "files": dl_manager.iter_archive(archive_path["train.360"]),
133
+ },
134
+ ),
135
+ ]
136
+ dev_splits = [
137
+ datasets.SplitGenerator(
138
+ name=datasets.Split.VALIDATION,
139
+ gen_kwargs={
140
+ "files": dl_manager.iter_archive(archive_path["dev"]),
141
+ },
142
+ )
143
+ ]
144
+ test_splits = [
145
+ datasets.SplitGenerator(
146
+ name=datasets.Split.TEST,
147
+ gen_kwargs={
148
+ "files": dl_manager.iter_archive(archive_path["test"]),
149
+ },
150
+ )
151
+ ]
152
+ elif self.config.name == "other":
153
+ train_splits = [
154
+ datasets.SplitGenerator(
155
+ name="train.500",
156
+ gen_kwargs={
157
+ "files": dl_manager.iter_archive(archive_path["train.500"]),
158
+ },
159
+ )
160
+ ]
161
+ dev_splits = [
162
+ datasets.SplitGenerator(
163
+ name=datasets.Split.VALIDATION,
164
+ gen_kwargs={
165
+ "files": dl_manager.iter_archive(archive_path["dev"]),
166
+ },
167
+ )
168
+ ]
169
+ test_splits = [
170
+ datasets.SplitGenerator(
171
+ name=datasets.Split.TEST,
172
+ gen_kwargs={
173
+ "files": dl_manager.iter_archive(archive_path["test"]),
174
+ },
175
+ )
176
+ ]
177
+ elif self.config.name == "all":
178
+ train_splits = [
179
+ datasets.SplitGenerator(
180
+ name="train.clean.100",
181
+ gen_kwargs={
182
+ "files": dl_manager.iter_archive(archive_path["train.clean.100"]),
183
+ },
184
+ ),
185
+ datasets.SplitGenerator(
186
+ name="train.clean.360",
187
+ gen_kwargs={
188
+ "files": dl_manager.iter_archive(archive_path["train.clean.360"]),
189
+ },
190
+ ),
191
+ datasets.SplitGenerator(
192
+ name="train.other.500",
193
+ gen_kwargs={
194
+ "files": dl_manager.iter_archive(archive_path["train.other.500"]),
195
+ },
196
+ ),
197
+ ]
198
+ dev_splits = [
199
+ datasets.SplitGenerator(
200
+ name="validation.clean",
201
+ gen_kwargs={
202
+ "files": dl_manager.iter_archive(archive_path["dev.clean"]),
203
+ },
204
+ ),
205
+ datasets.SplitGenerator(
206
+ name="validation.other",
207
+ gen_kwargs={
208
+ "files": dl_manager.iter_archive(archive_path["dev.other"]),
209
+ },
210
+ ),
211
+ ]
212
+ test_splits = [
213
+ datasets.SplitGenerator(
214
+ name="test.clean",
215
+ gen_kwargs={
216
+ "files": dl_manager.iter_archive(archive_path["test.clean"]),
217
+ },
218
+ ),
219
+ datasets.SplitGenerator(
220
+ name="test.other",
221
+ gen_kwargs={
222
+ "files": dl_manager.iter_archive(archive_path["test.other"]),
223
+ },
224
+ ),
225
+ ]
226
+
227
+ return train_splits + dev_splits + test_splits
228
+
229
+ def _generate_examples(self, files):
230
+ """Generate examples from a LibriSpeech archive_path."""
231
+ key = 0
232
+ audio_data = {}
233
+ transcripts = []
234
+ for path, f in files:
235
+ if path.endswith(".flac"):
236
+ id_ = path.split("/")[-1][: -len(".flac")]
237
+ audio_data[id_] = f.read()
238
+ elif path.endswith(".trans.txt"):
239
+ for line in f:
240
+ if line:
241
+ line = line.decode("utf-8").strip()
242
+ id_, transcript = line.split(" ", 1)
243
+ audio_file = f"{id_}.flac"
244
+ speaker_id, chapter_id = [int(el) for el in id_.split("-")[:2]]
245
+ transcripts.append(
246
+ {
247
+ "id": id_,
248
+ "speaker_id": speaker_id,
249
+ "chapter_id": chapter_id,
250
+ "file": audio_file,
251
+ "text": transcript,
252
+ }
253
+ )
254
+ if audio_data and len(audio_data) == len(transcripts):
255
+ for transcript in transcripts:
256
+ audio = {"path": transcript["file"], "bytes": audio_data[transcript["id"]]}
257
+ yield key, {"audio": audio, **transcript}
258
+ key += 1
259
+ audio_data = {}
260
+ transcripts = []