Datasets:
patrickvonplaten
commited on
Commit
•
d3bb592
1
Parent(s):
466f219
finish
Browse files- ami-ihm-kaldi-chunked.py +31 -52
ami-ihm-kaldi-chunked.py
CHANGED
@@ -280,10 +280,6 @@ class AMIConfig(datasets.BuilderConfig):
|
|
280 |
def __init__(self, name, *args, **kwargs):
|
281 |
"""BuilderConfig for AMI"""
|
282 |
super().__init__(name=name, *args, **kwargs)
|
283 |
-
if name not in {"dev", "test"}:
|
284 |
-
self.subsets_to_download = _SUBSETS[: _SUBSETS.index(name) + 1]
|
285 |
-
else:
|
286 |
-
self.subsets_to_download = (name,)
|
287 |
|
288 |
|
289 |
class AMI(datasets.GeneratorBasedBuilder):
|
@@ -331,9 +327,9 @@ class AMI(datasets.GeneratorBasedBuilder):
|
|
331 |
)
|
332 |
|
333 |
def _split_generators(self, dl_manager):
|
334 |
-
train_audio_files =
|
335 |
-
dev_audio_files =
|
336 |
-
eval_audio_files =
|
337 |
|
338 |
train_audio_archives = dl_manager.download_and_extract(train_audio_files)
|
339 |
dev_audio_archives = dl_manager.download_and_extract(dev_audio_files)
|
@@ -343,61 +339,44 @@ class AMI(datasets.GeneratorBasedBuilder):
|
|
343 |
dev_annotation = dl_manager.download_and_extract(_ANNOTATIONS_ARCHIVE_URL.format(split="dev"))
|
344 |
eval_annotation = dl_manager.download_and_extract(_ANNOTATIONS_ARCHIVE_URL.format(split="eval"))
|
345 |
|
346 |
-
import ipdb; ipdb.set_trace()
|
347 |
-
|
348 |
return [
|
349 |
datasets.SplitGenerator(
|
350 |
name=datasets.Split.TRAIN,
|
351 |
-
gen_kwargs={"audio": train_audio_archives, "annotation": train_annotation},
|
352 |
),
|
353 |
datasets.SplitGenerator(
|
354 |
name=datasets.Split.VALIDATION,
|
355 |
-
gen_kwargs={"audio": dev_audio_archives, "annotation": dev_annotation},
|
356 |
),
|
357 |
datasets.SplitGenerator(
|
358 |
name=datasets.Split.TEST,
|
359 |
-
gen_kwargs={"audio": eval_audio_archives, "annotation": eval_annotation},
|
360 |
),
|
361 |
]
|
362 |
|
363 |
-
def _generate_examples(self, audio, annotation):
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
# audio_meta = meta_dict[audio_id]
|
383 |
-
# audio_meta["segment_id"] = audio_meta.pop("sid")
|
384 |
-
# audio_meta["original_full_path"] = audio_meta.pop("path")
|
385 |
-
# audio_meta["text"] = audio_meta.pop("text_tn")
|
386 |
-
# audio_meta["audio_id"] = audio_meta.pop("aid")
|
387 |
-
# if not audio_meta["category"]:
|
388 |
-
# audio_meta["category"] = "N/A"
|
389 |
-
#
|
390 |
-
# path = (
|
391 |
-
# os.path.join(local_audio_archives_paths[i], audio_path_in_archive)
|
392 |
-
# if local_audio_archives_paths
|
393 |
-
# else audio_path_in_archive
|
394 |
-
# )
|
395 |
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
# },
|
403 |
-
# }
|
|
|
280 |
def __init__(self, name, *args, **kwargs):
|
281 |
"""BuilderConfig for AMI"""
|
282 |
super().__init__(name=name, *args, **kwargs)
|
|
|
|
|
|
|
|
|
283 |
|
284 |
|
285 |
class AMI(datasets.GeneratorBasedBuilder):
|
|
|
327 |
)
|
328 |
|
329 |
def _split_generators(self, dl_manager):
|
330 |
+
train_audio_files = {m: _AUDIO_ARCHIVE_URL.format(subset=self.config.name, split="train", _id=m) for m in _TRAIN_SAMPLE_IDS}
|
331 |
+
dev_audio_files = {m: _AUDIO_ARCHIVE_URL.format(subset=self.config.name, split="dev", _id=m) for m in _VALIDATION_SAMPLE_IDS}
|
332 |
+
eval_audio_files = {m: _AUDIO_ARCHIVE_URL.format(subset=self.config.name, split="eval", _id=m) for m in _EVAL_SAMPLE_IDS}
|
333 |
|
334 |
train_audio_archives = dl_manager.download_and_extract(train_audio_files)
|
335 |
dev_audio_archives = dl_manager.download_and_extract(dev_audio_files)
|
|
|
339 |
dev_annotation = dl_manager.download_and_extract(_ANNOTATIONS_ARCHIVE_URL.format(split="dev"))
|
340 |
eval_annotation = dl_manager.download_and_extract(_ANNOTATIONS_ARCHIVE_URL.format(split="eval"))
|
341 |
|
|
|
|
|
342 |
return [
|
343 |
datasets.SplitGenerator(
|
344 |
name=datasets.Split.TRAIN,
|
345 |
+
gen_kwargs={"audio": train_audio_archives, "annotation": train_annotation, "split": "train"},
|
346 |
),
|
347 |
datasets.SplitGenerator(
|
348 |
name=datasets.Split.VALIDATION,
|
349 |
+
gen_kwargs={"audio": dev_audio_archives, "annotation": dev_annotation, "split": "dev"},
|
350 |
),
|
351 |
datasets.SplitGenerator(
|
352 |
name=datasets.Split.TEST,
|
353 |
+
gen_kwargs={"audio": eval_audio_archives, "annotation": eval_annotation, "split": "eval"},
|
354 |
),
|
355 |
]
|
356 |
|
357 |
+
def _generate_examples(self, audio, annotation, split):
|
358 |
+
# open annotation file
|
359 |
+
with open(annotation, "r", encoding="utf-8") as f:
|
360 |
+
transcriptions = {}
|
361 |
+
for line in f.readlines():
|
362 |
+
line_items = line.strip().split()
|
363 |
+
_id = line_items[0]
|
364 |
+
text = " ".join(line_items[1:])
|
365 |
+
_, segment_id, microphone_id, speaker_id, begin_time, end_time = _id.split("_")
|
366 |
+
|
367 |
+
transcriptions[_id] = {
|
368 |
+
"audio_id": _id,
|
369 |
+
"segment_id": segment_id,
|
370 |
+
"text": text,
|
371 |
+
"begin_time": int(begin_time) / 100,
|
372 |
+
"end_time": int(end_time) / 100,
|
373 |
+
"microphone_id": microphone_id,
|
374 |
+
"speaker_id": speaker_id,
|
375 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
|
377 |
+
for _audio_id, (transcription_id, result) in enumerate(transcriptions.items()):
|
378 |
+
folder_id = result["segment_id"]
|
379 |
+
file_name = "_".join([split, transcription_id.lower()]) + ".wav"
|
380 |
+
audio_file = os.path.join(audio[folder_id], folder_id, file_name)
|
381 |
+
result["audio"] = audio_file
|
382 |
+
yield _audio_id, result
|
|
|
|