lhoestq HF Staff commited on
Commit
ed4ac4a
·
verified ·
1 Parent(s): c3e21b5

Update superb.py

Browse files
Files changed (1) hide show
  1. superb.py +20 -48
superb.py CHANGED
@@ -294,42 +294,6 @@ class Superb(datasets.GeneratorBasedBuilder):
294
  ),
295
  ]
296
 
297
- @property
298
- def manual_download_instructions(self):
299
- if self.config.name == "si":
300
- return textwrap.dedent(
301
- """
302
- Please download the VoxCeleb dataset using the following script,
303
- which should create `VoxCeleb1/wav/id*` directories for both train and test speakers`:
304
- ```
305
- mkdir VoxCeleb1
306
- cd VoxCeleb1
307
-
308
- wget https://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_dev_wav_partaa
309
- wget https://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_dev_wav_partab
310
- wget https://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_dev_wav_partac
311
- wget https://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_dev_wav_partad
312
- cat vox1_dev* > vox1_dev_wav.zip
313
- unzip vox1_dev_wav.zip
314
-
315
- wget https://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_test_wav.zip
316
- unzip vox1_test_wav.zip
317
-
318
- # download the official SUPERB train-dev-test split
319
- wget https://raw.githubusercontent.com/s3prl/s3prl/master/s3prl/downstream/voxceleb1/veri_test_class.txt
320
- ```"""
321
- )
322
- elif self.config.name == "er":
323
- return textwrap.dedent(
324
- """
325
- Please download the IEMOCAP dataset after submitting the request form here:
326
- https://sail.usc.edu/iemocap/iemocap_release.htm
327
- Having downloaded the dataset you can extract it with `tar -xvzf IEMOCAP_full_release.tar.gz`
328
- which should create a folder called `IEMOCAP_full_release`
329
- """
330
- )
331
- return None
332
-
333
  def _info(self):
334
  return datasets.DatasetInfo(
335
  description=_DESCRIPTION,
@@ -390,15 +354,19 @@ class Superb(datasets.GeneratorBasedBuilder):
390
  ),
391
  ]
392
  elif self.config.name == "si":
393
- manual_dir = os.path.abspath(os.path.expanduser(dl_manager.manual_dir))
 
 
 
 
394
  return [
395
  datasets.SplitGenerator(
396
  name=datasets.Split.TRAIN,
397
- gen_kwargs={"archive_path": manual_dir, "split": 1},
398
  ),
399
  datasets.SplitGenerator(
400
  name=datasets.Split.VALIDATION,
401
- gen_kwargs={"archive_path": manual_dir, "split": 2},
402
  ),
403
  datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"archive_path": manual_dir, "split": 3}),
404
  ]
@@ -419,7 +387,9 @@ class Superb(datasets.GeneratorBasedBuilder):
419
  for split in splits
420
  ]
421
  elif self.config.name == "er":
422
- manual_dir = os.path.abspath(os.path.expanduser(dl_manager.manual_dir))
 
 
423
  return [
424
  datasets.SplitGenerator(
425
  name=f"session{i}",
@@ -483,20 +453,22 @@ class Superb(datasets.GeneratorBasedBuilder):
483
  "location": location,
484
  }
485
  elif self.config.name == "si":
486
- wav_path = os.path.join(archive_path, "wav")
487
- splits_path = os.path.join(archive_path, "veri_test_class.txt")
488
  with open(splits_path, "r", encoding="utf-8") as f:
489
  for key, line in enumerate(f):
490
  split_id, file_path = line.strip().split(" ")
491
  if int(split_id) != split:
492
  continue
493
  speaker_id = file_path.split("/")[0]
494
- audio_path = os.path.join(wav_path, file_path)
495
- yield key, {
496
- "file": audio_path,
497
- "audio": audio_path,
498
- "label": speaker_id,
499
- }
 
 
 
500
  elif self.config.name == "sd":
501
  data = SdData(archive_path)
502
  args = SdArgs()
 
294
  ),
295
  ]
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  def _info(self):
298
  return datasets.DatasetInfo(
299
  description=_DESCRIPTION,
 
354
  ),
355
  ]
356
  elif self.config.name == "si":
357
+ archive_path = (
358
+ dl_manager.download_and_extract("https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav.zip"),
359
+ dl_manager.download_and_extract("https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_test_wav.zip"),
360
+ dl_manager.download_and_extract("https://raw.githubusercontent.com/s3prl/s3prl/master/s3prl/downstream/voxceleb1/veri_test_class.txt"),
361
+ )
362
  return [
363
  datasets.SplitGenerator(
364
  name=datasets.Split.TRAIN,
365
+ gen_kwargs={"archive_path": archive_path, "split": 1},
366
  ),
367
  datasets.SplitGenerator(
368
  name=datasets.Split.VALIDATION,
369
+ gen_kwargs={"archive_path": archive_path, "split": 2},
370
  ),
371
  datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"archive_path": manual_dir, "split": 3}),
372
  ]
 
387
  for split in splits
388
  ]
389
  elif self.config.name == "er":
390
+ archive_path = (
391
+ dl_manager.download_and_extract("https://huggingface.co/datasets/lhoestq/IEMOCAP_full_release/resolve/main/IEMOCAP_full_release.zip")
392
+ )
393
  return [
394
  datasets.SplitGenerator(
395
  name=f"session{i}",
 
453
  "location": location,
454
  }
455
  elif self.config.name == "si":
456
+ *archives_dirs, splits_path = archive_path
 
457
  with open(splits_path, "r", encoding="utf-8") as f:
458
  for key, line in enumerate(f):
459
  split_id, file_path = line.strip().split(" ")
460
  if int(split_id) != split:
461
  continue
462
  speaker_id = file_path.split("/")[0]
463
+ for archive_dir in archives_dirs: # in one or the other
464
+ wav_path = os.path.join(archive_dir, "wav")
465
+ audio_path = os.path.join(wav_path, file_path)
466
+ if os.path.exists(audio_path):
467
+ yield key, {
468
+ "file": audio_path,
469
+ "audio": audio_path,
470
+ "label": speaker_id,
471
+ }
472
  elif self.config.name == "sd":
473
  data = SdData(archive_path)
474
  args = SdArgs()