|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import csv |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
logger = datasets.logging.get_logger(__name__) |
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{pudo23_interspeech, |
|
author={Mikołaj Pudo and Mateusz Wosik and Adam Cieślak and Justyna Krzywdziak and Bożena Łukasiak and Artur Janicki}, |
|
title={{MOCKS} 1.0: Multilingual Open Custom Keyword Spotting Testset}, |
|
year={2023}, |
|
booktitle={Proc. Interspeech 2023}, |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
Multilingual Open Custom Keyword Spotting Testset (MOCKS) is a comprehensive |
|
audio testset for evaluation and benchmarking Open-Vocabulary Keyword Spotting (OV-KWS) models. |
|
""" |
|
|
|
|
|
_BASE_URL = "https://huggingface.co/datasets/voiceintelligenceresearch/MOCKS/tree/main" |
|
_DL_URLS = { |
|
"de.MCV": { |
|
"offline": "de/MCV/test/offline/data.tar.gz", |
|
"online": "de/MCV/test/online/data.tar.gz", |
|
"offline_transcription" : "de/MCV/test/data_offline_transcription.tsv", |
|
"online_transcription" : "de/MCV/test/data_online_transcription.tsv", |
|
}, |
|
"en.LS-clean": { |
|
"offline": "en/LS-clean/test/offline/data.tar.gz", |
|
"online": "en/LS-clean/test/online/data.tar.gz", |
|
"offline_transcription" : "en/LS-clean/test/data_offline_transcription.tsv", |
|
"online_transcription" : "en/LS-clean/test/data_online_transcription.tsv", |
|
}, |
|
"en.LS-other": { |
|
"offline": "en/LS-other/test/offline/data.tar.gz", |
|
"online": "en/LS-other/test/online/data.tar.gz", |
|
"offline_transcription" : "en/LS-other/test/data_offline_transcription.tsv", |
|
"online_transcription" : "en/LS-other/test/data_online_transcription.tsv", |
|
}, |
|
"en.MCV": { |
|
"offline": "en/MCV/test/offline/data.tar.gz", |
|
"online": "en/MCV/test/online/data.tar.gz", |
|
"offline_transcription" : "en/MCV/test/data_offline_transcription.tsv", |
|
"online_transcription" : "en/MCV/test/data_online_transcription.tsv", |
|
}, |
|
"es.MCV": { |
|
"offline": "es/MCV/test/offline/data.tar.gz", |
|
"online": "es/MCV/test/online/data.tar.gz", |
|
"offline_transcription" : "es/MCV/test/data_offline_transcription.tsv", |
|
"online_transcription" : "es/MCV/test/data_online_transcription.tsv", |
|
}, |
|
"fr.MCV": { |
|
"offline": "fr/MCV/test/offline/data.tar.gz", |
|
"online": "fr/MCV/test/online/data.tar.gz", |
|
"offline_transcription": "fr/MCV/test/data_offline_transcription.tsv", |
|
"online_transcription": "fr/MCV/test/data_online_transcription.tsv", |
|
}, |
|
"it.MCV": { |
|
"offline": "it/MCV/test/offline/data.tar.gz", |
|
"online": "it/MCV/test/online/data.tar.gz", |
|
"offline_transcription": "it/MCV/test/data_offline_transcription.tsv", |
|
"online_transcription": "it/MCV/test/data_online_transcription.tsv", |
|
}, |
|
"all": { |
|
"de.MCV.offline": "de/MCV/test/offline/data.tar.gz", |
|
"de.MCV.online": "de/MCV/test/online/data.tar.gz", |
|
"en.LS-clean.offline": "en/LS-clean/test/offline/data.tar.gz", |
|
"en.LS-clean.online": "en/LS-clean/test/online/data.tar.gz", |
|
"en.LS-other.offline": "en/LS-other/test/offline/data.tar.gz", |
|
"en.LS-other.online": "en/LS-other/test/online/data.tar.gz", |
|
"en.MCV.offline": "en/MCV/test/offline/data.tar.gz", |
|
"en.MCV.online": "en/MCV/test/online/data.tar.gz", |
|
"es.MCV.offline": "es/MCV/test/offline/data.tar.gz", |
|
"es.MCV.online": "es/MCV/test/online/data.tar.gz", |
|
"fr.MCV.offline": "fr/MCV/test/offline/data.tar.gz", |
|
"fr.MCV.online": "fr/MCV/test/online/data.tar.gz", |
|
"it.MCVoffline": "it/MCV/test/offline/data.tar.gz", |
|
"it.MCV.online": "it/MCV/test/online/data.tar.gz", |
|
"de.MCV.offline_transcription": "de/MCV/test/data_offline_transcription.tsv", |
|
"de.MCV.online_transcription": "de/MCV/test/data_online_transcription.tsv", |
|
"en.LS-clean.offline_transcription": "en/LS-clean/test/data_offline_transcription.tsv", |
|
"en.LS-clean.online_transcription": "en/LS-clean/test/data_online_transcription.tsv", |
|
"en.LS-other.offline_transcription": "en/LS-other/test/data_offline_transcription.tsv", |
|
"en.LS-other.online_transcription": "en/LS-other/test/data_online_transcription.tsv", |
|
"en.MCV.offline_transcription": "en/MCV/test/data_offline_transcription.tsv", |
|
"en.MCVonline_transcription": "en/MCV/test/data_online_transcription.tsv", |
|
"es.MCV.offline_transcription": "es/MCV/test/data_offline_transcription.tsv", |
|
"es.MCV.online_transcription": "es/MCV/test/data_online_transcription.tsv", |
|
"fr.MCV.offline_transcription": "fr/MCV/test/data_offline_transcription.tsv", |
|
"fr.MCV.online_transcription": "fr/MCV/test/data_online_transcription.tsv", |
|
"it.MCV.offline_transcription": "it/MCV/test/data_offline_transcription.tsv", |
|
"it.MCV.online_transcription": "it/MCV/test/data_online_transcription.tsv", |
|
} |
|
} |
|
|
|
|
|
class Mocks(datasets.GeneratorBasedBuilder): |
|
"""Mocks Dataset.""" |
|
DEFAULT_CONFIG_NAME = "all" |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="de.MCV", description="German Mozilla Common Voice."), |
|
datasets.BuilderConfig(name="en.LS-clean", description="English LibriSpeech 'Clean'."), |
|
datasets.BuilderConfig(name="en.LS-other", description="English LibriSpeech 'Other'."), |
|
datasets.BuilderConfig(name="en.MCV", description="English Mozilla Common Voice."), |
|
datasets.BuilderConfig(name="es.MCV", description="Spanish Mozilla Common Voice."), |
|
datasets.BuilderConfig(name="fr.MCV", description="French Mozilla Common Voice."), |
|
datasets.BuilderConfig(name="it.MCV", description="Italian Mozilla Common Voice."), |
|
datasets.BuilderConfig(name="all", description="All test set."), |
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"audio_id": datasets.Value("string"), |
|
"audio": datasets.Audio(sampling_rate=16_000), |
|
"transcription": datasets.Value("string"), |
|
} |
|
), |
|
homepage=_BASE_URL, |
|
citation=_CITATION |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
archive_path = dl_manager.download(_DL_URLS[self.config.name]) |
|
|
|
if self.config.name == "de.MCV": |
|
offline_split = [ |
|
datasets.SplitGenerator( |
|
name="offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["offline"]), |
|
"transcription": archive_path["offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
) |
|
] |
|
online_split = [ |
|
datasets.SplitGenerator( |
|
name="online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["online"]), |
|
"transcription": archive_path["online_transcription"], |
|
"s_type": "online" |
|
} |
|
) |
|
] |
|
|
|
elif self.config.name == "en.LS-clean": |
|
offline_split = [ |
|
datasets.SplitGenerator( |
|
name="offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["offline"]), |
|
"transcription": archive_path["offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
) |
|
] |
|
online_split = [ |
|
datasets.SplitGenerator( |
|
name="online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["online"]), |
|
"transcription": archive_path["online_transcription"], |
|
"s_type": "online" |
|
} |
|
) |
|
] |
|
|
|
elif self.config.name == "en.LS-other": |
|
offline_split = [ |
|
datasets.SplitGenerator( |
|
name="offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["offline"]), |
|
"transcription": archive_path["offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
) |
|
] |
|
online_split = [ |
|
datasets.SplitGenerator( |
|
name="online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["online"]), |
|
"transcription": archive_path["online_transcription"], |
|
"s_type": "online" |
|
} |
|
) |
|
] |
|
|
|
elif self.config.name == "en.MCV": |
|
offline_split = [ |
|
datasets.SplitGenerator( |
|
name="offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["offline"]), |
|
"transcription": archive_path["offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
) |
|
] |
|
online_split = [ |
|
datasets.SplitGenerator( |
|
name="online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["online"]), |
|
"transcription": archive_path["online_transcription"], |
|
"s_type": "online" |
|
} |
|
) |
|
] |
|
|
|
elif self.config.name == "es.MCV": |
|
offline_split = [ |
|
datasets.SplitGenerator( |
|
name="offline", |
|
gen_kwargs={ |
|
"local_extracted_archive": local_extracted_archive.get("offline"), |
|
"audio_files": dl_manager.iter_archive(archive_path["offline"]), |
|
"transcription": archive_path["offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
) |
|
] |
|
online_split = [ |
|
datasets.SplitGenerator( |
|
name="online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["online"]), |
|
"transcription": archive_path["online_transcription"], |
|
"s_type": "online" |
|
} |
|
) |
|
] |
|
|
|
elif self.config.name == "fr.MCV": |
|
offline_split = [ |
|
datasets.SplitGenerator( |
|
name="offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["offline"]), |
|
"transcription": archive_path["offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
) |
|
] |
|
online_split = [ |
|
datasets.SplitGenerator( |
|
name="online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["online"]), |
|
"transcription": archive_path["online_transcription"], |
|
"s_type": "online" |
|
} |
|
) |
|
] |
|
|
|
elif self.config.name == "it.MCV": |
|
offline_split = [ |
|
datasets.SplitGenerator( |
|
name="offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["offline"]), |
|
"transcription": archive_path["offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
) |
|
] |
|
online_split = [ |
|
datasets.SplitGenerator( |
|
name="online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["online"]), |
|
"transcription": archive_path["online_transcription"], |
|
"s_type": "online" |
|
} |
|
) |
|
] |
|
|
|
elif self.config.name == "all": |
|
offline_split = [ |
|
datasets.SplitGenerator( |
|
name="de.MCV.offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["de.MCV.offline"]), |
|
"transcription": archive_path["de.MCV.offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="en.LS-clean.offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["en.LS-clean.offline"]), |
|
"transcription": archive_path["en.LS-clean.offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="en.LS-other.offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["en.LS-other.offline"]), |
|
"transcription": archive_path["en.LS-other.offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="en.MCV.offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["en.MCV.offline"]), |
|
"transcription": archive_path["en.MCV.offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="es.MCV.offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["es.MCV.offline"]), |
|
"transcription": archive_path["es.MCV.offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="fr.MCV.offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["fr.MCV.offline"]), |
|
"transcription": archive_path["fr.MCV.offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="it.MCV.offline", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["it.MCV.offline"]), |
|
"transcription": archive_path["it.MCV.offline_transcription"], |
|
"s_type": "offline" |
|
} |
|
) |
|
] |
|
online_split = [ |
|
datasets.SplitGenerator( |
|
name="de.MCV.online", |
|
gen_kwargs={ |
|
"transcription": archive_path["de.MCV.offline_transconline"], |
|
"s_type": "online" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="en.LS-clean.online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["en.LS-clean.online"]), |
|
"transcription": archive_path["en.LS-clean.online_transcription"], |
|
"s_type": "online" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="en.LS-other.online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["en.LS-other.online"]), |
|
"transcription": archive_path["en.LS-other.online_transcription"], |
|
"s_type": "online" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="en.MCV.online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["en.MCV.online"]), |
|
"transcription": archive_path["en.MCV.online_transcription"], |
|
"s_type": "online" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="es.MCV.online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["es.MCV.online"]), |
|
"transcription": archive_path["es.MCV.online_transcription"], |
|
"s_type": "online" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="fr.MCV.online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["fr.MCV.online"]), |
|
"transcription": archive_path["fr.MCV.online_transcription"], |
|
"s_type": "online" |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name="it.MCV.online", |
|
gen_kwargs={ |
|
"audio_files": dl_manager.iter_archive(archive_path["it.MCV.online"]), |
|
"transcription": archive_path["it.MCV.online_transcription"], |
|
"s_type": "online" |
|
} |
|
) |
|
] |
|
|
|
return online_split + offline_split |
|
|
|
def _generate_examples(self, audio_files, transcription, s_type): |
|
"""Lorem ipsum.""" |
|
metadata = {} |
|
with open(transcription, encoding="utf-8") as f: |
|
f = csv.reader(f, delimiter="\t") |
|
for row in f: |
|
audio_id = row[0].split("/")[-1] |
|
keyword_transcription = row[1] |
|
metadata[audio_id] = {"audio_id": audio_id, "transcription": keyword_transcription} |
|
|
|
id_ = 0 |
|
for path, f in audio_files: |
|
_, audio_name = os.path.split(path) |
|
if audio_name in metadata: |
|
audio = {"bytes": f.read()} |
|
yield id_, {**metadata[audio_name], "audio": audio} |
|
id_ +=1 |
|
|