freococo's picture
Upload 2 files
5bef4c4 verified
import csv, datasets, os
class Voaburmese(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
_SLOT2IDX = {"morning": 0, "evening": 1}
def _info(self):
return datasets.DatasetInfo(
description="VOA Burmese Morning & Evening audio index (2012-09-16 → today)",
license="odc-pddl-1.0",
features=datasets.Features(
{
"id": datasets.Value("string"),
"date": datasets.Value("string"),
"slot": datasets.ClassLabel(names=["morning", "evening"]),
"title": datasets.Value("string"),
"article_url": datasets.Value("string"),
"audio": datasets.Audio(), # remote MP3 streamed on access
}
),
)
def _split_generators(self, dl_manager):
# the CSV is shipped with the repo; no need to download
csv_path = os.path.join(self._get_manual_data_dir(), "index.csv")
return [datasets.SplitGenerator(name="train", gen_kwargs={"csv_path": csv_path})]
def _generate_examples(self, csv_path):
with open(csv_path, newline="", encoding="utf-8") as f:
for i, row in enumerate(csv.DictReader(f)):
yield i, {
"id": f"{row['date']}_{row['slot']}",
"date": row["date"],
"slot": self._SLOT2IDX[row["slot"]],
"title": row["title"],
"article_url": row["article_url"],
"audio": row["mp3_url"],
}