Commit
•
29bc121
1
Parent(s):
2543b30
new generate_examples method
Browse files- libri_light.py +19 -22
libri_light.py
CHANGED
@@ -17,6 +17,9 @@
|
|
17 |
"""Libri-Light audio dataset."""
|
18 |
|
19 |
|
|
|
|
|
|
|
20 |
import json
|
21 |
|
22 |
import datasets
|
@@ -147,25 +150,19 @@ class LibriLight(datasets.GeneratorBasedBuilder):
|
|
147 |
),
|
148 |
]
|
149 |
|
150 |
-
def _generate_examples(self,
|
151 |
-
|
152 |
-
key
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
"file": file,
|
167 |
-
"audio": audio,
|
168 |
-
"speaker_id": speaker_id,
|
169 |
-
# "metadata": metadata,
|
170 |
-
}
|
171 |
-
key += 1
|
|
|
17 |
"""Libri-Light audio dataset."""
|
18 |
|
19 |
|
20 |
+
import glob
|
21 |
+
import os
|
22 |
+
|
23 |
import json
|
24 |
|
25 |
import datasets
|
|
|
150 |
),
|
151 |
]
|
152 |
|
153 |
+
def _generate_examples(self, archive_path):
|
154 |
+
paths = glob.glob(os.path.join(archive_path, "**", "**", "*.flac"))
|
155 |
+
for key, path in enumerate(paths):
|
156 |
+
path_split = path.split("/")
|
157 |
+
id_ = path_split[-1].replace(".flac", "")
|
158 |
+
speaker_id = int(path_split[-3])
|
159 |
+
#path_json = path.replace(".flac", ".json")
|
160 |
+
#with open(path_json) as json_file:
|
161 |
+
# metadata = json.load(json_file)
|
162 |
+
yield key, {
|
163 |
+
"id": id_,
|
164 |
+
"file": path,
|
165 |
+
"audio": path,
|
166 |
+
"speaker_id": speaker_id,
|
167 |
+
# "metadata": metadata,
|
168 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|