Datasets:
Commit
•
900248f
1
Parent(s):
0d6394e
add loading scrip and readme
Browse files- README.md +297 -3
- dataset_infos.json +0 -0
- ml_spoken_words.py +244 -0
README.md
CHANGED
@@ -1,3 +1,297 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- machine-generated
|
4 |
+
language_creators:
|
5 |
+
- other
|
6 |
+
languages:
|
7 |
+
- ar
|
8 |
+
- as
|
9 |
+
- br
|
10 |
+
- ca
|
11 |
+
- cnh
|
12 |
+
- cs
|
13 |
+
- cv
|
14 |
+
- cy
|
15 |
+
- de
|
16 |
+
- dv
|
17 |
+
- el
|
18 |
+
- en
|
19 |
+
- eo
|
20 |
+
- es
|
21 |
+
- et
|
22 |
+
- eu
|
23 |
+
- fa
|
24 |
+
- fr
|
25 |
+
- fy-NL
|
26 |
+
- ga-IE
|
27 |
+
- gn
|
28 |
+
- ha
|
29 |
+
- ia
|
30 |
+
- id
|
31 |
+
- it
|
32 |
+
- ka
|
33 |
+
- ky
|
34 |
+
- lt
|
35 |
+
- lv
|
36 |
+
- mn
|
37 |
+
- mt
|
38 |
+
- nl
|
39 |
+
- or
|
40 |
+
- pl
|
41 |
+
- pt
|
42 |
+
- rm-sursilv
|
43 |
+
- rm-vallader
|
44 |
+
- ro
|
45 |
+
- ru
|
46 |
+
- rw
|
47 |
+
- sah
|
48 |
+
- sk
|
49 |
+
- sl
|
50 |
+
- sv-SE
|
51 |
+
- ta
|
52 |
+
- tr
|
53 |
+
- tt
|
54 |
+
- uk
|
55 |
+
- vi
|
56 |
+
- zh-CN
|
57 |
+
licenses:
|
58 |
+
- cc-by-4.0
|
59 |
+
multilinguality:
|
60 |
+
- multilingual
|
61 |
+
pretty_name: Multilingual Spoken Words
|
62 |
+
size_categories:
|
63 |
+
- 10M<n<100M
|
64 |
+
source_datasets:
|
65 |
+
- extended|common_voice
|
66 |
+
task_categories:
|
67 |
+
- speech-processing
|
68 |
+
task_ids:
|
69 |
+
- other-other-keyword-spotting
|
70 |
+
---
|
71 |
+
|
72 |
+
# Dataset Card for Multilingual Spoken Words
|
73 |
+
|
74 |
+
## Table of Contents
|
75 |
+
- [Table of Contents](#table-of-contents)
|
76 |
+
- [Dataset Description](#dataset-description)
|
77 |
+
- [Dataset Summary](#dataset-summary)
|
78 |
+
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
79 |
+
- [Languages](#languages)
|
80 |
+
- [Dataset Structure](#dataset-structure)
|
81 |
+
- [Data Instances](#data-instances)
|
82 |
+
- [Data Fields](#data-fields)
|
83 |
+
- [Data Splits](#data-splits)
|
84 |
+
- [Dataset Creation](#dataset-creation)
|
85 |
+
- [Curation Rationale](#curation-rationale)
|
86 |
+
- [Source Data](#source-data)
|
87 |
+
- [Annotations](#annotations)
|
88 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
89 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
90 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
91 |
+
- [Discussion of Biases](#discussion-of-biases)
|
92 |
+
- [Other Known Limitations](#other-known-limitations)
|
93 |
+
- [Additional Information](#additional-information)
|
94 |
+
- [Dataset Curators](#dataset-curators)
|
95 |
+
- [Licensing Information](#licensing-information)
|
96 |
+
- [Citation Information](#citation-information)
|
97 |
+
- [Contributions](#contributions)
|
98 |
+
|
99 |
+
## Dataset Description
|
100 |
+
|
101 |
+
- **Homepage:** https://mlcommons.org/en/multilingual-spoken-words/
|
102 |
+
- **Repository:** https://github.com/harvard-edge/multilingual_kws
|
103 |
+
- **Paper:** https://datasets-benchmarks-proceedings.neurips.cc/paper/2021/file/fe131d7f5a6b38b23cc967316c13dae2-Paper-round2.pdf
|
104 |
+
- **Leaderboard:**
|
105 |
+
- **Point of Contact:**
|
106 |
+
|
107 |
+
### Dataset Summary
|
108 |
+
|
109 |
+
Multilingual Spoken Words Corpus is a large and growing audio dataset of spoken
|
110 |
+
words in 50 languages collectively spoken by over 5 billion people, for academic
|
111 |
+
research and commercial applications in keyword spotting and spoken term search,
|
112 |
+
licensed under CC-BY 4.0. The dataset contains more than 340,000 keywords,
|
113 |
+
totaling 23.4 million 1-second spoken examples (over 6,000 hours). The dataset
|
114 |
+
has many use cases, ranging from voice-enabled consumer devices to call center
|
115 |
+
automation. This dataset is generated by applying forced alignment on crowd-sourced sentence-level
|
116 |
+
audio to produce per-word timing estimates for extraction.
|
117 |
+
All alignments are included in the dataset.
|
118 |
+
|
119 |
+
### Supported Tasks and Leaderboards
|
120 |
+
|
121 |
+
Keyword spotting, Spoken term search
|
122 |
+
|
123 |
+
### Languages
|
124 |
+
|
125 |
+
The dataset is multilingual. To specify several languages to downloading pass a list of them to the
|
126 |
+
`language` argument:
|
127 |
+
|
128 |
+
```python
|
129 |
+
ds = load_dataset("datasets/ml_spoken_words", languages=["ar", "tt", "br"])
|
130 |
+
```
|
131 |
+
|
132 |
+
The dataset contains data for the following languages:
|
133 |
+
|
134 |
+
Low-resourced (<10 hours):
|
135 |
+
* Arabic (0.1G, 7.6h)
|
136 |
+
* Assamese (0.9M, 0.1h)
|
137 |
+
* Breton (69M, 5.6h)
|
138 |
+
* Chuvash (28M, 2.1h)
|
139 |
+
* Chinese (zh-CN) (42M, 3.1h)
|
140 |
+
* Dhivehi (0.7M, 0.04h)
|
141 |
+
* Frisian (0.1G, 9.6h)
|
142 |
+
* Georgian (20M, 1.4h)
|
143 |
+
* Guarani (0.7M, 1.3h)
|
144 |
+
* Greek (84M, 6.7h)
|
145 |
+
* Hakha Chin (26M, 0.1h)
|
146 |
+
* Hausa (90M, 1.0h)
|
147 |
+
* Interlingua (58M, 4.0h)
|
148 |
+
* Irish (38M, 3.2h)
|
149 |
+
* Latvian (51M, 4.2h)
|
150 |
+
* Lithuanian (21M, 0.46h)
|
151 |
+
* Maltese (88M, 7.3h)
|
152 |
+
* Oriya (0.7M, 0.1h)
|
153 |
+
* Romanian (59M, 4.5h)
|
154 |
+
* Sakha (42M, 3.3h)
|
155 |
+
* Slovenian (43M, 3.0h)
|
156 |
+
* Slovak (31M, 1.9h)
|
157 |
+
* Sursilvan (61M, 4.8h)
|
158 |
+
* Tamil (8.8M, 0.6h)
|
159 |
+
* Vallader (14M, 1.2h)
|
160 |
+
* Vietnamese (1.2M, 0.1h)
|
161 |
+
|
162 |
+
Medium-resourced (>10 & <100 hours):
|
163 |
+
* Czech (0.3G, 24h)
|
164 |
+
* Dutch (0.8G, 70h)
|
165 |
+
* Estonian (0.2G, 19h)
|
166 |
+
* Esperanto (1.3G, 77h)
|
167 |
+
* Indonesian (0.1G, 11h)
|
168 |
+
* Kyrgyz (0.1G, 12h)
|
169 |
+
* Mongolian (0.1G, 12h)
|
170 |
+
* Portuguese (0.7G, 58h)
|
171 |
+
* Swedish (0.1G, 12h)
|
172 |
+
* Tatar (4G, 30h)
|
173 |
+
* Turkish (1.3G, 29h)
|
174 |
+
* Ukrainian (0.2G, 18h)
|
175 |
+
|
176 |
+
Hig-resourced (>100 hours):
|
177 |
+
* Basque (1.7G, 118h)
|
178 |
+
* Catalan (8.7G, 615h)
|
179 |
+
* English (26G, 1957h)
|
180 |
+
* French (9.3G, 754h)
|
181 |
+
* German (14G, 1083h)
|
182 |
+
* Italian (2.2G, 155h)
|
183 |
+
* Kinyarwanda (6.1G, 422h)
|
184 |
+
* Persian (4.5G, 327h)
|
185 |
+
* Polish (1.8G, 130h)
|
186 |
+
* Russian (2.1G, 137h)
|
187 |
+
* Spanish (4.9G, 349h)
|
188 |
+
* Welsh (4.5G, 108h)
|
189 |
+
|
190 |
+
## Dataset Structure
|
191 |
+
|
192 |
+
### Data Instances
|
193 |
+
|
194 |
+
```python
|
195 |
+
{'file': 'абзар_common_voice_tt_17737010.opus',
|
196 |
+
'is_valid': True,
|
197 |
+
'language': 0,
|
198 |
+
'speaker_id': '687025afd5ce033048472754c8d2cb1cf8a617e469866bbdb3746e2bb2194202094a715906f91feb1c546893a5d835347f4869e7def2e360ace6616fb4340e38',
|
199 |
+
'gender': 0,
|
200 |
+
'keyword': 'абзар',
|
201 |
+
'audio': {'path': 'абзар_common_voice_tt_17737010.opus',
|
202 |
+
'array': array([2.03458695e-34, 2.03458695e-34, 2.03458695e-34, ...,
|
203 |
+
2.03458695e-34, 2.03458695e-34, 2.03458695e-34]),
|
204 |
+
'sampling_rate': 48000}}
|
205 |
+
```
|
206 |
+
|
207 |
+
### Data Fields
|
208 |
+
|
209 |
+
* file: strinrelative audio path inside the archive **#TODO: change according to the new local path schema?**
|
210 |
+
* is_valid: if a sample is valid
|
211 |
+
* language: language of an instance. Makes sense only when providing multiple languages to the
|
212 |
+
dataset loader (for example, `load_dataset("ml_spoken_words", languages=["ar", "tt"])`)
|
213 |
+
* speaker_id: unique id of a speaker. Can be "NA" if an instance is invalid
|
214 |
+
* gender: speaker gender. Can be one of `["MALE", "FEMALE", "OTHER", "NAN"]`
|
215 |
+
* keyword: word spoken in a current sample
|
216 |
+
* audio: a dictionary containing the relative path to the audio file,
|
217 |
+
the decoded audio array, and the sampling rate.
|
218 |
+
Note that when accessing the audio column: `dataset[0]["audio"]` the audio file is automatically
|
219 |
+
decoded and resampled to `dataset.features["audio"].sampling_rate`. Decoding and resampling of
|
220 |
+
a large number of audio files might take a significant amount of time.
|
221 |
+
Thus, it is important to first query the sample index before the "audio" column,
|
222 |
+
i.e. `dataset[0]["audio"]` should always be preferred over `dataset["audio"][0]`
|
223 |
+
|
224 |
+
### Data Splits
|
225 |
+
|
226 |
+
The data for each language is splitted into train / validation / test parts.
|
227 |
+
|
228 |
+
## Dataset Creation
|
229 |
+
|
230 |
+
### Curation Rationale
|
231 |
+
|
232 |
+
[More Information Needed]
|
233 |
+
|
234 |
+
### Source Data
|
235 |
+
|
236 |
+
#### Initial Data Collection and Normalization
|
237 |
+
|
238 |
+
The data comes form Common Voice dataset.
|
239 |
+
|
240 |
+
#### Who are the source language producers?
|
241 |
+
|
242 |
+
[More Information Needed]
|
243 |
+
|
244 |
+
### Annotations
|
245 |
+
|
246 |
+
#### Annotation process
|
247 |
+
|
248 |
+
[More Information Needed]
|
249 |
+
|
250 |
+
#### Who are the annotators?
|
251 |
+
|
252 |
+
[More Information Needed]
|
253 |
+
|
254 |
+
### Personal and Sensitive Information
|
255 |
+
|
256 |
+
he dataset consists of people who have donated their voice online.
|
257 |
+
You agree to not attempt to determine the identity of speakers.
|
258 |
+
|
259 |
+
## Considerations for Using the Data
|
260 |
+
|
261 |
+
### Social Impact of Dataset
|
262 |
+
|
263 |
+
[More Information Needed]
|
264 |
+
|
265 |
+
### Discussion of Biases
|
266 |
+
|
267 |
+
[More Information Needed]
|
268 |
+
|
269 |
+
### Other Known Limitations
|
270 |
+
|
271 |
+
[More Information Needed]
|
272 |
+
|
273 |
+
## Additional Information
|
274 |
+
|
275 |
+
### Dataset Curators
|
276 |
+
|
277 |
+
[More Information Needed]
|
278 |
+
|
279 |
+
### Licensing Information
|
280 |
+
|
281 |
+
The dataset is licensed under [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/) and can be used for academic
|
282 |
+
research and commercial applications in keyword spotting and spoken term search.
|
283 |
+
|
284 |
+
### Citation Information
|
285 |
+
|
286 |
+
```
|
287 |
+
@inproceedings{mazumder2021multilingual,
|
288 |
+
title={Multilingual Spoken Words Corpus},
|
289 |
+
author={Mazumder, Mark and Chitlangia, Sharad and Banbury, Colby and Kang, Yiping and Ciro, Juan Manuel and Achorn, Keith and Galvez, Daniel and Sabini, Mark and Mattson, Peter and Kanter, David and others},
|
290 |
+
booktitle={Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 2)},
|
291 |
+
year={2021}
|
292 |
+
}
|
293 |
+
```
|
294 |
+
|
295 |
+
### Contributions
|
296 |
+
|
297 |
+
Thanks to [@polinaeterna](https://github.com/polinaeterna) for adding this dataset.
|
dataset_infos.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
ml_spoken_words.py
ADDED
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 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 |
+
|
16 |
+
"""
|
17 |
+
Multilingual Spoken Words Corpus is a large and growing audio dataset of spoken
|
18 |
+
words in 50 languages collectively spoken by over 5 billion people, for academic
|
19 |
+
research and commercial applications in keyword spotting and spoken term search,
|
20 |
+
licensed under CC-BY 4.0. The dataset contains more than 340,000 keywords,
|
21 |
+
totaling 23.4 million 1-second spoken examples (over 6,000 hours).
|
22 |
+
"""
|
23 |
+
|
24 |
+
|
25 |
+
import csv
|
26 |
+
from functools import partial
|
27 |
+
|
28 |
+
import datasets
|
29 |
+
|
30 |
+
|
31 |
+
_CITATION = """\
|
32 |
+
@inproceedings{mazumder2021multilingual,
|
33 |
+
title={Multilingual Spoken Words Corpus},
|
34 |
+
author={Mazumder, Mark and Chitlangia, Sharad and Banbury, Colby and Kang, Yiping and Ciro, Juan Manuel and Achorn, Keith and Galvez, Daniel and Sabini, Mark and Mattson, Peter and Kanter, David and others},
|
35 |
+
booktitle={Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 2)},
|
36 |
+
year={2021}
|
37 |
+
}
|
38 |
+
"""
|
39 |
+
|
40 |
+
_DESCRIPTION = """\
|
41 |
+
Multilingual Spoken Words Corpus is a large and growing audio dataset of spoken
|
42 |
+
words in 50 languages collectively spoken by over 5 billion people, for academic
|
43 |
+
research and commercial applications in keyword spotting and spoken term search,
|
44 |
+
licensed under CC-BY 4.0. The dataset contains more than 340,000 keywords,
|
45 |
+
totaling 23.4 million 1-second spoken examples (over 6,000 hours). The dataset
|
46 |
+
has many use cases, ranging from voice-enabled consumer devices to call center
|
47 |
+
automation. This dataset is generated by applying forced alignment on crowd-sourced sentence-level
|
48 |
+
audio to produce per-word timing estimates for extraction.
|
49 |
+
All alignments are included in the dataset.
|
50 |
+
"""
|
51 |
+
|
52 |
+
_HOMEPAGE = "https://mlcommons.org/en/multilingual-spoken-words/"
|
53 |
+
|
54 |
+
_LICENSE = "CC-BY 4.0."
|
55 |
+
|
56 |
+
_VERSION = datasets.Version("1.0.0")
|
57 |
+
|
58 |
+
_BASE_URL = "https://huggingface.co/datasets/polinaeterna/ml_spoken_words/resolve/main/data/{lang}/"
|
59 |
+
_AUDIO_URL = _BASE_URL + "{split}/audio/{n}.tar.gz"
|
60 |
+
_SPLITS_URL = _BASE_URL + "splits.tar.gz"
|
61 |
+
_N_FILES_URL = _BASE_URL + "{split}/n_files.txt"
|
62 |
+
|
63 |
+
_GENDERS = ["MALE", "FEMALE", "OTHER", "NAN"]
|
64 |
+
|
65 |
+
_LANGUAGES = [
|
66 |
+
"ar",
|
67 |
+
"as",
|
68 |
+
"br",
|
69 |
+
"ca",
|
70 |
+
"cnh",
|
71 |
+
"cs",
|
72 |
+
"cv",
|
73 |
+
"cy",
|
74 |
+
"de",
|
75 |
+
"dv",
|
76 |
+
"el",
|
77 |
+
"en",
|
78 |
+
"eo",
|
79 |
+
"es",
|
80 |
+
"et",
|
81 |
+
"eu",
|
82 |
+
"fa",
|
83 |
+
"fr",
|
84 |
+
"fy-NL",
|
85 |
+
"ga-IE",
|
86 |
+
"gn",
|
87 |
+
"ha",
|
88 |
+
"ia",
|
89 |
+
"id",
|
90 |
+
"it",
|
91 |
+
"ka",
|
92 |
+
"ky",
|
93 |
+
"lt",
|
94 |
+
"lv",
|
95 |
+
"mn",
|
96 |
+
"mt",
|
97 |
+
"nl",
|
98 |
+
"or",
|
99 |
+
"pl",
|
100 |
+
"pt",
|
101 |
+
"rm-sursilv",
|
102 |
+
"rm-vallader",
|
103 |
+
"ro",
|
104 |
+
"ru",
|
105 |
+
"rw",
|
106 |
+
"sah",
|
107 |
+
"sk",
|
108 |
+
"sl",
|
109 |
+
"sv-SE",
|
110 |
+
"ta",
|
111 |
+
"tr",
|
112 |
+
"tt",
|
113 |
+
"uk",
|
114 |
+
"vi",
|
115 |
+
"zh-CN",
|
116 |
+
]
|
117 |
+
|
118 |
+
|
119 |
+
class MlSpokenWordsConfig(datasets.BuilderConfig):
|
120 |
+
"""BuilderConfig for MlSpokenWords."""
|
121 |
+
|
122 |
+
def __init__(self, *args, languages, **kwargs):
|
123 |
+
"""BuilderConfig for MlSpokenWords.
|
124 |
+
Args:
|
125 |
+
languages (:obj:`Union[List[str], str]`): language or list of languages to load
|
126 |
+
**kwargs: keyword arguments forwarded to super.
|
127 |
+
"""
|
128 |
+
super().__init__(
|
129 |
+
*args,
|
130 |
+
name="+".join(languages) if isinstance(languages, list) else languages,
|
131 |
+
**kwargs,
|
132 |
+
)
|
133 |
+
self.languages = languages if isinstance(languages, list) else [languages]
|
134 |
+
|
135 |
+
|
136 |
+
class MlSpokenWords(datasets.GeneratorBasedBuilder):
|
137 |
+
"""
|
138 |
+
Multilingual Spoken Words Corpus is a large and growing audio dataset of spoken
|
139 |
+
words in 50 languages collectively spoken by over 5 billion people, for academic
|
140 |
+
research and commercial applications in keyword spotting and spoken term search,
|
141 |
+
licensed under CC-BY 4.0. The dataset contains more than 340,000 keywords,
|
142 |
+
totaling 23.4 million 1-second spoken examples (over 6,000 hours).
|
143 |
+
"""
|
144 |
+
|
145 |
+
VERSION = _VERSION
|
146 |
+
BUILDER_CONFIGS = [MlSpokenWordsConfig(languages=[lang], version=_VERSION) for lang in _LANGUAGES]
|
147 |
+
BUILDER_CONFIG_CLASS = MlSpokenWordsConfig
|
148 |
+
|
149 |
+
def _info(self):
|
150 |
+
features = datasets.Features(
|
151 |
+
{
|
152 |
+
"file": datasets.Value("string"),
|
153 |
+
"is_valid": datasets.Value("bool"),
|
154 |
+
"language": datasets.ClassLabel(names=self.config.languages),
|
155 |
+
"speaker_id": datasets.Value("string"),
|
156 |
+
"gender": datasets.ClassLabel(names=_GENDERS),
|
157 |
+
"keyword": datasets.Value("string"), # seems that there are too many of them (340k unique keywords)
|
158 |
+
"audio": datasets.Audio(sampling_rate=48_000),
|
159 |
+
}
|
160 |
+
)
|
161 |
+
return datasets.DatasetInfo(
|
162 |
+
description=_DESCRIPTION,
|
163 |
+
features=features,
|
164 |
+
homepage=_HOMEPAGE,
|
165 |
+
license=_LICENSE,
|
166 |
+
citation=_CITATION,
|
167 |
+
)
|
168 |
+
|
169 |
+
def _split_generators(self, dl_manager):
|
170 |
+
splits_archive_path = [dl_manager.download(_SPLITS_URL.format(lang=lang)) for lang in self.config.languages]
|
171 |
+
download_audio = partial(_download_audio_archives, dl_manager=dl_manager)
|
172 |
+
|
173 |
+
return [
|
174 |
+
datasets.SplitGenerator(
|
175 |
+
name=datasets.Split.TRAIN,
|
176 |
+
gen_kwargs={
|
177 |
+
"audio_archives": [download_audio(split="train", lang=lang) for lang in self.config.languages],
|
178 |
+
"splits_archives": [dl_manager.iter_archive(path) for path in splits_archive_path],
|
179 |
+
"split": "train",
|
180 |
+
},
|
181 |
+
),
|
182 |
+
datasets.SplitGenerator(
|
183 |
+
name=datasets.Split.VALIDATION,
|
184 |
+
gen_kwargs={
|
185 |
+
"audio_archives": [download_audio(split="dev", lang=lang) for lang in self.config.languages],
|
186 |
+
"splits_archives": [dl_manager.iter_archive(path) for path in splits_archive_path],
|
187 |
+
"split": "dev",
|
188 |
+
},
|
189 |
+
),
|
190 |
+
datasets.SplitGenerator(
|
191 |
+
name=datasets.Split.TEST,
|
192 |
+
gen_kwargs={
|
193 |
+
"audio_archives": [download_audio(split="test", lang=lang) for lang in self.config.languages],
|
194 |
+
"splits_archives": [dl_manager.iter_archive(path) for path in splits_archive_path],
|
195 |
+
"split": "test",
|
196 |
+
},
|
197 |
+
),
|
198 |
+
]
|
199 |
+
|
200 |
+
def _generate_examples(self, audio_archives, splits_archives, split):
|
201 |
+
metadata = dict()
|
202 |
+
for lang_idx, lang in enumerate(self.config.languages):
|
203 |
+
for split_filename, split_file in splits_archives[lang_idx]:
|
204 |
+
if split_filename.split(".csv")[0] == split:
|
205 |
+
csv_reader = csv.reader([line.decode("utf-8") for line in split_file.readlines()], delimiter=",")
|
206 |
+
for i, (link, word, is_valid, speaker, gender) in enumerate(csv_reader):
|
207 |
+
if i == 0:
|
208 |
+
continue
|
209 |
+
audio_filename = "_".join(link.split("/"))
|
210 |
+
metadata[audio_filename] = {
|
211 |
+
"keyword": word,
|
212 |
+
"is_valid": is_valid,
|
213 |
+
"speaker_id": speaker,
|
214 |
+
"gender": gender if gender and gender != "NA" else "NAN", # some values are "NA"
|
215 |
+
}
|
216 |
+
|
217 |
+
for audio_archive in audio_archives[lang_idx]:
|
218 |
+
for audio_filename, audio_file in audio_archive:
|
219 |
+
yield audio_filename, {
|
220 |
+
"file": audio_filename,
|
221 |
+
"language": lang,
|
222 |
+
"audio": {"path": audio_filename, "bytes": audio_file.read()},
|
223 |
+
**metadata[audio_filename],
|
224 |
+
}
|
225 |
+
|
226 |
+
|
227 |
+
def _download_audio_archives(dl_manager, lang, split):
|
228 |
+
"""
|
229 |
+
All audio files are stored in several .tar.gz archives with names like 0.tar.gz, 1.tar.gz, ...
|
230 |
+
Number of archives stored in a separate .txt file (n_files.txt)
|
231 |
+
|
232 |
+
Prepare all the audio archives for iterating over them and their audio files.
|
233 |
+
"""
|
234 |
+
|
235 |
+
n_files_url = _N_FILES_URL.format(lang=lang, split=split)
|
236 |
+
n_files_path = dl_manager.download(n_files_url)
|
237 |
+
|
238 |
+
with open(n_files_path, "r", encoding="utf-8") as file:
|
239 |
+
n_files = int(file.read().strip()) # the file contains a number of archives
|
240 |
+
|
241 |
+
archive_urls = [_AUDIO_URL.format(lang=lang, split=split, n=i) for i in range(n_files)]
|
242 |
+
archive_paths = dl_manager.download(archive_urls)
|
243 |
+
|
244 |
+
return [dl_manager.iter_archive(archive_path) for archive_path in archive_paths]
|