| | import datasets |
| |
|
| | _CITATION = """\ |
| | @InProceedings{huggingface:dataset, |
| | title = {Small audio-text set}, |
| | author={James Briggs}, |
| | year={2022} |
| | } |
| | """ |
| |
|
| | _DESCRIPTION = """\ |
| | Demo dataset for testing or showing audio-text capabilities. |
| | """ |
| | |
| | _HOMEPAGE = "https://huggingface.co/datasets/lucasjca/audio-files" |
| |
|
| | _LICENSE = "" |
| |
|
| | |
| | _REPO = "https://huggingface.co/datasets/lucasjca/audio-files" |
| |
|
| |
|
| | descriptions =['ACOLHIMENTO NOTURNO DE PACIENTE EM CENTRO DE ATENÇÃO PSICOSSOCIAL', |
| | 'ADALIMUMABE 40 MG INJETÁVEL (POR SERINGA PREENCHIDA)', |
| | 'ADALIMUMABE 40 MG INJETAVEL (POR SERINGA PREENCHIDA)', |
| | 'ADALIMUMABE 40 MG INJETÁVEL (FRASCO AMPOLA)'] |
| |
|
| |
|
| | class audioSet(datasets.GeneratorBasedBuilder): |
| | """Small sample of audio-text pairs""" |
| |
|
| | def _info(self): |
| | return datasets.DatasetInfo( |
| | description=_DESCRIPTION, |
| | features=datasets.Features( |
| | { |
| | 'text': datasets.Value("string"), |
| | 'audio': datasets.audio(), |
| | } |
| | ), |
| | supervised_keys=None, |
| | homepage=_HOMEPAGE, |
| | citation=_CITATION, |
| | ) |
| |
|
| | def _split_generators(self, dl_manager): |
| | audios_archive = dl_manager.download(f"{_REPO}/resolve/main/audios.tgz") |
| | audio_iters = dl_manager.iter_archive(audios_archive) |
| | return [ |
| | datasets.SplitGenerator( |
| | name=datasets.Split.TRAIN, |
| | gen_kwargs={ |
| | "audios": audio_iters |
| | } |
| | ), |
| | ] |
| |
|
| | def _generate_examples(self, audios): |
| | """ This function returns the examples in the raw (text) form.""" |
| | |
| | for idx, (filepath, audio) in enumerate(audios): |
| | description = filepath.split('/')[-1][:-4] |
| | description = description.replace('_', ' ') |
| | yield idx, { |
| | "audio": {"path": filepath, "bytes": audio.read()}, |
| | "text": description, |
| | } |
| |
|