alaleye commited on
Commit
5a1e795
·
1 Parent(s): 2f7b998

fix splt names

Browse files
Files changed (1) hide show
  1. aloresb.py +23 -127
aloresb.py CHANGED
@@ -67,6 +67,29 @@ class Aloresb(datasets.GeneratorBasedBuilder):
67
  if os.path.exists(self.config.data_root_url + "/" + split + "/transcripts.txt"):
68
  _transcripts[split] = self.config.data_root_url + "/" + split + "/transcripts.txt"
69
  _audio_filenames[split] = self.config.data_root_url + "/" + split + "/audio_filenames.txt"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  transcripts = dl_manager.download(_transcripts)
72
 
@@ -144,130 +167,3 @@ class Aloresb(datasets.GeneratorBasedBuilder):
144
 
145
 
146
 
147
-
148
-
149
- # class Aloresb(datasets.GeneratorBasedBuilder):
150
- # DEFAULT_WRITER_BATCH_SIZE = 1000
151
- # VERSION = datasets.Version("1.0.0")
152
- # BUILDER_CONFIGS = [_build_config(name) for name in _STATS.keys()]
153
-
154
- # def _info(self):
155
- # description = _DESCRIPTION
156
- # features = datasets.Features(
157
- # {
158
- # "id": datasets.Value("string"),
159
- # "audio_path": datasets.Value("string"),
160
- # "audio_id": datasets.Value("string"),
161
- # "audio": datasets.features.Audio(sampling_rate=44_100),
162
- # "transcript": datasets.Value("string"),
163
- # "language": datasets.Value("string"),
164
- # }
165
- # )
166
-
167
- # return datasets.DatasetInfo(
168
- # description=description,
169
- # features=features,
170
- # supervised_keys=None,
171
- # # homepage=_HOMEPAGE,
172
- # # license=_LICENSE,
173
- # citation=_CITATION,
174
- # version=self.VERSION,
175
- # )
176
-
177
- # def _split_generators(self, dl_manager):
178
- # """Returns SplitGenerators."""
179
- # # If several configurations are possible (listed in BUILDER_CONFIGS),
180
- # # the configuration selected by the user is in self.config.name
181
-
182
- # # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
183
- # # It can accept any type or nested list/dict and will give back the same structure
184
- # # with the url replaced with path to local files.
185
- # # By default the archives will be extracted and a path to a cached folder
186
- # # where they are extracted is returned instead of the archive
187
-
188
- # language = self.config.name
189
-
190
- # audio_urls = {}
191
- # splits = ("train", "dev", "test")
192
- # for split in splits:
193
- # if self.config.name == 'all':
194
- # audio_urls[split] = []
195
- # for language in _STATS:
196
- # if language == "all" or split not in _STATS[language]:
197
- # continue
198
- # for i in range(_STATS[language][split]['shards']):
199
- # audio_urls[split].append(_AUDIO_URL.format(language=language, split=split, shard_idx=i))
200
- # elif split in _STATS[self.config.name]:
201
- # language = self.config.name
202
- # audio_urls[split] = [
203
- # _AUDIO_URL.format(language=language, split=split,
204
- # shard_idx=i) for i in range(_STATS[language][split]['shards'])
205
- # ]
206
- # archive_paths = dl_manager.download(audio_urls)
207
- # local_extracted_archive_paths = dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {}
208
-
209
- # language = self.config.name
210
-
211
- # if language == 'all':
212
- # meta_urls = {split: _TRANSCRIPT_URL_ALL.format(split=split) for split in splits}
213
- # else:
214
- # meta_urls = {split: _TRANSCRIPT_URL.format(language=language, split=split)
215
- # for split in splits if split in _STATS[language]}
216
-
217
- # meta_paths = dl_manager.download_and_extract(meta_urls)
218
-
219
- # split_generators = []
220
- # split_names = {
221
- # "train": datasets.Split.TRAIN,
222
- # "dev": datasets.Split.VALIDATION,
223
- # "test": datasets.Split.TEST,
224
- # }
225
-
226
- # for split in splits:
227
- # if split in _STATS[self.config.name]:
228
- # split_generators.append(
229
- # datasets.SplitGenerator(
230
- # name=split_names.get(split, split),
231
- # gen_kwargs={
232
- # "local_extracted_archive_paths": local_extracted_archive_paths.get(split),
233
- # "archives": [dl_manager.iter_archive(path) for path in archive_paths.get(split)],
234
- # "meta_path": meta_paths[split],
235
- # },
236
- # ),
237
- # )
238
-
239
- # return split_generators
240
-
241
- # def _generate_examples(self, local_extracted_archive_paths, archives, meta_path):
242
- # """Yields examples as (key, example) tuples."""
243
- # # This method handles input defined in _split_generators to yield (key, example) tuples
244
- # # from the dataset.
245
- # # The `key` is here for legacy reason (tfds) and is not important in itself.
246
- # data_fields = [key for key in self._info().features.keys() if key not in ["audio", "path"]]
247
- # metadata = {}
248
- # with open(meta_path, "r", encoding="utf-8") as f:
249
- # reader = csv.DictReader(f)
250
- # for row in tqdm(reader, desc="Reading metadata..."):
251
- # language = self.config.name
252
- # if (row['language'] == language) or (language == 'all'):
253
- # row["speaker_id"] = row["ID"]
254
- # audio_id = row["audio_id"]
255
- # # if data is incomplete, fill with empty values
256
- # metadata[audio_id] = {field: row.get(field, "") for field in data_fields}
257
-
258
- # for i, audio_archive in enumerate(archives):
259
- # #for filename, file in tqdm(audio_archive, desc=f"Searching and Extracting audios for config {self.config.name}..."):
260
- # for filename, file in audio_archive:
261
- # _, filename = os.path.split(filename)
262
- # audio_id = filename.replace(".wav", "")
263
- # if audio_id in metadata:
264
- # result = dict(metadata[audio_id])
265
- # # set the audio feature and the path to the extracted file
266
- # path = os.path.join(local_extracted_archive_paths[i], filename) if local_extracted_archive_paths else filename
267
- # result["audio"] = {"path": path, "bytes": file.read()}
268
- # result["audio_id"] = audio_id # add audio_id to the metadata
269
- # # set path to None if the audio file doesn't exist locally (i.e. in streaming mode)
270
- # result["audio_path"] = path if local_extracted_archive_paths else filename
271
-
272
- # yield path, result
273
-
 
