Reihaneh commited on
Commit
5440ac1
·
verified ·
1 Parent(s): dc80153

Upload dataset_loading_script.py

Browse files
Files changed (1) hide show
  1. dataset_loading_script.py +774 -0
dataset_loading_script.py ADDED
@@ -0,0 +1,774 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor.
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
+ """ Common Voice Dataset"""
16
+
17
+
18
+ import os
19
+ import warnings
20
+
21
+ import datasets
22
+ from datasets.tasks import AutomaticSpeechRecognition
23
+
24
+
25
+
26
+ #_DATA_URL = "https://voice-prod-bundler-ee1969a6ce8178826482b88e843c335139bd3fb4.s3.amazonaws.com/cv-corpus-6.1-2020-12-11/{}.tar.gz"
27
+ _DATA_URL = base_url
28
+ _CITATION = """\
29
+ @inproceedings{commonvoice:2020,
30
+ author = {Ardila, R. and Branson, M. and Davis, K. and Henretty, M. and Kohler, M. and Meyer, J. and Morais, R. and Saunders, L. and Tyers, F. M. and Weber, G.},
31
+ title = {Common Voice: A Massively-Multilingual Speech Corpus},
32
+ booktitle = {Proceedings of the 12th Conference on Language Resources and Evaluation (LREC 2020)},
33
+ pages = {4211--4215},
34
+ year = 2020
35
+ }
36
+ """
37
+
38
+ _DESCRIPTION = """\
39
+ Common Voice is Mozilla's initiative to help teach machines how real people speak.
40
+ The dataset currently consists of 7,335 validated hours of speech in 60 languages, but we’re always adding more voices and languages.
41
+ """
42
+
43
+ _HOMEPAGE = "https://commonvoice.mozilla.org/en/datasets"
44
+
45
+ _LICENSE = "https://github.com/common-voice/common-voice/blob/main/LICENSE"
46
+
47
+ _LANGUAGES = {
48
+ "ab": {
49
+ "Language": "Abkhaz",
50
+ "Date": "2020-12-11",
51
+ "Size": "39 MB",
52
+ "Version": "ab_1h_2020-12-11",
53
+ "Validated_Hr_Total": 0.05,
54
+ "Overall_Hr_Total": 1,
55
+ "Number_Of_Voice": 14,
56
+ },
57
+ "ar": {
58
+ "Language": "Arabic",
59
+ "Date": "2020-12-11",
60
+ "Size": "2 GB",
61
+ "Version": "ar_77h_2020-12-11",
62
+ "Validated_Hr_Total": 49,
63
+ "Overall_Hr_Total": 77,
64
+ "Number_Of_Voice": 672,
65
+ },
66
+ "as": {
67
+ "Language": "Assamese",
68
+ "Date": "2020-12-11",
69
+ "Size": "21 MB",
70
+ "Version": "as_0.78h_2020-12-11",
71
+ "Validated_Hr_Total": 0.74,
72
+ "Overall_Hr_Total": 0.78,
73
+ "Number_Of_Voice": 17,
74
+ },
75
+ "br": {
76
+ "Language": "Breton",
77
+ "Date": "2020-12-11",
78
+ "Size": "444 MB",
79
+ "Version": "br_16h_2020-12-11",
80
+ "Validated_Hr_Total": 7,
81
+ "Overall_Hr_Total": 16,
82
+ "Number_Of_Voice": 157,
83
+ },
84
+ "ca": {
85
+ "Language": "Catalan",
86
+ "Date": "2020-12-11",
87
+ "Size": "19 GB",
88
+ "Version": "ca_748h_2020-12-11",
89
+ "Validated_Hr_Total": 623,
90
+ "Overall_Hr_Total": 748,
91
+ "Number_Of_Voice": 5376,
92
+ },
93
+ "cnh": {
94
+ "Language": "Hakha Chin",
95
+ "Date": "2020-12-11",
96
+ "Size": "39 MB",
97
+ "Version": "ab_1h_2020-12-11",
98
+ "Validated_Hr_Total": 0.05,
99
+ "Overall_Hr_Total": 1,
100
+ "Number_Of_Voice": 14,
101
+ },
102
+ "cs": {
103
+ "Language": "Czech",
104
+ "Date": "2020-12-11",
105
+ "Size": "39 MB",
106
+ "Version": "ab_1h_2020-12-11",
107
+ "Validated_Hr_Total": 0.05,
108
+ "Overall_Hr_Total": 1,
109
+ "Number_Of_Voice": 14,
110
+ },
111
+ "cv": {
112
+ "Language": "Chuvash",
113
+ "Date": "2020-12-11",
114
+ "Size": "419 MB",
115
+ "Version": "cv_16h_2020-12-11",
116
+ "Validated_Hr_Total": 4,
117
+ "Overall_Hr_Total": 16,
118
+ "Number_Of_Voice": 92,
119
+ },
120
+ "cy": {
121
+ "Language": "Welsh",
122
+ "Date": "2020-12-11",
123
+ "Size": "3 GB",
124
+ "Version": "cy_124h_2020-12-11",
125
+ "Validated_Hr_Total": 95,
126
+ "Overall_Hr_Total": 124,
127
+ "Number_Of_Voice": 1382,
128
+ },
129
+ "de": {
130
+ "Language": "German",
131
+ "Date": "2020-12-11",
132
+ "Size": "22 GB",
133
+ "Version": "de_836h_2020-12-11",
134
+ "Validated_Hr_Total": 777,
135
+ "Overall_Hr_Total": 836,
136
+ "Number_Of_Voice": 12659,
137
+ },
138
+ "dv": {
139
+ "Language": "Dhivehi",
140
+ "Date": "2020-12-11",
141
+ "Size": "515 MB",
142
+ "Version": "dv_19h_2020-12-11",
143
+ "Validated_Hr_Total": 18,
144
+ "Overall_Hr_Total": 19,
145
+ "Number_Of_Voice": 167,
146
+ },
147
+ "el": {
148
+ "Language": "Greek",
149
+ "Date": "2020-12-11",
150
+ "Size": "364 MB",
151
+ "Version": "el_13h_2020-12-11",
152
+ "Validated_Hr_Total": 6,
153
+ "Overall_Hr_Total": 13,
154
+ "Number_Of_Voice": 118,
155
+ },
156
+ "en": {
157
+ "Language": "English",
158
+ "Date": "2020-12-11",
159
+ "Size": "56 GB",
160
+ "Version": "en_2181h_2020-12-11",
161
+ "Validated_Hr_Total": 1686,
162
+ "Overall_Hr_Total": 2181,
163
+ "Number_Of_Voice": 66173,
164
+ },
165
+ "eo": {
166
+ "Language": "Esperanto",
167
+ "Date": "2020-12-11",
168
+ "Size": "3 GB",
169
+ "Version": "eo_102h_2020-12-11",
170
+ "Validated_Hr_Total": 90,
171
+ "Overall_Hr_Total": 102,
172
+ "Number_Of_Voice": 574,
173
+ },
174
+ "es": {
175
+ "Language": "Spanish",
176
+ "Date": "2020-12-11",
177
+ "Size": "15 GB",
178
+ "Version": "es_579h_2020-12-11",
179
+ "Validated_Hr_Total": 324,
180
+ "Overall_Hr_Total": 579,
181
+ "Number_Of_Voice": 19484,
182
+ },
183
+ "et": {
184
+ "Language": "Estonian",
185
+ "Date": "2020-12-11",
186
+ "Size": "732 MB",
187
+ "Version": "et_27h_2020-12-11",
188
+ "Validated_Hr_Total": 19,
189
+ "Overall_Hr_Total": 27,
190
+ "Number_Of_Voice": 543,
191
+ },
192
+ "eu": {
193
+ "Language": "Basque",
194
+ "Date": "2020-12-11",
195
+ "Size": "3 GB",
196
+ "Version": "eu_131h_2020-12-11",
197
+ "Validated_Hr_Total": 89,
198
+ "Overall_Hr_Total": 131,
199
+ "Number_Of_Voice": 1028,
200
+ },
201
+ "fa": {
202
+ "Language": "Persian",
203
+ "Date": "2020-12-11",
204
+ "Size": "8 GB",
205
+ "Version": "fa_321h_2020-12-11",
206
+ "Validated_Hr_Total": 282,
207
+ "Overall_Hr_Total": 321,
208
+ "Number_Of_Voice": 3655,
209
+ },
210
+ "fi": {
211
+ "Language": "Finnish",
212
+ "Date": "2020-12-11",
213
+ "Size": "48 MB",
214
+ "Version": "fi_1h_2020-12-11",
215
+ "Validated_Hr_Total": 1,
216
+ "Overall_Hr_Total": 1,
217
+ "Number_Of_Voice": 27,
218
+ },
219
+ "fr": {
220
+ "Language": "French",
221
+ "Date": "2020-12-11",
222
+ "Size": "18 GB",
223
+ "Version": "fr_682h_2020-12-11",
224
+ "Validated_Hr_Total": 623,
225
+ "Overall_Hr_Total": 682,
226
+ "Number_Of_Voice": 12953,
227
+ },
228
+ "fy-NL": {
229
+ "Language": "Frisian",
230
+ "Date": "2020-12-11",
231
+ "Size": "1 GB",
232
+ "Version": "fy-NL_46h_2020-12-11",
233
+ "Validated_Hr_Total": 14,
234
+ "Overall_Hr_Total": 46,
235
+ "Number_Of_Voice": 467,
236
+ },
237
+ "ga-IE": {
238
+ "Language": "Irish",
239
+ "Date": "2020-12-11",
240
+ "Size": "149 MB",
241
+ "Version": "ga-IE_5h_2020-12-11",
242
+ "Validated_Hr_Total": 3,
243
+ "Overall_Hr_Total": 5,
244
+ "Number_Of_Voice": 101,
245
+ },
246
+ "hi": {
247
+ "Language": "Hindi",
248
+ "Date": "2020-12-11",
249
+ "Size": "20 MB",
250
+ "Version": "hi_0.8h_2020-12-11",
251
+ "Validated_Hr_Total": 0.54,
252
+ "Overall_Hr_Total": 0.8,
253
+ "Number_Of_Voice": 31,
254
+ },
255
+ "hsb": {
256
+ "Language": "Sorbian, Upper",
257
+ "Date": "2020-12-11",
258
+ "Size": "76 MB",
259
+ "Version": "hsb_2h_2020-12-11",
260
+ "Validated_Hr_Total": 2,
261
+ "Overall_Hr_Total": 2,
262
+ "Number_Of_Voice": 19,
263
+ },
264
+ "hu": {
265
+ "Language": "Hungarian",
266
+ "Date": "2020-12-11",
267
+ "Size": "232 MB",
268
+ "Version": "hu_8h_2020-12-11",
269
+ "Validated_Hr_Total": 8,
270
+ "Overall_Hr_Total": 8,
271
+ "Number_Of_Voice": 47,
272
+ },
273
+ "ia": {
274
+ "Language": "InterLinguia",
275
+ "Date": "2020-12-11",
276
+ "Size": "216 MB",
277
+ "Version": "ia_8h_2020-12-11",
278
+ "Validated_Hr_Total": 6,
279
+ "Overall_Hr_Total": 8,
280
+ "Number_Of_Voice": 36,
281
+ },
282
+ "id": {
283
+ "Language": "Indonesian",
284
+ "Date": "2020-12-11",
285
+ "Size": "454 MB",
286
+ "Version": "id_17h_2020-12-11",
287
+ "Validated_Hr_Total": 9,
288
+ "Overall_Hr_Total": 17,
289
+ "Number_Of_Voice": 219,
290
+ },
291
+ "it": {
292
+ "Language": "Italian",
293
+ "Date": "2020-12-11",
294
+ "Size": "5 GB",
295
+ "Version": "it_199h_2020-12-11",
296
+ "Validated_Hr_Total": 158,
297
+ "Overall_Hr_Total": 199,
298
+ "Number_Of_Voice": 5729,
299
+ },
300
+ "ja": {
301
+ "Language": "Japanese",
302
+ "Date": "2020-12-11",
303
+ "Size": "146 MB",
304
+ "Version": "ja_5h_2020-12-11",
305
+ "Validated_Hr_Total": 3,
306
+ "Overall_Hr_Total": 5,
307
+ "Number_Of_Voice": 235,
308
+ },
309
+ "ka": {
310
+ "Language": "Georgian",
311
+ "Date": "2020-12-11",
312
+ "Size": "99 MB",
313
+ "Version": "ka_3h_2020-12-11",
314
+ "Validated_Hr_Total": 3,
315
+ "Overall_Hr_Total": 3,
316
+ "Number_Of_Voice": 44,
317
+ },
318
+ "kab": {
319
+ "Language": "Kabyle",
320
+ "Date": "2020-12-11",
321
+ "Size": "16 GB",
322
+ "Version": "kab_622h_2020-12-11",
323
+ "Validated_Hr_Total": 525,
324
+ "Overall_Hr_Total": 622,
325
+ "Number_Of_Voice": 1309,
326
+ },
327
+ "ky": {
328
+ "Language": "Kyrgyz",
329
+ "Date": "2020-12-11",
330
+ "Size": "553 MB",
331
+ "Version": "ky_22h_2020-12-11",
332
+ "Validated_Hr_Total": 11,
333
+ "Overall_Hr_Total": 22,
334
+ "Number_Of_Voice": 134,
335
+ },
336
+ "lg": {
337
+ "Language": "Luganda",
338
+ "Date": "2020-12-11",
339
+ "Size": "199 MB",
340
+ "Version": "lg_8h_2020-12-11",
341
+ "Validated_Hr_Total": 3,
342
+ "Overall_Hr_Total": 8,
343
+ "Number_Of_Voice": 76,
344
+ },
345
+ "lt": {
346
+ "Language": "Lithuanian",
347
+ "Date": "2020-12-11",
348
+ "Size": "129 MB",
349
+ "Version": "lt_4h_2020-12-11",
350
+ "Validated_Hr_Total": 2,
351
+ "Overall_Hr_Total": 4,
352
+ "Number_Of_Voice": 30,
353
+ },
354
+ "lv": {
355
+ "Language": "Latvian",
356
+ "Date": "2020-12-11",
357
+ "Size": "199 MB",
358
+ "Version": "lv_7h_2020-12-11",
359
+ "Validated_Hr_Total": 6,
360
+ "Overall_Hr_Total": 7,
361
+ "Number_Of_Voice": 99,
362
+ },
363
+ "mn": {
364
+ "Language": "Mongolian",
365
+ "Date": "2020-12-11",
366
+ "Size": "464 MB",
367
+ "Version": "mn_17h_2020-12-11",
368
+ "Validated_Hr_Total": 11,
369
+ "Overall_Hr_Total": 17,
370
+ "Number_Of_Voice": 376,
371
+ },
372
+ "mt": {
373
+ "Language": "Maltese",
374
+ "Date": "2020-12-11",
375
+ "Size": "405 MB",
376
+ "Version": "mt_15h_2020-12-11",
377
+ "Validated_Hr_Total": 7,
378
+ "Overall_Hr_Total": 15,
379
+ "Number_Of_Voice": 171,
380
+ },
381
+ "nl": {
382
+ "Language": "Dutch",
383
+ "Date": "2020-12-11",
384
+ "Size": "2 GB",
385
+ "Version": "nl_63h_2020-12-11",
386
+ "Validated_Hr_Total": 59,
387
+ "Overall_Hr_Total": 63,
388
+ "Number_Of_Voice": 1012,
389
+ },
390
+ "or": {
391
+ "Language": "Odia",
392
+ "Date": "2020-12-11",
393
+ "Size": "190 MB",
394
+ "Version": "or_7h_2020-12-11",
395
+ "Validated_Hr_Total": 0.87,
396
+ "Overall_Hr_Total": 7,
397
+ "Number_Of_Voice": 34,
398
+ },
399
+ "pa-IN": {
400
+ "Language": "Punjabi",
401
+ "Date": "2020-12-11",
402
+ "Size": "67 MB",
403
+ "Version": "pa-IN_2h_2020-12-11",
404
+ "Validated_Hr_Total": 0.5,
405
+ "Overall_Hr_Total": 2,
406
+ "Number_Of_Voice": 26,
407
+ },
408
+ "pl": {
409
+ "Language": "Polish",
410
+ "Date": "2020-12-11",
411
+ "Size": "3 GB",
412
+ "Version": "pl_129h_2020-12-11",
413
+ "Validated_Hr_Total": 108,
414
+ "Overall_Hr_Total": 129,
415
+ "Number_Of_Voice": 2647,
416
+ },
417
+ "pt": {
418
+ "Language": "Portuguese",
419
+ "Date": "2020-12-11",
420
+ "Size": "2 GB",
421
+ "Version": "pt_63h_2020-12-11",
422
+ "Validated_Hr_Total": 50,
423
+ "Overall_Hr_Total": 63,
424
+ "Number_Of_Voice": 1120,
425
+ },
426
+ "rm-sursilv": {
427
+ "Language": "Romansh Sursilvan",
428
+ "Date": "2020-12-11",
429
+ "Size": "263 MB",
430
+ "Version": "rm-sursilv_9h_2020-12-11",
431
+ "Validated_Hr_Total": 5,
432
+ "Overall_Hr_Total": 9,
433
+ "Number_Of_Voice": 78,
434
+ },
435
+ "rm-vallader": {
436
+ "Language": "Romansh Vallader",
437
+ "Date": "2020-12-11",
438
+ "Size": "103 MB",
439
+ "Version": "rm-vallader_3h_2020-12-11",
440
+ "Validated_Hr_Total": 2,
441
+ "Overall_Hr_Total": 3,
442
+ "Number_Of_Voice": 39,
443
+ },
444
+ "ro": {
445
+ "Language": "Romanian",
446
+ "Date": "2020-12-11",
447
+ "Size": "250 MB",
448
+ "Version": "ro_9h_2020-12-11",
449
+ "Validated_Hr_Total": 6,
450
+ "Overall_Hr_Total": 9,
451
+ "Number_Of_Voice": 130,
452
+ },
453
+ "ru": {
454
+ "Language": "Russian",
455
+ "Date": "2020-12-11",
456
+ "Size": "3 GB",
457
+ "Version": "ru_130h_2020-12-11",
458
+ "Validated_Hr_Total": 111,
459
+ "Overall_Hr_Total": 130,
460
+ "Number_Of_Voice": 1412,
461
+ },
462
+ "rw": {
463
+ "Language": "Kinyarwanda",
464
+ "Date": "2020-12-11",
465
+ "Size": "40 GB",
466
+ "Version": "rw_1510h_2020-12-11",
467
+ "Validated_Hr_Total": 1183,
468
+ "Overall_Hr_Total": 1510,
469
+ "Number_Of_Voice": 410,
470
+ },
471
+ "sah": {
472
+ "Language": "Sakha",
473
+ "Date": "2020-12-11",
474
+ "Size": "173 MB",
475
+ "Version": "sah_6h_2020-12-11",
476
+ "Validated_Hr_Total": 4,
477
+ "Overall_Hr_Total": 6,
478
+ "Number_Of_Voice": 42,
479
+ },
480
+ "sl": {
481
+ "Language": "Slovenian",
482
+ "Date": "2020-12-11",
483
+ "Size": "212 MB",
484
+ "Version": "sl_7h_2020-12-11",
485
+ "Validated_Hr_Total": 5,
486
+ "Overall_Hr_Total": 7,
487
+ "Number_Of_Voice": 82,
488
+ },
489
+ "sv-SE": {
490
+ "Language": "Swedish",
491
+ "Date": "2020-12-11",
492
+ "Size": "402 MB",
493
+ "Version": "sv-SE_15h_2020-12-11",
494
+ "Validated_Hr_Total": 12,
495
+ "Overall_Hr_Total": 15,
496
+ "Number_Of_Voice": 222,
497
+ },
498
+ "ta": {
499
+ "Language": "Tamil",
500
+ "Date": "2020-12-11",
501
+ "Size": "648 MB",
502
+ "Version": "ta_24h_2020-12-11",
503
+ "Validated_Hr_Total": 14,
504
+ "Overall_Hr_Total": 24,
505
+ "Number_Of_Voice": 266,
506
+ },
507
+ "th": {
508
+ "Language": "Thai",
509
+ "Date": "2020-12-11",
510
+ "Size": "325 MB",
511
+ "Version": "th_12h_2020-12-11",
512
+ "Validated_Hr_Total": 8,
513
+ "Overall_Hr_Total": 12,
514
+ "Number_Of_Voice": 182,
515
+ },
516
+ "tr": {
517
+ "Language": "Turkish",
518
+ "Date": "2020-12-11",
519
+ "Size": "592 MB",
520
+ "Version": "tr_22h_2020-12-11",
521
+ "Validated_Hr_Total": 20,
522
+ "Overall_Hr_Total": 22,
523
+ "Number_Of_Voice": 678,
524
+ },
525
+ "tt": {
526
+ "Language": "Tatar",
527
+ "Date": "2020-12-11",
528
+ "Size": "741 MB",
529
+ "Version": "tt_28h_2020-12-11",
530
+ "Validated_Hr_Total": 26,
531
+ "Overall_Hr_Total": 28,
532
+ "Number_Of_Voice": 185,
533
+ },
534
+ "uk": {
535
+ "Language": "Ukrainian",
536
+ "Date": "2020-12-11",
537
+ "Size": "1 GB",
538
+ "Version": "uk_43h_2020-12-11",
539
+ "Validated_Hr_Total": 30,
540
+ "Overall_Hr_Total": 43,
541
+ "Number_Of_Voice": 459,
542
+ },
543
+ "vi": {
544
+ "Language": "Vietnamese",
545
+ "Date": "2020-12-11",
546
+ "Size": "50 MB",
547
+ "Version": "vi_1h_2020-12-11",
548
+ "Validated_Hr_Total": 0.74,
549
+ "Overall_Hr_Total": 1,
550
+ "Number_Of_Voice": 62,
551
+ },
552
+ "vot": {
553
+ "Language": "Votic",
554
+ "Date": "2020-12-11",
555
+ "Size": "7 MB",
556
+ "Version": "vot_0.28h_2020-12-11",
557
+ "Validated_Hr_Total": 0,
558
+ "Overall_Hr_Total": 0.28,
559
+ "Number_Of_Voice": 3,
560
+ },
561
+ "zh-CN": {
562
+ "Language": "Chinese (China)",
563
+ "Date": "2020-12-11",
564
+ "Size": "2 GB",
565
+ "Version": "zh-CN_78h_2020-12-11",
566
+ "Validated_Hr_Total": 56,
567
+ "Overall_Hr_Total": 78,
568
+ "Number_Of_Voice": 3501,
569
+ },
570
+ "zh-HK": {
571
+ "Language": "Chinese (Hong Kong)",
572
+ "Date": "2020-12-11",
573
+ "Size": "3 GB",
574
+ "Version": "zh-HK_100h_2020-12-11",
575
+ "Validated_Hr_Total": 50,
576
+ "Overall_Hr_Total": 100,
577
+ "Number_Of_Voice": 2536,
578
+ },
579
+ "zh-TW": {
580
+ "Language": "Chinese (Taiwan)",
581
+ "Date": "2020-12-11",
582
+ "Size": "2 GB",
583
+ "Version": "zh-TW_78h_2020-12-11",
584
+ "Validated_Hr_Total": 55,
585
+ "Overall_Hr_Total": 78,
586
+ "Number_Of_Voice": 1444,
587
+ },
588
+ }
589
+
590
+
591
+ class CommonVoiceConfig(datasets.BuilderConfig):
592
+ """BuilderConfig for CommonVoice."""
593
+
594
+ def __init__(self, name, sub_version, **kwargs):
595
+ """
596
+ Args:
597
+ data_dir: `string`, the path to the folder containing the files in the
598
+ downloaded .tar
599
+ citation: `string`, citation for the data set
600
+ url: `string`, url for information about the data set
601
+ **kwargs: keyword arguments forwarded to super.
602
+ """
603
+ self.sub_version = sub_version
604
+ self.language = kwargs.pop("language", None)
605
+ self.date_of_snapshot = kwargs.pop("date", None)
606
+ self.size = kwargs.pop("size", None)
607
+ self.validated_hr_total = kwargs.pop("val_hrs", None)
608
+ self.total_hr_total = kwargs.pop("total_hrs", None)
609
+ self.num_of_voice = kwargs.pop("num_of_voice", None)
610
+ description = f"Common Voice speech to text dataset in {self.language} version {self.sub_version} of {self.date_of_snapshot}. The dataset comprises {self.validated_hr_total} of validated transcribed speech data from {self.num_of_voice} speakers. The dataset has a size of {self.size}"
611
+ super(CommonVoiceConfig, self).__init__(
612
+ name=name, version=datasets.Version("6.1.0", ""), description=description, **kwargs
613
+ )
614
+
615
+
616
+ class CommonVoice(datasets.GeneratorBasedBuilder):
617
+
618
+ DEFAULT_WRITER_BATCH_SIZE = 1000
619
+ BUILDER_CONFIGS = [
620
+ CommonVoiceConfig(
621
+ name=lang_id,
622
+ language=_LANGUAGES[lang_id]["Language"],
623
+ sub_version=_LANGUAGES[lang_id]["Version"],
624
+ date=_LANGUAGES[lang_id]["Date"],
625
+ size=_LANGUAGES[lang_id]["Size"],
626
+ val_hrs=_LANGUAGES[lang_id]["Validated_Hr_Total"],
627
+ total_hrs=_LANGUAGES[lang_id]["Overall_Hr_Total"],
628
+ num_of_voice=_LANGUAGES[lang_id]["Number_Of_Voice"],
629
+ )
630
+ for lang_id in _LANGUAGES.keys()
631
+ ]
632
+
633
+ def _info(self):
634
+
635
+ warnings.warn(
636
+ """
637
+ This version of the Common Voice dataset is deprecated.
638
+ You can download the latest one with
639
+ >>> load_dataset(\"mozilla-foundation/common_voice_11_0\", \"en\")
640
+ """,
641
+ FutureWarning,
642
+ )
643
+
644
+ features = datasets.Features(
645
+ {
646
+ "path": datasets.Value("string"),
647
+ "audio": datasets.Audio(sampling_rate=48_000),
648
+ "sentence": datasets.Value("string")
649
+ }
650
+ )
651
+
652
+ return datasets.DatasetInfo(
653
+ description=_DESCRIPTION,
654
+ features=features,
655
+ supervised_keys=None,
656
+ homepage=_HOMEPAGE,
657
+ license=_LICENSE,
658
+ citation=_CITATION,
659
+ task_templates=[AutomaticSpeechRecognition(audio_column="audio", transcription_column="sentence")],
660
+ )
661
+
662
+ def _split_generators(self, dl_manager):
663
+ """Returns SplitGenerators."""
664
+ # Download the TAR archive that contains the audio files:
665
+ #archive_path = dl_manager.download(_DATA_URL.format(self.config.name))
666
+
667
+ # First we locate the data using the path within the archive:
668
+ #path_to_data = "/".join(["cv-corpus-6.1-2020-12-11", self.config.name])
669
+ path_to_data = base_url
670
+ path_to_clips = base_url+"clips"
671
+ #path_to_clips = "/".join([path_to_data, "clips"])
672
+ metadata_filepaths = {
673
+ split: "/".join([path_to_data, f"{split}.tsv"])
674
+ for split in ["train", "test", "validation"]
675
+ }
676
+ # (Optional) In non-streaming mode, we can extract the archive locally to have actual local audio files:
677
+ local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else None
678
+ local_extracted_archive = base_url
679
+ # To access the audio data from the TAR archives using the download manager,
680
+ # we have to use the dl_manager.iter_archive method.
681
+ #
682
+ # This is because dl_manager.download_and_extract
683
+ # doesn't work to stream TAR archives in streaming mode.
684
+ # (we have to stream the files of a TAR archive one by one)
685
+ #
686
+ # The iter_archive method returns an iterable of (path_within_archive, file_obj) for every
687
+ # file in the TAR archive.
688
+
689
+ return [
690
+ datasets.SplitGenerator(
691
+ name=datasets.Split.TRAIN,
692
+ gen_kwargs={
693
+ "local_extracted_archive": local_extracted_archive,
694
+ "archive_iterator": dl_manager.iter_archive(
695
+ archive_path
696
+ ), # use iter_archive here to access the files in the TAR archives
697
+ "metadata_filepath": metadata_filepaths["train"],
698
+ "path_to_clips": path_to_clips,
699
+ },
700
+ ),
701
+ datasets.SplitGenerator(
702
+ name=datasets.Split.TEST,
703
+ gen_kwargs={
704
+ "local_extracted_archive": local_extracted_archive,
705
+ "archive_iterator": dl_manager.iter_archive(
706
+ archive_path
707
+ ), # use iter_archive here to access the files in the TAR archives
708
+ "metadata_filepath": metadata_filepaths["test"],
709
+ "path_to_clips": path_to_clips,
710
+ },
711
+ ),
712
+ datasets.SplitGenerator(
713
+ name=datasets.Split.VALIDATION,
714
+ gen_kwargs={
715
+ "local_extracted_archive": local_extracted_archive,
716
+ "archive_iterator": dl_manager.iter_archive(
717
+ archive_path
718
+ ), # use iter_archive here to access the files in the TAR archives
719
+ "metadata_filepath": metadata_filepaths["validation"],
720
+ "path_to_clips": path_to_clips,
721
+ },
722
+ ),
723
+
724
+ ]
725
+
726
+ def _generate_examples(self, local_extracted_archive, archive_iterator, metadata_filepath, path_to_clips):
727
+ """Yields examples."""
728
+ data_fields = list(self._info().features.keys())
729
+
730
+ # audio is not a header of the csv files
731
+ data_fields.remove("audio")
732
+ path_idx = data_fields.index("path")
733
+
734
+ all_field_values = {}
735
+ metadata_found = False
736
+ # Here we iterate over all the files within the TAR archive:
737
+ for path, f in archive_iterator:
738
+ # Parse the metadata CSV file
739
+ if path == metadata_filepath:
740
+ metadata_found = True
741
+ lines = f.readlines()
742
+ headline = lines[0].decode("utf-8")
743
+
744
+ column_names = headline.strip().split("\t")
745
+ assert (
746
+ column_names == data_fields
747
+ ), f"The file should have {data_fields} as column names, but has {column_names}"
748
+ for line in lines[1:]:
749
+ field_values = line.decode("utf-8").strip().split("\t")
750
+ # set full path for mp3 audio file
751
+ audio_path = "/".join([path_to_clips, field_values[path_idx]])
752
+ all_field_values[audio_path] = field_values
753
+ # Else, read the audio file and yield an example
754
+ elif path.startswith(path_to_clips):
755
+ assert metadata_found, "Found audio clips before the metadata TSV file."
756
+ if not all_field_values:
757
+ break
758
+ if path in all_field_values:
759
+ # retrieve the metadata corresponding to this audio file
760
+ field_values = all_field_values[path]
761
+
762
+ # if data is incomplete, fill with empty values
763
+ if len(field_values) < len(data_fields):
764
+ field_values += (len(data_fields) - len(field_values)) * ["''"]
765
+
766
+ result = {key: value for key, value in zip(data_fields, field_values)}
767
+
768
+ # set audio feature
769
+ path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
770
+ result["audio"] = {"path": path, "bytes": f.read()}
771
+ # set path to None if the audio file doesn't exist locally (i.e. in streaming mode)
772
+ result["path"] = path if local_extracted_archive else None
773
+
774
+ yield path, result