Commit
·
1b92920
1
Parent(s):
f79068d
up
Browse files- ami-ihm.py +17 -10
ami-ihm.py
CHANGED
@@ -265,9 +265,9 @@ _AUDIO_ARCHIVE_URL = _BASE_DATA_URL + "audio/{subset}/{split}/{_id}.tar.gz"
|
|
265 |
|
266 |
_ANNOTATIONS_ARCHIVE_URL = _BASE_DATA_URL + "annotations/{split}/text"
|
267 |
|
268 |
-
_TRANSCRIPT_URL = "https://huggingface.co/datasets/distil-whisper/ami/resolve/main/transcription_data/greedy_search/"
|
269 |
|
270 |
-
_TRANSCRIPT_URLS = _TRANSCRIPT_URL + "
|
271 |
|
272 |
logger = datasets.utils.logging.get_logger(__name__)
|
273 |
|
@@ -314,6 +314,7 @@ class AMI(datasets.GeneratorBasedBuilder):
|
|
314 |
|
315 |
def _split_generators(self, dl_manager):
|
316 |
splits = ["train", "dev", "eval"]
|
|
|
317 |
|
318 |
audio_archives_urls = {}
|
319 |
for split in splits:
|
@@ -334,8 +335,8 @@ class AMI(datasets.GeneratorBasedBuilder):
|
|
334 |
annotations_urls = {split: _ANNOTATIONS_ARCHIVE_URL.format(split=split) for split in splits}
|
335 |
annotations = dl_manager.download(annotations_urls)
|
336 |
|
337 |
-
transcription_urls = {split: _TRANSCRIPT_URLS.format(split=split) for split in
|
338 |
-
transcript_archive_path = dl_manager.download(transcription_urls
|
339 |
|
340 |
return [
|
341 |
datasets.SplitGenerator(
|
@@ -345,7 +346,8 @@ class AMI(datasets.GeneratorBasedBuilder):
|
|
345 |
"local_extracted_archives_paths": local_extracted_archives_paths["train"],
|
346 |
"annotation": annotations["train"],
|
347 |
"transcript_files": transcript_archive_path["train"],
|
348 |
-
"split": "train"
|
|
|
349 |
},
|
350 |
),
|
351 |
datasets.SplitGenerator(
|
@@ -354,8 +356,9 @@ class AMI(datasets.GeneratorBasedBuilder):
|
|
354 |
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_archives["dev"]],
|
355 |
"local_extracted_archives_paths": local_extracted_archives_paths["dev"],
|
356 |
"annotation": annotations["dev"],
|
357 |
-
"transcript_files": transcript_archive_path["
|
358 |
-
"split": "dev"
|
|
|
359 |
},
|
360 |
),
|
361 |
datasets.SplitGenerator(
|
@@ -364,16 +367,20 @@ class AMI(datasets.GeneratorBasedBuilder):
|
|
364 |
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_archives["eval"]],
|
365 |
"local_extracted_archives_paths": local_extracted_archives_paths["eval"],
|
366 |
"annotation": annotations["eval"],
|
367 |
-
"transcript_files": transcript_archive_path["
|
368 |
-
"split": "eval"
|
|
|
369 |
},
|
370 |
),
|
371 |
]
|
372 |
|
373 |
-
def _generate_examples(self, audio_archives, local_extracted_archives_paths, annotation, transcript_files, split):
|
374 |
# open annotation file
|
375 |
assert len(audio_archives) == len(local_extracted_archives_paths)
|
376 |
|
|
|
|
|
|
|
377 |
with open(annotation, "r", encoding="utf-8") as f:
|
378 |
transcriptions = {}
|
379 |
for line in f.readlines():
|
|
|
265 |
|
266 |
_ANNOTATIONS_ARCHIVE_URL = _BASE_DATA_URL + "annotations/{split}/text"
|
267 |
|
268 |
+
_TRANSCRIPT_URL = "https://huggingface.co/datasets/distil-whisper/ami-ihm/resolve/main/transcription_data/greedy_search/"
|
269 |
|
270 |
+
_TRANSCRIPT_URLS = _TRANSCRIPT_URL + "/{split}-transcription.txt"
|
271 |
|
272 |
logger = datasets.utils.logging.get_logger(__name__)
|
273 |
|
|
|
314 |
|
315 |
def _split_generators(self, dl_manager):
|
316 |
splits = ["train", "dev", "eval"]
|
317 |
+
splits_alt = ["train", "validation", "test"]
|
318 |
|
319 |
audio_archives_urls = {}
|
320 |
for split in splits:
|
|
|
335 |
annotations_urls = {split: _ANNOTATIONS_ARCHIVE_URL.format(split=split) for split in splits}
|
336 |
annotations = dl_manager.download(annotations_urls)
|
337 |
|
338 |
+
transcription_urls = {split: _TRANSCRIPT_URLS.format(split=split) for split in splits_alt}
|
339 |
+
transcript_archive_path = dl_manager.download(transcription_urls)
|
340 |
|
341 |
return [
|
342 |
datasets.SplitGenerator(
|
|
|
346 |
"local_extracted_archives_paths": local_extracted_archives_paths["train"],
|
347 |
"annotation": annotations["train"],
|
348 |
"transcript_files": transcript_archive_path["train"],
|
349 |
+
"split": "train",
|
350 |
+
"config": self.config.name,
|
351 |
},
|
352 |
),
|
353 |
datasets.SplitGenerator(
|
|
|
356 |
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_archives["dev"]],
|
357 |
"local_extracted_archives_paths": local_extracted_archives_paths["dev"],
|
358 |
"annotation": annotations["dev"],
|
359 |
+
"transcript_files": transcript_archive_path["validation"],
|
360 |
+
"split": "dev",
|
361 |
+
"config": self.config.name,
|
362 |
},
|
363 |
),
|
364 |
datasets.SplitGenerator(
|
|
|
367 |
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_archives["eval"]],
|
368 |
"local_extracted_archives_paths": local_extracted_archives_paths["eval"],
|
369 |
"annotation": annotations["eval"],
|
370 |
+
"transcript_files": transcript_archive_path["test"],
|
371 |
+
"split": "eval",
|
372 |
+
"config": self.config.name,
|
373 |
},
|
374 |
),
|
375 |
]
|
376 |
|
377 |
+
def _generate_examples(self, audio_archives, local_extracted_archives_paths, annotation, transcript_files, split, config):
|
378 |
# open annotation file
|
379 |
assert len(audio_archives) == len(local_extracted_archives_paths)
|
380 |
|
381 |
+
if config != "ihm":
|
382 |
+
raise ValueError("This dataset is intended for the ihm split only. Use `distil-whisper/ami-sdm` for the sdm split")
|
383 |
+
|
384 |
with open(annotation, "r", encoding="utf-8") as f:
|
385 |
transcriptions = {}
|
386 |
for line in f.readlines():
|