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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2023 The HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Creative Commons version 4.0 and Mozilla Public License version 2.0,
|
5 |
+
# (the "Licenses"); you may not use this file except in compliance with the Licenses.
|
6 |
+
# You may obtain a copies of the Licenses at
|
7 |
+
#
|
8 |
+
# https://creativecommons.org/licenses/by/4.0/
|
9 |
+
# and https://www.mozilla.org/en-US/MPL/2.0/
|
10 |
+
#
|
11 |
+
# Unless required by applicable law or agreed to in writing, software
|
12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
# See the Licenses for the specific language governing permissions and
|
15 |
+
# limitations under the Licenses.
|
16 |
+
|
17 |
+
# Lint as: python3
|
18 |
+
|
19 |
+
import csv
|
20 |
+
import os
|
21 |
+
import json
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
from datasets.utils.py_utils import size_str
|
25 |
+
from tqdm import tqdm
|
26 |
+
|
27 |
+
|
28 |
+
_CITATION = """\
|
29 |
+
@inproceedings{pudo23_interspeech,
|
30 |
+
author={Mikołaj Pudo and Mateusz Wosik and Adam Cieślak and Justyna Krzywdziak and Bożena Łukasiak and Artur Janicki},
|
31 |
+
title={{MOCKS} 1.0: Multilingual Open Custom Keyword Spotting Testset},
|
32 |
+
year={2023},
|
33 |
+
booktitle={Proc. Interspeech 2023},
|
34 |
+
}
|
35 |
+
"""
|
36 |
+
|
37 |
+
_DESCRIPTION = """\
|
38 |
+
Multilingual Open Custom Keyword Spotting Testset (MOCKS) is a comprehensive
|
39 |
+
audio testset for evaluation and benchmarking Open-Vocabulary Keyword Spotting (OV-KWS) models.
|
40 |
+
"""
|
41 |
+
|
42 |
+
|
43 |
+
_BASE_URL = "https://huggingface.co/datasets/voiceintelligenceresearch/MOCKS/tree/main"
|
44 |
+
_DL_URL = "https://huggingface.co/datasets/voiceintelligenceresearch/MOCKS/blob/main/"
|
45 |
+
_TR_URL = "https://huggingface.co/datasets/voiceintelligenceresearch/MOCKS/raw/main/"
|
46 |
+
_DL_URLS = {
|
47 |
+
"de.MCV": {
|
48 |
+
"offline": _DL_URL + "de/MCV/test/offline/data.tar.gz",
|
49 |
+
"online": _DL_URL + "de/MCV/test/online/data.tar.gz",
|
50 |
+
"offline_transcription" : _TR_URL + "de/MCV/test/data_offline_transcription.tsv",
|
51 |
+
"online_transcription" : _TR_URL + "de/MCV/test/data_online_transcription.tsv",
|
52 |
+
},
|
53 |
+
"en.LS-clean": {
|
54 |
+
"offline": _DL_URL + "en/LS-clean/test/offline/data.tar.gz",
|
55 |
+
"online": _DL_URL + "en/LS-clean/test/online/data.tar.gz",
|
56 |
+
"offline_transcription" : _TR_URL + "en/LS-clean/test/data_offline_transcription.tsv",
|
57 |
+
"online_transcription" : _TR_URL + "en/LS-clean/test/data_online_transcription.tsv",
|
58 |
+
},
|
59 |
+
"en.LS-other": {
|
60 |
+
"offline": _DL_URL + "en/LS-other/test/offline/data.tar.gz",
|
61 |
+
"online": _DL_URL + "en/LS-other/test/online/data.tar.gz",
|
62 |
+
"offline_transcription" : _TR_URL + "en/LS-other/test/data_offline_transcription.tsv",
|
63 |
+
"online_transcription" : _TR_URL + "en/LS-other/test/data_online_transcription.tsv",
|
64 |
+
},
|
65 |
+
"en.MCV": {
|
66 |
+
"offline": _DL_URL + "en/MCV/test/offline/data.tar.gz",
|
67 |
+
"online": _DL_URL + "en/MCV/test/online/data.tar.gz",
|
68 |
+
"offline_transcription" : _TR_URL + "en/MCV/test/data_offline_transcription.tsv",
|
69 |
+
"online_transcription" : _TR_URL + "en/MCV/test/data_online_transcription.tsv",
|
70 |
+
},
|
71 |
+
"es.MCV": {
|
72 |
+
"offline": _DL_URL + "es/MCV/test/offline/data.tar.gz",
|
73 |
+
"online": _DL_URL + "es/MCV/test/online/data.tar.gz",
|
74 |
+
"offline_transcription" : _TR_URL + "es/MCV/test/data_offline_transcription.tsv",
|
75 |
+
"online_transcription" : _TR_URL + "es/MCV/test/data_online_transcription.tsv",
|
76 |
+
},
|
77 |
+
"fr.MCV": {
|
78 |
+
"offline": _DL_URL + "fr/MCV/test/offline/data.tar.gz",
|
79 |
+
"online": _DL_URL + "fr/MCV/test/online/data.tar.gz",
|
80 |
+
"offline_transcription" : _TR_URL + "fr/MCV/test/data_offline_transcription.tsv",
|
81 |
+
"online_transcription" : _TR_URL + "fr/MCV/test/data_online_transcription.tsv",
|
82 |
+
},
|
83 |
+
"it.MCV": {
|
84 |
+
"offline": _DL_URL + "it/MCV/test/offline/data.tar.gz",
|
85 |
+
"online": _DL_URL + "it/MCV/test/online/data.tar.gz",
|
86 |
+
"offline_transcription" : _TR_URL + "it/MCV/test/data_offline_transcription.tsv",
|
87 |
+
"online_transcription" : _TR_URL + "it/MCV/test/data_online_transcription.tsv",
|
88 |
+
},
|
89 |
+
"all": {
|
90 |
+
"de.MCV.offline": _DL_URL + "de/MCV/test/offline/data.tar.gz",
|
91 |
+
"de.MCV.online": _DL_URL + "de/MCV/test/online/data.tar.gz",
|
92 |
+
"en.LS-clean.offline": _DL_URL + "en/LS-clean/test/offline/data.tar.gz",
|
93 |
+
"en.LS-clean.online": _DL_URL + "en/LS-clean/test/online/data.tar.gz",
|
94 |
+
"en.LS-other.offline": _DL_URL + "en/LS-other/test/offline/data.tar.gz",
|
95 |
+
"en.LS-other.online": _DL_URL + "en/LS-other/test/online/data.tar.gz",
|
96 |
+
"en.MCV.offline": _DL_URL + "en/MCV/test/offline/data.tar.gz",
|
97 |
+
"en.MCV.online": _DL_URL + "en/MCV/test/online/data.tar.gz",
|
98 |
+
"es.MCV.offline": _DL_URL + "es/MCV/test/offline/data.tar.gz",
|
99 |
+
"es.MCV.online": _DL_URL + "es/MCV/test/online/data.tar.gz",
|
100 |
+
"fr.MCV.offline": _DL_URL + "fr/MCV/test/offline/data.tar.gz",
|
101 |
+
"fr.MCV.online": _DL_URL + "fr/MCV/test/online/data.tar.gz",
|
102 |
+
"it.MCVoffline": _DL_URL + "it/MCV/test/offline/data.tar.gz",
|
103 |
+
"it.MCV.online": _DL_URL + "it/MCV/test/online/data.tar.gz",
|
104 |
+
"de.MCV.offline_transcription" : _TR_URL + "de/MCV/test/data_offline_transcription.tsv",
|
105 |
+
"de.MCV.online_transcription" : _TR_URL + "de/MCV/test/data_online_transcription.tsv",
|
106 |
+
"en.LS-clean.offline_transcription" : _TR_URL + "en/LS-clean/test/data_offline_transcription.tsv",
|
107 |
+
"en.LS-clean.online_transcription" : _TR_URL + "en/LS-clean/test/data_online_transcription.tsv",
|
108 |
+
"en.LS-other.offline_transcription" : _TR_URL + "en/LS-other/test/data_offline_transcription.tsv",
|
109 |
+
"en.LS-other.online_transcription" : _TR_URL + "en/LS-other/test/data_online_transcription.tsv",
|
110 |
+
"en.MCV.offline_transcription" : _TR_URL + "en/MCV/test/data_offline_transcription.tsv",
|
111 |
+
"en.MCVonline_transcription" : _TR_URL + "en/MCV/test/data_online_transcription.tsv",
|
112 |
+
"es.MCV.offline_transcription" : _TR_URL + "es/MCV/test/data_offline_transcription.tsv",
|
113 |
+
"es.MCV.online_transcription" : _TR_URL + "es/MCV/test/data_online_transcription.tsv",
|
114 |
+
"fr.MCV.offline_transcription" : _TR_URL + "fr/MCV/test/data_offline_transcription.tsv",
|
115 |
+
"fr.MCV.online_transcription" : _TR_URL + "fr/MCV/test/data_online_transcription.tsv",
|
116 |
+
"it.MCV.offline_transcription" : _TR_URL + "it/MCV/test/data_offline_transcription.tsv",
|
117 |
+
"it.MCV.online_transcription" : _TR_URL + "it/MCV/test/data_online_transcription.tsv",
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
_PROMPTS_URLS = "https://huggingface.co/datasets/j-krzywdziak/test/blob/main/dev.tsv"
|
122 |
+
|
123 |
+
logger = datasets.logging.get_logger(__name__)
|
124 |
+
|
125 |
+
class MocksConfig(datasets.BuilderConfig):
|
126 |
+
"""BuilderConfig for MOCKS testset."""
|
127 |
+
|
128 |
+
def __init__(self, name, version, **kwargs):
|
129 |
+
|
130 |
+
super(MocksConfig, self).__init__(
|
131 |
+
name=name,
|
132 |
+
version=datasets.Version(version),
|
133 |
+
description=description,
|
134 |
+
**kwargs,
|
135 |
+
)
|
136 |
+
|
137 |
+
class Mocks(datasets.GeneratorBasedBuilder):
|
138 |
+
"""Mocks Dataset."""
|
139 |
+
DEFAULT_CONFIG_NAME = "all"
|
140 |
+
|
141 |
+
BUILDER_CONFIGS = [
|
142 |
+
datasets.BuilderConfig(name="de.MCV", description="German Mozilla Common Voice."),
|
143 |
+
datasets.BuilderConfig(name="en.LS-clean", description="English LibriSpeech 'Clean'."),
|
144 |
+
datasets.BuilderConfig(name="en.LS-other", description="English LibriSpeech 'Other'."),
|
145 |
+
datasets.BuilderConfig(name="en.MCV", description="English Mozilla Common Voice."),
|
146 |
+
datasets.BuilderConfig(name="es.MCV", description="Spanish Mozilla Common Voice."),
|
147 |
+
datasets.BuilderConfig(name="fr.MCV", description="French Mozilla Common Voice."),
|
148 |
+
datasets.BuilderConfig(name="it.MCV", description="Italian Mozilla Common Voice."),
|
149 |
+
]
|
150 |
+
|
151 |
+
def _info(self):
|
152 |
+
return datasets.DatasetInfo(
|
153 |
+
description=_DESCRIPTION,
|
154 |
+
features=datasets.Features(
|
155 |
+
{
|
156 |
+
"audio_id": datasets.Value("string"),
|
157 |
+
"audio": datasets.Audio(sampling_rate=16_000),
|
158 |
+
"transcription": datasets.Value("string"),
|
159 |
+
"type": datasets.Value("string")
|
160 |
+
}
|
161 |
+
),
|
162 |
+
supervised_keys=("file", "text"),
|
163 |
+
homepage=_BASE_URL,
|
164 |
+
citation=_CITATION
|
165 |
+
)
|
166 |
+
|
167 |
+
def _split_generators(self, dl_manager):
|
168 |
+
archive_path = dl_manager.download(_DL_URLS[self.config.name])
|
169 |
+
# (Optional) In non-streaming mode, we can extract the archive locally to have actual local audio files:
|
170 |
+
local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else {}
|
171 |
+
|
172 |
+
if self.config.name == "de.MCV":
|
173 |
+
offline_split = [
|
174 |
+
datasets.SplitGenerator(
|
175 |
+
name="offline",
|
176 |
+
gen_kwargs={
|
177 |
+
"local_extracted_archive": local_extracted_archive.get("offline"),
|
178 |
+
"audio_files": dl_manager.iter_archive(archive_path["offline"]),
|
179 |
+
"transcription": archive_path["offline_transcription"],
|
180 |
+
"s_type": "offline"
|
181 |
+
}
|
182 |
+
)
|
183 |
+
]
|
184 |
+
online_split = [
|
185 |
+
datasets.SplitGenerator(
|
186 |
+
name="online",
|
187 |
+
gen_kwargs={
|
188 |
+
"local_extracted_archive": local_extracted_archive.get("online"),
|
189 |
+
"audio_files": dl_manager.iter_archive(archive_path["online"]),
|
190 |
+
"transcription": archive_path["online_transcription"],
|
191 |
+
"s_type": "online"
|
192 |
+
}
|
193 |
+
)
|
194 |
+
]
|
195 |
+
|
196 |
+
elif self.config.name == "en.LS-clean":
|
197 |
+
offline_split = [
|
198 |
+
datasets.SplitGenerator(
|
199 |
+
name="offline",
|
200 |
+
gen_kwargs={
|
201 |
+
"local_extracted_archive": local_extracted_archive.get("offline"),
|
202 |
+
"audio_files": dl_manager.iter_archive(archive_path["offline"]),
|
203 |
+
"transcription": archive_path["offline_transcription"],
|
204 |
+
"s_type": "offline"
|
205 |
+
}
|
206 |
+
)
|
207 |
+
]
|
208 |
+
online_split = [
|
209 |
+
datasets.SplitGenerator(
|
210 |
+
name="online",
|
211 |
+
gen_kwargs={
|
212 |
+
"local_extracted_archive": local_extracted_archive.get("online"),
|
213 |
+
"audio_files": dl_manager.iter_archive(archive_path["online"]),
|
214 |
+
"transcription": archive_path["online_transcription"],
|
215 |
+
"s_type": "online"
|
216 |
+
}
|
217 |
+
)
|
218 |
+
]
|
219 |
+
|
220 |
+
elif self.config.name == "en.LS-other":
|
221 |
+
offline_split = [
|
222 |
+
datasets.SplitGenerator(
|
223 |
+
name="offline",
|
224 |
+
gen_kwargs={
|
225 |
+
"local_extracted_archive": local_extracted_archive.get("offline"),
|
226 |
+
"audio_files": dl_manager.iter_archive(archive_path["offline"]),
|
227 |
+
"transcription": archive_path["offline_transcription"],
|
228 |
+
"s_type": "offline"
|
229 |
+
}
|
230 |
+
)
|
231 |
+
]
|
232 |
+
online_split = [
|
233 |
+
datasets.SplitGenerator(
|
234 |
+
name="online",
|
235 |
+
gen_kwargs={
|
236 |
+
"local_extracted_archive": local_extracted_archive.get("online"),
|
237 |
+
"audio_files": dl_manager.iter_archive(archive_path["online"]),
|
238 |
+
"transcription": archive_path["online_transcription"],
|
239 |
+
"s_type": "online"
|
240 |
+
}
|
241 |
+
)
|
242 |
+
]
|
243 |
+
|
244 |
+
elif self.config.name == "en.MCV":
|
245 |
+
offline_split = [
|
246 |
+
datasets.SplitGenerator(
|
247 |
+
name="offline",
|
248 |
+
gen_kwargs={
|
249 |
+
"local_extracted_archive": local_extracted_archive.get("offline"),
|
250 |
+
"audio_files": dl_manager.iter_archive(archive_path["offline"]),
|
251 |
+
"transcription": archive_path["offline_transcription"],
|
252 |
+
"s_type": "offline"
|
253 |
+
}
|
254 |
+
)
|
255 |
+
]
|
256 |
+
online_split = [
|
257 |
+
datasets.SplitGenerator(
|
258 |
+
name="online",
|
259 |
+
gen_kwargs={
|
260 |
+
"local_extracted_archive": local_extracted_archive.get("online"),
|
261 |
+
"audio_files": dl_manager.iter_archive(archive_path["online"]),
|
262 |
+
"transcription": archive_path["online_transcription"],
|
263 |
+
"s_type": "online"
|
264 |
+
}
|
265 |
+
)
|
266 |
+
]
|
267 |
+
|
268 |
+
elif self.config.name == "es.MCV":
|
269 |
+
offline_split = [
|
270 |
+
datasets.SplitGenerator(
|
271 |
+
name="offline",
|
272 |
+
gen_kwargs={
|
273 |
+
"local_extracted_archive": local_extracted_archive.get("offline"),
|
274 |
+
"audio_files": dl_manager.iter_archive(archive_path["offline"]),
|
275 |
+
"transcription": archive_path["offline_transcription"],
|
276 |
+
"s_type": "offline"
|
277 |
+
}
|
278 |
+
)
|
279 |
+
]
|
280 |
+
online_split = [
|
281 |
+
datasets.SplitGenerator(
|
282 |
+
name="online",
|
283 |
+
gen_kwargs={
|
284 |
+
"local_extracted_archive": local_extracted_archive.get("online"),
|
285 |
+
"audio_files": dl_manager.iter_archive(archive_path["online"]),
|
286 |
+
"transcription": archive_path["online_transcription"],
|
287 |
+
"s_type": "online"
|
288 |
+
}
|
289 |
+
)
|
290 |
+
]
|
291 |
+
|
292 |
+
elif self.config.name == "fr.MCV":
|
293 |
+
offline_split = [
|
294 |
+
datasets.SplitGenerator(
|
295 |
+
name="offline",
|
296 |
+
gen_kwargs={
|
297 |
+
"local_extracted_archive": local_extracted_archive.get("offline"),
|
298 |
+
"audio_files": dl_manager.iter_archive(archive_path["offline"]),
|
299 |
+
"transcription": archive_path["offline_transcription"],
|
300 |
+
"s_type": "offline"
|
301 |
+
}
|
302 |
+
)
|
303 |
+
]
|
304 |
+
online_split = [
|
305 |
+
datasets.SplitGenerator(
|
306 |
+
name="online",
|
307 |
+
gen_kwargs={
|
308 |
+
"local_extracted_archive": local_extracted_archive.get("online"),
|
309 |
+
"audio_files": dl_manager.iter_archive(archive_path["online"]),
|
310 |
+
"transcription": archive_path["online_transcription"],
|
311 |
+
"s_type": "online"
|
312 |
+
}
|
313 |
+
)
|
314 |
+
]
|
315 |
+
|
316 |
+
elif self.config.name == "it.MCV":
|
317 |
+
offline_split = [
|
318 |
+
datasets.SplitGenerator(
|
319 |
+
name="offline",
|
320 |
+
gen_kwargs={
|
321 |
+
"local_extracted_archive": local_extracted_archive.get("offline"),
|
322 |
+
"audio_files": dl_manager.iter_archive(archive_path["offline"]),
|
323 |
+
"transcription": archive_path["offline_transcription"],
|
324 |
+
"s_type": "offline"
|
325 |
+
}
|
326 |
+
)
|
327 |
+
]
|
328 |
+
online_split = [
|
329 |
+
datasets.SplitGenerator(
|
330 |
+
name="online",
|
331 |
+
gen_kwargs={
|
332 |
+
"local_extracted_archive": local_extracted_archive.get("online"),
|
333 |
+
"audio_files": dl_manager.iter_archive(archive_path["online"]),
|
334 |
+
"transcription": archive_path["online_transcription"],
|
335 |
+
"s_type": "online"
|
336 |
+
}
|
337 |
+
)
|
338 |
+
]
|
339 |
+
|
340 |
+
elif self.config.name == "all":
|
341 |
+
offline_split = [
|
342 |
+
datasets.SplitGenerator(
|
343 |
+
name="de.MCV.offline",
|
344 |
+
gen_kwargs={
|
345 |
+
"local_extracted_archive": local_extracted_archive.get("de.MCV.offline"),
|
346 |
+
"audio_files": dl_manager.iter_archive(archive_path["de.MCV.offline"]),
|
347 |
+
"transcription": archive_path["de.MCV.offline_transcription"],
|
348 |
+
"s_type": "offline"
|
349 |
+
}
|
350 |
+
),
|
351 |
+
datasets.SplitGenerator(
|
352 |
+
name="en.LS-clean.offline",
|
353 |
+
gen_kwargs={
|
354 |
+
"local_extracted_archive": local_extracted_archive.get("en.LS-clean.offline"),
|
355 |
+
"audio_files": dl_manager.iter_archive(archive_path["en.LS-clean.offline"]),
|
356 |
+
"transcription": archive_path["en.LS-clean.offline_transcription"],
|
357 |
+
"s_type": "offline"
|
358 |
+
}
|
359 |
+
),
|
360 |
+
datasets.SplitGenerator(
|
361 |
+
name="en.LS-other.offline",
|
362 |
+
gen_kwargs={
|
363 |
+
"local_extracted_archive": local_extracted_archive.get("en.LS-other.offline"),
|
364 |
+
"audio_files": dl_manager.iter_archive(archive_path["en.LS-other.offline"]),
|
365 |
+
"transcription": archive_path["en.LS-other.offline_transcription"],
|
366 |
+
"s_type": "offline"
|
367 |
+
}
|
368 |
+
),
|
369 |
+
datasets.SplitGenerator(
|
370 |
+
name="en.MCV.offline",
|
371 |
+
gen_kwargs={
|
372 |
+
"local_extracted_archive": local_extracted_archive.get("en.MCV.offline"),
|
373 |
+
"audio_files": dl_manager.iter_archive(archive_path["en.MCV.offline"]),
|
374 |
+
"transcription": archive_path["en.MCV.offline_transcription"],
|
375 |
+
"s_type": "offline"
|
376 |
+
}
|
377 |
+
),
|
378 |
+
datasets.SplitGenerator(
|
379 |
+
name="es.MCV.offline",
|
380 |
+
gen_kwargs={
|
381 |
+
"local_extracted_archive": local_extracted_archive.get("es.MCV.offline"),
|
382 |
+
"audio_files": dl_manager.iter_archive(archive_path["es.MCV.offline"]),
|
383 |
+
"transcription": archive_path["es.MCV.offline_transcription"],
|
384 |
+
"s_type": "offline"
|
385 |
+
}
|
386 |
+
),
|
387 |
+
datasets.SplitGenerator(
|
388 |
+
name="fr.MCV.offline",
|
389 |
+
gen_kwargs={
|
390 |
+
"local_extracted_archive": local_extracted_archive.get("fr.MCV.offline"),
|
391 |
+
"audio_files": dl_manager.iter_archive(archive_path["fr.MCV.offline"]),
|
392 |
+
"transcription": archive_path["fr.MCV.offline_transcription"],
|
393 |
+
"s_type": "offline"
|
394 |
+
}
|
395 |
+
),
|
396 |
+
datasets.SplitGenerator(
|
397 |
+
name="it.MCV.offline",
|
398 |
+
gen_kwargs={
|
399 |
+
"local_extracted_archive": local_extracted_archive.get("it.MCV.offline"),
|
400 |
+
"audio_files": dl_manager.iter_archive(archive_path["it.MCV.offline"]),
|
401 |
+
"transcription": archive_path["it.MCV.offline_transcription"],
|
402 |
+
"s_type": "offline"
|
403 |
+
}
|
404 |
+
)
|
405 |
+
]
|
406 |
+
online_split = [
|
407 |
+
datasets.SplitGenerator(
|
408 |
+
name="de.MCV.online",
|
409 |
+
gen_kwargs={
|
410 |
+
"local_extracted_archive": local_extracted_archive.get("de.MCV.online"),
|
411 |
+
"audio_files": dl_manager.iter_archive(archive_path["de.MCV.online"]),
|
412 |
+
"transcription": archive_path["de.MCV.offline_transconline"],
|
413 |
+
"s_type": "online"
|
414 |
+
}
|
415 |
+
),
|
416 |
+
datasets.SplitGenerator(
|
417 |
+
name="en.LS-clean.online",
|
418 |
+
gen_kwargs={
|
419 |
+
"local_extracted_archive": local_extracted_archive.get("en.LS-clean.online"),
|
420 |
+
"audio_files": dl_manager.iter_archive(archive_path["en.LS-clean.online"]),
|
421 |
+
"transcription": archive_path["en.LS-clean.online_transcription"],
|
422 |
+
"s_type": "online"
|
423 |
+
}
|
424 |
+
),
|
425 |
+
datasets.SplitGenerator(
|
426 |
+
name="en.LS-other.online",
|
427 |
+
gen_kwargs={
|
428 |
+
"local_extracted_archive": local_extracted_archive.get("en.LS-other.online"),
|
429 |
+
"audio_files": dl_manager.iter_archive(archive_path["en.LS-other.online"]),
|
430 |
+
"transcription": archive_path["en.LS-other.online_transcription"],
|
431 |
+
"s_type": "online"
|
432 |
+
}
|
433 |
+
),
|
434 |
+
datasets.SplitGenerator(
|
435 |
+
name="en.MCV.online",
|
436 |
+
gen_kwargs={
|
437 |
+
"local_extracted_archive": local_extracted_archive.get("en.MCV.online"),
|
438 |
+
"audio_files": dl_manager.iter_archive(archive_path["en.MCV.online"]),
|
439 |
+
"transcription": archive_path["en.MCV.online_transcription"],
|
440 |
+
"s_type": "online"
|
441 |
+
}
|
442 |
+
),
|
443 |
+
datasets.SplitGenerator(
|
444 |
+
name="es.MCV.online",
|
445 |
+
gen_kwargs={
|
446 |
+
"local_extracted_archive": local_extracted_archive.get("es.MCV.online"),
|
447 |
+
"audio_files": dl_manager.iter_archive(archive_path["es.MCV.online"]),
|
448 |
+
"transcription": archive_path["es.MCV.online_transcription"],
|
449 |
+
"s_type": "online"
|
450 |
+
}
|
451 |
+
),
|
452 |
+
datasets.SplitGenerator(
|
453 |
+
name="fr.MCV.online",
|
454 |
+
gen_kwargs={
|
455 |
+
"local_extracted_archive": local_extracted_archive.get("fr.MCV.online"),
|
456 |
+
"audio_files": dl_manager.iter_archive(archive_path["fr.MCV.online"]),
|
457 |
+
"transcription": archive_path["fr.MCV.online_transcription"],
|
458 |
+
"s_type": "online"
|
459 |
+
}
|
460 |
+
),
|
461 |
+
datasets.SplitGenerator(
|
462 |
+
name="it.MCV.online",
|
463 |
+
gen_kwargs={
|
464 |
+
"local_extracted_archive": local_extracted_archive.get("it.MCV.online"),
|
465 |
+
"audio_files": dl_manager.iter_archive(archive_path["it.MCV.online"]),
|
466 |
+
"transcription": archive_path["it.MCV.online_transcription"],
|
467 |
+
"s_type": "online"
|
468 |
+
}
|
469 |
+
)
|
470 |
+
]
|
471 |
+
|
472 |
+
return online_split + offline_split
|
473 |
+
|
474 |
+
def _generate_examples(self, local_extracted_archive, audio_files, transcription, s_type):
|
475 |
+
"""Lorem ipsum."""
|
476 |
+
audio_data = {}
|
477 |
+
metadata = []
|
478 |
+
key = 0
|
479 |
+
|
480 |
+
for path, f in audio_files:
|
481 |
+
audio_data[path] = f.read()
|
482 |
+
trans_col_name = "keyword_transcription"
|
483 |
+
if s_type == "online":
|
484 |
+
trans_col_name = "adversary_keyword_transcription"
|
485 |
+
|
486 |
+
with open(transcription, encoding="utf-8") as f:
|
487 |
+
for row in f:
|
488 |
+
r = row.split(r"\t")
|
489 |
+
audio_id = r[0].split("/")[-1]
|
490 |
+
keyword = r[1]
|
491 |
+
metadata.append({"audio_id": audio_id,
|
492 |
+
trans_col_name: ngram})
|
493 |
+
|
494 |
+
if audio_data and len(audio_data) == len(metadata):
|
495 |
+
for example in metadata:
|
496 |
+
audio = {"name": metadata["audio_id"], "bytes": audio_data[metadata["audio_id"]]}
|
497 |
+
yield key, {"audio": audio, **metadata}
|
498 |
+
key += 1
|
499 |
+
audio_data = {}
|
500 |
+
metadata = []
|