Commit
·
27520da
1
Parent(s):
7422449
fix metadata reading
Browse files- afrispeech-200.py +3 -5
afrispeech-200.py
CHANGED
|
@@ -134,17 +134,15 @@ class AfriSpeech(datasets.GeneratorBasedBuilder):
|
|
| 134 |
# from the dataset.
|
| 135 |
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
| 136 |
|
| 137 |
-
data_fields =
|
| 138 |
metadata = {}
|
| 139 |
with open(meta_path, "r", encoding="utf-8") as f:
|
| 140 |
reader = csv.DictReader(f)
|
| 141 |
for row in tqdm(reader, desc="Reading metadata..."):
|
| 142 |
row["speaker_id"] = row["user_ids"]
|
|
|
|
| 143 |
# if data is incomplete, fill with empty values
|
| 144 |
-
for field in data_fields
|
| 145 |
-
if field not in row:
|
| 146 |
-
row[field] = ""
|
| 147 |
-
metadata[row["audio_paths"].split("/")[-1]] = row
|
| 148 |
|
| 149 |
for i, audio_archive in enumerate(archives):
|
| 150 |
for filename, file in audio_archive:
|
|
|
|
| 134 |
# from the dataset.
|
| 135 |
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
| 136 |
|
| 137 |
+
data_fields = [key for key in self._info().features.keys() if key not in ["audio", "path"]]
|
| 138 |
metadata = {}
|
| 139 |
with open(meta_path, "r", encoding="utf-8") as f:
|
| 140 |
reader = csv.DictReader(f)
|
| 141 |
for row in tqdm(reader, desc="Reading metadata..."):
|
| 142 |
row["speaker_id"] = row["user_ids"]
|
| 143 |
+
audio_id = row["audio_paths"].split("/")[-1]
|
| 144 |
# if data is incomplete, fill with empty values
|
| 145 |
+
metadata[audio_id] = {field: row.get(field, "") for field in data_fields}
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
for i, audio_archive in enumerate(archives):
|
| 148 |
for filename, file in audio_archive:
|