Splend1dchan commited on
Commit
52e0a14
1 Parent(s): 09ea628

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +305 -0
  2. dataset_infos.json +1 -0
  3. librispeech_asr.py +292 -0
README.md ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: LibriSpeech
3
+ annotations_creators:
4
+ - expert-generated
5
+ language_creators:
6
+ - crowdsourced
7
+ - expert-generated
8
+ language:
9
+ - en
10
+ license:
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
+ - speaker-identification
24
+ dataset_info:
25
+ - config_name: clean
26
+ features:
27
+ - name: file
28
+ dtype: string
29
+ - name: audio
30
+ dtype:
31
+ audio:
32
+ sampling_rate: 16000
33
+ - name: text
34
+ dtype: string
35
+ - name: speaker_id
36
+ dtype: int64
37
+ - name: chapter_id
38
+ dtype: int64
39
+ - name: id
40
+ dtype: string
41
+ splits:
42
+ - name: train.100
43
+ num_bytes: 6619683041
44
+ num_examples: 28539
45
+ - name: train.360
46
+ num_bytes: 23898214592
47
+ num_examples: 104014
48
+ - name: validation
49
+ num_bytes: 359572231
50
+ num_examples: 2703
51
+ - name: test
52
+ num_bytes: 367705423
53
+ num_examples: 2620
54
+ download_size: 30121377654
55
+ dataset_size: 31245175287
56
+ - config_name: other
57
+ features:
58
+ - name: file
59
+ dtype: string
60
+ - name: audio
61
+ dtype:
62
+ audio:
63
+ sampling_rate: 16000
64
+ - name: text
65
+ dtype: string
66
+ - name: speaker_id
67
+ dtype: int64
68
+ - name: chapter_id
69
+ dtype: int64
70
+ - name: id
71
+ dtype: string
72
+ splits:
73
+ - name: train.500
74
+ num_bytes: 31810256902
75
+ num_examples: 148688
76
+ - name: validation
77
+ num_bytes: 337283304
78
+ num_examples: 2864
79
+ - name: test
80
+ num_bytes: 352396474
81
+ num_examples: 2939
82
+ download_size: 31236565377
83
+ dataset_size: 32499936680
84
+ - config_name: all
85
+ features:
86
+ - name: file
87
+ dtype: string
88
+ - name: audio
89
+ dtype:
90
+ audio:
91
+ sampling_rate: 16000
92
+ - name: text
93
+ dtype: string
94
+ - name: speaker_id
95
+ dtype: int64
96
+ - name: chapter_id
97
+ dtype: int64
98
+ - name: id
99
+ dtype: string
100
+ splits:
101
+ - name: train.clean.100
102
+ num_bytes: 6627791685
103
+ num_examples: 28539
104
+ - name: train.clean.360
105
+ num_bytes: 23927767570
106
+ num_examples: 104014
107
+ - name: train.other.500
108
+ num_bytes: 31852502880
109
+ num_examples: 148688
110
+ - name: validation.clean
111
+ num_bytes: 359505691
112
+ num_examples: 2703
113
+ - name: validation.other
114
+ num_bytes: 337213112
115
+ num_examples: 2864
116
+ - name: test.clean
117
+ num_bytes: 368449831
118
+ num_examples: 2620
119
+ - name: test.other
120
+ num_bytes: 353231518
121
+ num_examples: 2939
122
+ download_size: 61357943031
123
+ dataset_size: 63826462287
124
+ ---
125
+
126
+ # Dataset Card for librispeech_asr
127
+
128
+ ## Table of Contents
129
+ - [Dataset Description](#dataset-description)
130
+ - [Dataset Summary](#dataset-summary)
131
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
132
+ - [Languages](#languages)
133
+ - [Dataset Structure](#dataset-structure)
134
+ - [Data Instances](#data-instances)
135
+ - [Data Fields](#data-fields)
136
+ - [Data Splits](#data-splits)
137
+ - [Dataset Creation](#dataset-creation)
138
+ - [Curation Rationale](#curation-rationale)
139
+ - [Source Data](#source-data)
140
+ - [Annotations](#annotations)
141
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
142
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
143
+ - [Social Impact of Dataset](#social-impact-of-dataset)
144
+ - [Discussion of Biases](#discussion-of-biases)
145
+ - [Other Known Limitations](#other-known-limitations)
146
+ - [Additional Information](#additional-information)
147
+ - [Dataset Curators](#dataset-curators)
148
+ - [Licensing Information](#licensing-information)
149
+ - [Citation Information](#citation-information)
150
+ - [Contributions](#contributions)
151
+
152
+ ## Dataset Description
153
+
154
+ - **Homepage:** [LibriSpeech ASR corpus](http://www.openslr.org/12)
155
+ - **Repository:** [Needs More Information]
156
+ - **Paper:** [LibriSpeech: An ASR Corpus Based On Public Domain Audio Books](https://www.danielpovey.com/files/2015_icassp_librispeech.pdf)
157
+ - **Leaderboard:** [The 🤗 Speech Bench](https://huggingface.co/spaces/huggingface/hf-speech-bench)
158
+ - **Point of Contact:** [Daniel Povey](mailto:dpovey@gmail.com)
159
+
160
+ ### Dataset Summary
161
+
162
+ 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.
163
+
164
+ ### Supported Tasks and Leaderboards
165
+
166
+ - `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 Hugging Face leaderboard which can be found at https://huggingface.co/spaces/huggingface/hf-speech-bench. The leaderboard ranks models uploaded to the Hub based on their WER. An external leaderboard at https://paperswithcode.com/sota/speech-recognition-on-librispeech-test-clean ranks the latest models from research and academia.
167
+
168
+ ### Languages
169
+
170
+ The audio is in English. There are two configurations: `clean` and `other`.
171
+ The speakers in the corpus were ranked according to the WER of the transcripts of a model trained on
172
+ a different dataset, and were divided roughly in the middle,
173
+ with the lower-WER speakers designated as "clean" and the higher WER speakers designated as "other".
174
+
175
+ ## Dataset Structure
176
+
177
+ ### Data Instances
178
+
179
+ 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.
180
+
181
+ ```
182
+ {'chapter_id': 141231,
183
+ 'file': '/home/patrick/.cache/huggingface/datasets/downloads/extracted/b7ded9969e09942ab65313e691e6fc2e12066192ee8527e21d634aca128afbe2/dev_clean/1272/141231/1272-141231-0000.flac',
184
+ 'audio': {'path': '/home/patrick/.cache/huggingface/datasets/downloads/extracted/b7ded9969e09942ab65313e691e6fc2e12066192ee8527e21d634aca128afbe2/dev_clean/1272/141231/1272-141231-0000.flac',
185
+ 'array': array([-0.00048828, -0.00018311, -0.00137329, ..., 0.00079346,
186
+ 0.00091553, 0.00085449], dtype=float32),
187
+ 'sampling_rate': 16000},
188
+ 'id': '1272-141231-0000',
189
+ 'speaker_id': 1272,
190
+ 'text': 'A MAN SAID TO THE UNIVERSE SIR I EXIST'}
191
+ ```
192
+
193
+
194
+ ### Data Fields
195
+
196
+ - file: A path to the downloaded audio file in .flac format.
197
+
198
+ - 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]`.
199
+
200
+ - text: the transcription of the audio file.
201
+
202
+ - id: unique id of the data sample.
203
+
204
+ - speaker_id: unique id of the speaker. The same speaker id can be found for multiple data samples.
205
+
206
+ - chapter_id: id of the audiobook chapter which includes the transcription.
207
+
208
+ ### Data Splits
209
+
210
+ The size of the corpus makes it impractical, or at least inconvenient
211
+ for some users, to distribute it as a single large archive. Thus the
212
+ training portion of the corpus is split into three subsets, with approximate size 100, 360 and 500 hours respectively.
213
+ A simple automatic
214
+ procedure was used to select the audio in the first two sets to be, on
215
+ average, of higher recording quality and with accents closer to US
216
+ English. An acoustic model was trained on WSJ’s si-84 data subset
217
+ and was used to recognize the audio in the corpus, using a bigram
218
+ LM estimated on the text of the respective books. We computed the
219
+ Word Error Rate (WER) of this automatic transcript relative to our
220
+ reference transcripts obtained from the book texts.
221
+ The speakers in the corpus were ranked according to the WER of
222
+ the WSJ model’s transcripts, and were divided roughly in the middle,
223
+ with the lower-WER speakers designated as "clean" and the higher-WER speakers designated as "other".
224
+
225
+ For "clean", the data is split into train, validation, and test set. The train set is further split into train.100 and train.360
226
+ respectively accounting for 100h and 360h of the training data.
227
+ For "other", the data is split into train, validation, and test set. The train set contains approximately 500h of recorded speech.
228
+
229
+ | | Train.500 | Train.360 | Train.100 | Valid | Test |
230
+ | ----- | ------ | ----- | ---- | ---- | ---- |
231
+ | clean | - | 104014 | 28539 | 2703 | 2620|
232
+ | other | 148688 | - | - | 2864 | 2939 |
233
+
234
+
235
+
236
+ ## Dataset Creation
237
+
238
+ ### Curation Rationale
239
+
240
+ [Needs More Information]
241
+
242
+ ### Source Data
243
+
244
+ #### Initial Data Collection and Normalization
245
+
246
+ [Needs More Information]
247
+
248
+ #### Who are the source language producers?
249
+
250
+ [Needs More Information]
251
+
252
+ ### Annotations
253
+
254
+ #### Annotation process
255
+
256
+ [Needs More Information]
257
+
258
+ #### Who are the annotators?
259
+
260
+ [Needs More Information]
261
+
262
+ ### Personal and Sensitive Information
263
+
264
+ 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.
265
+
266
+ ## Considerations for Using the Data
267
+
268
+ ### Social Impact of Dataset
269
+
270
+ [More Information Needed]
271
+
272
+ ### Discussion of Biases
273
+
274
+ [More Information Needed]
275
+
276
+ ### Other Known Limitations
277
+
278
+ [Needs More Information]
279
+
280
+ ## Additional Information
281
+
282
+ ### Dataset Curators
283
+
284
+ The dataset was initially created by Vassil Panayotov, Guoguo Chen, Daniel Povey, and Sanjeev Khudanpur.
285
+
286
+ ### Licensing Information
287
+
288
+ [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
289
+
290
+ ### Citation Information
291
+
292
+ ```
293
+ @inproceedings{panayotov2015librispeech,
294
+ title={Librispeech: an ASR corpus based on public domain audio books},
295
+ author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},
296
+ booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on},
297
+ pages={5206--5210},
298
+ year={2015},
299
+ organization={IEEE}
300
+ }
301
+ ```
302
+
303
+ ### Contributions
304
+
305
+ 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.py ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "validation.clean": {
69
+ "dev.clean": _DL_URL + "dev-clean.tar.gz",
70
+ }
71
+ }
72
+
73
+
74
+ class LibrispeechASRConfig(datasets.BuilderConfig):
75
+ """BuilderConfig for LibriSpeechASR."""
76
+
77
+ def __init__(self, **kwargs):
78
+ """
79
+ Args:
80
+ data_dir: `string`, the path to the folder containing the files in the
81
+ downloaded .tar
82
+ citation: `string`, citation for the data set
83
+ url: `string`, url for information about the data set
84
+ **kwargs: keyword arguments forwarded to super.
85
+ """
86
+ super(LibrispeechASRConfig, self).__init__(version=datasets.Version("2.1.0", ""), **kwargs)
87
+
88
+
89
+ class LibrispeechASR(datasets.GeneratorBasedBuilder):
90
+ """Librispeech dataset."""
91
+
92
+ DEFAULT_WRITER_BATCH_SIZE = 256
93
+ DEFAULT_CONFIG_NAME = "all"
94
+ BUILDER_CONFIGS = [
95
+ LibrispeechASRConfig(name="clean", description="'Clean' speech."),
96
+ LibrispeechASRConfig(name="other", description="'Other', more challenging, speech."),
97
+ LibrispeechASRConfig(name="all", description="Combined clean and other dataset."),
98
+ ]
99
+
100
+ def _info(self):
101
+ return datasets.DatasetInfo(
102
+ description=_DESCRIPTION,
103
+ features=datasets.Features(
104
+ {
105
+ "file": datasets.Value("string"),
106
+ "audio": datasets.Audio(sampling_rate=16_000),
107
+ "text": datasets.Value("string"),
108
+ "speaker_id": datasets.Value("int64"),
109
+ "chapter_id": datasets.Value("int64"),
110
+ "id": datasets.Value("string"),
111
+ }
112
+ ),
113
+ supervised_keys=("file", "text"),
114
+ homepage=_URL,
115
+ citation=_CITATION,
116
+ task_templates=[AutomaticSpeechRecognition(audio_column="audio", transcription_column="text")],
117
+ )
118
+
119
+ def _split_generators(self, dl_manager):
120
+ archive_path = dl_manager.download(_DL_URLS[self.config.name])
121
+ # (Optional) In non-streaming mode, we can extract the archive locally to have actual local audio files:
122
+ local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else {}
123
+
124
+ if self.config.name == "clean":
125
+ train_splits = [
126
+ datasets.SplitGenerator(
127
+ name="train.100",
128
+ gen_kwargs={
129
+ "local_extracted_archive": local_extracted_archive.get("train.100"),
130
+ "files": dl_manager.iter_archive(archive_path["train.100"]),
131
+ },
132
+ ),
133
+ datasets.SplitGenerator(
134
+ name="train.360",
135
+ gen_kwargs={
136
+ "local_extracted_archive": local_extracted_archive.get("train.360"),
137
+ "files": dl_manager.iter_archive(archive_path["train.360"]),
138
+ },
139
+ ),
140
+ ]
141
+ dev_splits = [
142
+ datasets.SplitGenerator(
143
+ name=datasets.Split.VALIDATION,
144
+ gen_kwargs={
145
+ "local_extracted_archive": local_extracted_archive.get("dev"),
146
+ "files": dl_manager.iter_archive(archive_path["dev"]),
147
+ },
148
+ )
149
+ ]
150
+ test_splits = [
151
+ datasets.SplitGenerator(
152
+ name=datasets.Split.TEST,
153
+ gen_kwargs={
154
+ "local_extracted_archive": local_extracted_archive.get("test"),
155
+ "files": dl_manager.iter_archive(archive_path["test"]),
156
+ },
157
+ )
158
+ ]
159
+ elif self.config.name == "other":
160
+ train_splits = [
161
+ datasets.SplitGenerator(
162
+ name="train.500",
163
+ gen_kwargs={
164
+ "local_extracted_archive": local_extracted_archive.get("train.500"),
165
+ "files": dl_manager.iter_archive(archive_path["train.500"]),
166
+ },
167
+ )
168
+ ]
169
+ dev_splits = [
170
+ datasets.SplitGenerator(
171
+ name=datasets.Split.VALIDATION,
172
+ gen_kwargs={
173
+ "local_extracted_archive": local_extracted_archive.get("dev"),
174
+ "files": dl_manager.iter_archive(archive_path["dev"]),
175
+ },
176
+ )
177
+ ]
178
+ test_splits = [
179
+ datasets.SplitGenerator(
180
+ name=datasets.Split.TEST,
181
+ gen_kwargs={
182
+ "local_extracted_archive": local_extracted_archive.get("test"),
183
+ "files": dl_manager.iter_archive(archive_path["test"]),
184
+ },
185
+ )
186
+ ]
187
+ elif self.config.name == "all":
188
+ train_splits = [
189
+ datasets.SplitGenerator(
190
+ name="train.clean.100",
191
+ gen_kwargs={
192
+ "local_extracted_archive": local_extracted_archive.get("train.clean.100"),
193
+ "files": dl_manager.iter_archive(archive_path["train.clean.100"]),
194
+ },
195
+ ),
196
+ datasets.SplitGenerator(
197
+ name="train.clean.360",
198
+ gen_kwargs={
199
+ "local_extracted_archive": local_extracted_archive.get("train.clean.360"),
200
+ "files": dl_manager.iter_archive(archive_path["train.clean.360"]),
201
+ },
202
+ ),
203
+ datasets.SplitGenerator(
204
+ name="train.other.500",
205
+ gen_kwargs={
206
+ "local_extracted_archive": local_extracted_archive.get("train.other.500"),
207
+ "files": dl_manager.iter_archive(archive_path["train.other.500"]),
208
+ },
209
+ ),
210
+ ]
211
+ dev_splits = [
212
+ datasets.SplitGenerator(
213
+ name="validation.clean",
214
+ gen_kwargs={
215
+ "local_extracted_archive": local_extracted_archive.get("dev.clean"),
216
+ "files": dl_manager.iter_archive(archive_path["dev.clean"]),
217
+ },
218
+ ),
219
+ datasets.SplitGenerator(
220
+ name="validation.other",
221
+ gen_kwargs={
222
+ "local_extracted_archive": local_extracted_archive.get("dev.other"),
223
+ "files": dl_manager.iter_archive(archive_path["dev.other"]),
224
+ },
225
+ ),
226
+ ]
227
+ test_splits = [
228
+ datasets.SplitGenerator(
229
+ name="test.clean",
230
+ gen_kwargs={
231
+ "local_extracted_archive": local_extracted_archive.get("test.clean"),
232
+ "files": dl_manager.iter_archive(archive_path["test.clean"]),
233
+ },
234
+ ),
235
+ datasets.SplitGenerator(
236
+ name="test.other",
237
+ gen_kwargs={
238
+ "local_extracted_archive": local_extracted_archive.get("test.other"),
239
+ "files": dl_manager.iter_archive(archive_path["test.other"]),
240
+ },
241
+ ),
242
+ ]
243
+ elif self.config.name == "validation.clean":
244
+ dev_splits = [
245
+ datasets.SplitGenerator(
246
+ name="validation.clean",
247
+ gen_kwargs={
248
+ "local_extracted_archive": local_extracted_archive.get("dev.clean"),
249
+ "files": dl_manager.iter_archive(archive_path["dev.clean"]),
250
+ },
251
+ ),
252
+ ]
253
+
254
+ return train_splits + dev_splits + test_splits
255
+
256
+ def _generate_examples(self, files, local_extracted_archive):
257
+ """Generate examples from a LibriSpeech archive_path."""
258
+ key = 0
259
+ audio_data = {}
260
+ transcripts = []
261
+ for path, f in files:
262
+ if path.endswith(".flac"):
263
+ id_ = path.split("/")[-1][: -len(".flac")]
264
+ audio_data[id_] = f.read()
265
+ elif path.endswith(".trans.txt"):
266
+ for line in f:
267
+ if line:
268
+ line = line.decode("utf-8").strip()
269
+ id_, transcript = line.split(" ", 1)
270
+ audio_file = f"{id_}.flac"
271
+ speaker_id, chapter_id = [int(el) for el in id_.split("-")[:2]]
272
+ audio_file = (
273
+ os.path.join(local_extracted_archive, audio_file)
274
+ if local_extracted_archive
275
+ else audio_file
276
+ )
277
+ transcripts.append(
278
+ {
279
+ "id": id_,
280
+ "speaker_id": speaker_id,
281
+ "chapter_id": chapter_id,
282
+ "file": audio_file,
283
+ "text": transcript,
284
+ }
285
+ )
286
+ if audio_data and len(audio_data) == len(transcripts):
287
+ for transcript in transcripts:
288
+ audio = {"path": transcript["file"], "bytes": audio_data[transcript["id"]]}
289
+ yield key, {"audio": audio, **transcript}
290
+ key += 1
291
+ audio_data = {}
292
+ transcripts = []