cahya commited on
Commit
e82d6b8
1 Parent(s): a030062

restructured the splits

Browse files
Files changed (1) hide show
  1. librivox-indonesia.py +13 -22
librivox-indonesia.py CHANGED
@@ -105,31 +105,26 @@ class LibriVoxIndonesia(datasets.GeneratorBasedBuilder):
105
  def _split_generators(self, dl_manager):
106
  """Returns SplitGenerators."""
107
  dl_manager.download_config.ignore_url_params = True
108
- audio_train = dl_manager.download(_DATA_URL + "/audio_train.tgz")
109
- local_extracted_archive_train = dl_manager.extract(audio_train) if not dl_manager.is_streaming else None
110
- audio_test = dl_manager.download(_DATA_URL + "/audio_test.tgz")
111
- local_extracted_archive_test = dl_manager.extract(audio_test) if not dl_manager.is_streaming else None
 
 
 
 
112
  path_to_clips = "librivox-indonesia"
113
 
114
  return [
115
  datasets.SplitGenerator(
116
- name=datasets.Split.TRAIN,
117
  gen_kwargs={
118
- "local_extracted_archive": local_extracted_archive_train,
119
- "audio_files": dl_manager.iter_archive(audio_train),
120
- "metadata_path": dl_manager.download_and_extract(_DATA_URL + "/metadata_train.csv.gz"),
121
  "path_to_clips": path_to_clips,
122
  },
123
- ),
124
- datasets.SplitGenerator(
125
- name=datasets.Split.TEST,
126
- gen_kwargs={
127
- "local_extracted_archive": local_extracted_archive_test,
128
- "audio_files": dl_manager.iter_archive(audio_test),
129
- "metadata_path": dl_manager.download_and_extract(_DATA_URL + "/metadata_test.csv.gz"),
130
- "path_to_clips": path_to_clips,
131
- },
132
- ),
133
  ]
134
 
135
  def _generate_examples(
@@ -140,7 +135,6 @@ class LibriVoxIndonesia(datasets.GeneratorBasedBuilder):
140
  path_to_clips,
141
  ):
142
  """Yields examples."""
143
- # print(metadata_path)
144
  data_fields = list(self._info().features.keys())
145
  metadata = {}
146
  with open(metadata_path, "r", encoding="utf-8") as f:
@@ -154,10 +148,7 @@ class LibriVoxIndonesia(datasets.GeneratorBasedBuilder):
154
  row[field] = ""
155
  metadata[row["path"]] = row
156
  id_ = 0
157
- # print("example length = %d" % len(metadata))
158
- # print(metadata)
159
  for path, f in audio_files:
160
- # print(path)
161
  if path in metadata:
162
  result = dict(metadata[path])
163
  # set the audio feature and the path to the extracted file
 
105
  def _split_generators(self, dl_manager):
106
  """Returns SplitGenerators."""
107
  dl_manager.download_config.ignore_url_params = True
108
+ audio = {}
109
+ local_extracted_archive = {}
110
+ metadata_path = {}
111
+ splits = { "train": datasets.Split.TRAIN, "test": datasets.Split.TEST}
112
+ for split in splits:
113
+ audio[split] = dl_manager.download(f"{_DATA_URL}/audio_train.tgz")
114
+ local_extracted_archive[split] = dl_manager.extract(audio[split]) if not dl_manager.is_streaming else None
115
+ metadata_path[split] = dl_manager.download_and_extract(f"{_DATA_URL}/metadata_{split}.csv.gz")
116
  path_to_clips = "librivox-indonesia"
117
 
118
  return [
119
  datasets.SplitGenerator(
120
+ name=splits[split],
121
  gen_kwargs={
122
+ "local_extracted_archive": local_extracted_archive[split],
123
+ "audio_files": dl_manager.iter_archive(audio[split]),
124
+ "metadata_path": dl_manager.download_and_extract(metadata_path[split]),
125
  "path_to_clips": path_to_clips,
126
  },
127
+ ) for split in splits
 
 
 
 
 
 
 
 
 
128
  ]
129
 
130
  def _generate_examples(
 
135
  path_to_clips,
136
  ):
137
  """Yields examples."""
 
138
  data_fields = list(self._info().features.keys())
139
  metadata = {}
140
  with open(metadata_path, "r", encoding="utf-8") as f:
 
148
  row[field] = ""
149
  metadata[row["path"]] = row
150
  id_ = 0
 
 
151
  for path, f in audio_files:
 
152
  if path in metadata:
153
  result = dict(metadata[path])
154
  # set the audio feature and the path to the extracted file