import os from collections import OrderedDict from pathlib import Path import datasets import glob import os from datasets.arrow_dataset import config class Gigaspeech2Config(datasets.BuilderConfig): """BuilderConfig for Yodas.""" def __init__(self, config_name, version, **kwargs): config_split = config_name.split("-") self.language = config_split[0] print(config_split) self.split = config_split[1] self.index = config_split[2] if len(config_split)>=3 else None self.base_data_path = f"data/{self.language}" description = ( f"Youtube speech to text dataset in {self.language}." ) super(Gigaspeech2Config, self).__init__( name=config_name, version=datasets.Version(version), description=description, **kwargs, ) DEFAULT_CONFIG_NAME = "all" LANGS = ['id', 'th', 'vi'] LANGS_SPLITS={ "id":2, "th":2, "vi":2 } VERSION = "1.0.1" CONFIG_NAME=[] for lang in LANGS: CONFIG_NAME.append(f"{lang}-test") CONFIG_NAME.append(f"{lang}-dev") CONFIG_NAME.append(f"{lang}-train_raw") CONFIG_NAME.append(f"{lang}-train_refine") for i in range(LANGS_SPLITS[lang]): CONFIG_NAME.append(f"{lang}-train_raw-{i}") CONFIG_NAME.append(f"{lang}-train_refine-{i}") class Gigaspeech2(datasets.GeneratorBasedBuilder): """Yodas dataset.""" BUILDER_CONFIGS = [ Gigaspeech2Config(config_name, version=VERSION) for config_name in CONFIG_NAME ] VERSION = datasets.Version("1.0.1") def _info(self): return datasets.DatasetInfo( description="Gigaspeech2", features=datasets.Features( OrderedDict( [ # ("id", datasets.Value("string")), # ("utt_id", datasets.Value("string")), ("audio", datasets.Audio(sampling_rate=16_000)), ("text", datasets.Value("string")), ] ) ), supervised_keys=None, homepage="", # TODO citation="", # TODO ) def _split_generators(self, dl_manager): """Returns SplitGenerators.""" # TODO lang = self.config.language split = self.config.split index = self.config.index if index is not None: assert int(index)