67
  if os.path.exists(self.config.data_root_url + "/" + split + "/transcripts.txt"):
68
  _transcripts[split] = self.config.data_root_url + "/" + split + "/transcripts.txt"
69
  _audio_filenames[split] = self.config.data_root_url + "/" + split + "/audio_filenames.txt"
70
+
71
+ if self.config.name in ["hausa", "wolof"]:
72
+ transcripts = dl_manager.download({
73
+ "train": self.config.data_root_url + "/train/transcripts.txt",
74
+ "dev": self.config.data_root_url + "/dev/transcripts.txt",
75
+ "test": self.config.data_root_url + "/test/transcripts.txt",
76
+ })
77
+ audio_filenames_paths = dl_manager.download({
78
+ "train": self.config.data_root_url + "/train/audio_filenames.txt",
79
+ "dev": self.config.data_root_url + "/dev/audio_filenames.txt",
80
+ "test": self.config.data_root_url + "/test/audio_filenames.txt",
81
+ })
82
+ else:
83
+ transcripts = dl_manager.download({
84
+ "train": self.config.data_root_url + "/train/transcripts.txt",
85
+ "test": self.config.data_root_url + "/test/transcripts.txt",
86
+ })
87
+
88
+ audio_filenames_paths = dl_manager.download({
89
+ "train": self.config.data_root_url + "/train/audio_filenames.txt",
90
+ "test": self.config.data_root_url + "/test/audio_filenames.txt",
91
+ })
92
+
93
 
94
  transcripts = dl_manager.download(_transcripts)
95
 
 
167
 
168
 
169