Edmon02 commited on
Commit
ce0d7c4
1 Parent(s): 1e897e6

Update hyvoxpopuli.py

Browse files
Files changed (1) hide show
  1. hyvoxpopuli.py +16 -16
hyvoxpopuli.py CHANGED
@@ -80,19 +80,19 @@ class Hyvoxpopuli(datasets.GeneratorBasedBuilder):
80
  ]
81
 
82
  def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
83
- features = ["raw_text", "normalized_text", "speaker_id", "gender", "is_gold_transcript", "accent"]
84
-
85
- for split, meta_path in metadata_paths.items():
86
- with open(meta_path) as f:
87
- metadata = {x["id"]: x for x in csv.DictReader(f, delimiter="\t")}
88
-
89
- for audio_archive, local_extracted_archive_path in zip(audio_archives[split], local_extracted_archives_paths[split]):
90
- for audio_filename, audio_file in audio_archive:
91
- audio_id = audio_filename.split(os.sep)[-1].split(".wav")[0]
92
- path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
93
-
94
- yield audio_id, {
95
- "audio_id": audio_id,
96
- **{feature: metadata[audio_id][feature] for feature in features},
97
- "audio": {"path": path, "bytes": audio_file.read()},
98
- }
 
80
  ]
81
 
82
  def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
83
+ features = ["raw_text", "normalized_text", "speaker_id", "gender", "is_gold_transcript", "accent"]
84
+
85
+ for split, meta_path in metadata_paths.items():
86
+ with open(meta_path) as f:
87
+ metadata = {x["id"]: x for x in csv.DictReader(f, delimiter="\t")}
88
+
89
+ for audio_archive, local_extracted_archive_path in zip(audio_archives[split], local_extracted_archives_paths[split]):
90
+ for audio_filename, audio_file in audio_archive:
91
+ audio_id = audio_filename.split(os.sep)[-1].split(".wav")[0]
92
+ path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
93
+
94
+ yield audio_id, {
95
+ "audio_id": audio_id,
96
+ **{feature: metadata[audio_id][feature] for feature in features},
97
+ "audio": {"path": path, "bytes": audio_file.read()},
98
+ }