|
|
|
|
|
"""test set""" |
|
|
|
|
|
import csv |
|
import os |
|
import json |
|
|
|
import datasets |
|
from datasets.utils.py_utils import size_str |
|
from tqdm import tqdm |
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{panayotov2015librispeech, |
|
title={Librispeech: an ASR corpus based on public domain audio books}, |
|
author={Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev}, |
|
booktitle={Acoustics, Speech and Signal Processing (ICASSP), 2015 IEEE International Conference on}, |
|
pages={5206--5210}, |
|
year={2015}, |
|
organization={IEEE} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
Lorem ipsum |
|
""" |
|
|
|
|
|
_BASE_URL = "https://huggingface.co/datasets/j-krzywdziak/test/tree/main" |
|
_DATA_URL = "https://huggingface.co/datasets/j-krzywdziak/test/blob/main/dev.tar.gz" |
|
_PROMPTS_URLS = "https://huggingface.co/datasets/j-krzywdziak/test/raw/main/dev.tsv" |
|
|
|
logger = datasets.logging.get_logger(__name__) |
|
|
|
class TestConfig(datasets.BuilderConfig): |
|
"""Lorem impsum.""" |
|
|
|
def __init__(self, name, version, **kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
description = ( |
|
f"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " |
|
f"incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud " |
|
f"exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " |
|
f"dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " |
|
f"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " |
|
f"mollit anim id est laborum." |
|
) |
|
super(TestConfig, self).__init__( |
|
name=name, |
|
version=datasets.Version(version), |
|
description=description, |
|
**kwargs, |
|
) |
|
|
|
class TestASR(datasets.GeneratorBasedBuilder): |
|
"""Lorem ipsum.""" |
|
DEFAULT_CONFIG_NAME = "all" |
|
|
|
BUILDER_CONFIGS = [ |
|
TestConfig( |
|
name="Test Dataset", |
|
version="0.0.0", |
|
) |
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"audio_id": datasets.Value("string"), |
|
"audio": datasets.Audio(sampling_rate=16_000), |
|
"ngram": datasets.Value("string") |
|
} |
|
), |
|
supervised_keys=None, |
|
homepage=_BASE_URL, |
|
citation=_CITATION |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
archive_path = dl_manager.download(_DATA_URL) |
|
|
|
local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else {} |
|
meta_path = dl_manager.download(_PROMPTS_URLS) |
|
return [datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={ |
|
"meta_path": meta_path, |
|
"audio_files": dl_manager.iter_archive(local_extracted_archive) |
|
} |
|
)] |
|
|
|
def _generate_examples(self, meta_path, audio_files): |
|
"""Lorem ipsum.""" |
|
metadata = {} |
|
with open(meta_path, encoding="utf-8") as f: |
|
for row in f: |
|
audio_id = row.splt("\t")[0] |
|
ngram = row.split("\t")[1] |
|
metadata[audio_id] = {"audio_id": audio_id, |
|
"ngram": ngram} |
|
|
|
inside_clips_dir = True |
|
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_id], "audio": audio} |
|
id_ +=1 |
|
|