freococo commited on
Commit
5bef4c4
·
verified ·
1 Parent(s): 4c026a2

Upload 2 files

Browse files
Files changed (2) hide show
  1. dataset.py +39 -0
  2. index.csv +0 -0
dataset.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import csv, datasets, os
2
+
3
+ class Voaburmese(datasets.GeneratorBasedBuilder):
4
+ VERSION = datasets.Version("1.0.0")
5
+
6
+ _SLOT2IDX = {"morning": 0, "evening": 1}
7
+
8
+ def _info(self):
9
+ return datasets.DatasetInfo(
10
+ description="VOA Burmese Morning & Evening audio index (2012-09-16 → today)",
11
+ license="odc-pddl-1.0",
12
+ features=datasets.Features(
13
+ {
14
+ "id": datasets.Value("string"),
15
+ "date": datasets.Value("string"),
16
+ "slot": datasets.ClassLabel(names=["morning", "evening"]),
17
+ "title": datasets.Value("string"),
18
+ "article_url": datasets.Value("string"),
19
+ "audio": datasets.Audio(), # remote MP3 streamed on access
20
+ }
21
+ ),
22
+ )
23
+
24
+ def _split_generators(self, dl_manager):
25
+ # the CSV is shipped with the repo; no need to download
26
+ csv_path = os.path.join(self._get_manual_data_dir(), "index.csv")
27
+ return [datasets.SplitGenerator(name="train", gen_kwargs={"csv_path": csv_path})]
28
+
29
+ def _generate_examples(self, csv_path):
30
+ with open(csv_path, newline="", encoding="utf-8") as f:
31
+ for i, row in enumerate(csv.DictReader(f)):
32
+ yield i, {
33
+ "id": f"{row['date']}_{row['slot']}",
34
+ "date": row["date"],
35
+ "slot": self._SLOT2IDX[row["slot"]],
36
+ "title": row["title"],
37
+ "article_url": row["article_url"],
38
+ "audio": row["mp3_url"],
39
+ }
index.csv ADDED
The diff for this file is too large to render. See raw diff