dsu-challenge-processed / dsu_dataset.py
dareenharthi's picture
Upload folder using huggingface_hub
e8284a7 verified
import json
import datasets
class DsuDataset(datasets.GeneratorBasedBuilder):
"""Discrete Speech Units dataset"""
VERSION = datasets.Version("1.0.0")
def _info(self):
return datasets.DatasetInfo(
description="Discrete Speech Units Dataset",
features=datasets.Features({
"id": datasets.Value("string"),
"tokens": datasets.Sequence(datasets.Value("int32")),
"text": datasets.Value("string"),
"augmentation": datasets.Value("string")
})
)
def _split_generators(self, dl_manager):
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"filepath": "data/train.json"},
)
]
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
data = json.load(f)
for i, item in enumerate(data):
yield i, {
"id": item["id"],
"tokens": item["tokens"],
"text": item["text"],
"augmentation": item["augmentation"],
}