Emilio Marinone
commited on
Commit
•
978d592
1
Parent(s):
893ddcf
avoid dicts in dataset
Browse files
nst_sv.py
CHANGED
@@ -115,45 +115,30 @@ class NstSV(datasets.GeneratorBasedBuilder):
|
|
115 |
|
116 |
def _info(self):
|
117 |
features_dict = {
|
118 |
-
"
|
119 |
-
|
120 |
-
|
121 |
-
"Region_of_Youth": datasets.Value("string"),
|
122 |
-
"Remarks": datasets.Value("string"),
|
123 |
-
"Sex": datasets.Value("string"),
|
124 |
-
"Speaker_ID": datasets.Value("string"),
|
125 |
-
},
|
126 |
-
"metadata": {
|
127 |
-
"file": datasets.Value("string"),
|
128 |
-
"lang": datasets.Value("string"),
|
129 |
-
"path": datasets.Value("string"),
|
130 |
-
"station": datasets.Value("string"),
|
131 |
-
},
|
132 |
"pid": datasets.Value("string"),
|
133 |
-
"
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
"
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
"Memo": datasets.Value("string"),
|
154 |
-
"Script": datasets.Value("string"),
|
155 |
-
"Version": datasets.Value("string"),
|
156 |
-
},
|
157 |
"audio": datasets.features.Audio(sampling_rate=16000),
|
158 |
'client_id': datasets.Value("string"),
|
159 |
'path': datasets.Value("string"),
|
@@ -161,7 +146,7 @@ class NstSV(datasets.GeneratorBasedBuilder):
|
|
161 |
'up_votes': datasets.Value("int32"),
|
162 |
'down_votes': datasets.Value("int32"),
|
163 |
'age': datasets.Value("string"),
|
164 |
-
'
|
165 |
'accent': datasets.Value("string"),
|
166 |
'locale': datasets.Value("string"),
|
167 |
'segment': datasets.Value("string"),
|
@@ -264,65 +249,46 @@ class NstSV(datasets.GeneratorBasedBuilder):
|
|
264 |
with open(audio_filepath, "rb") as f:
|
265 |
audio_bytes = f.read()
|
266 |
if audio_bytes:
|
267 |
-
|
268 |
-
"
|
269 |
-
"
|
270 |
-
"
|
271 |
-
"
|
272 |
-
"
|
273 |
-
"
|
274 |
-
|
275 |
-
|
276 |
-
"
|
277 |
-
"
|
278 |
-
"
|
279 |
-
"
|
280 |
-
|
281 |
-
|
282 |
-
"
|
283 |
-
"
|
284 |
-
"
|
285 |
-
"
|
286 |
-
"
|
287 |
-
"
|
288 |
-
"
|
289 |
-
"
|
290 |
-
|
291 |
-
|
292 |
-
"
|
293 |
-
|
294 |
-
"ByteFormat": annotation["system"]["ByteFormat"] or "",
|
295 |
-
"Channels": annotation["system"]["Channels"] or "",
|
296 |
-
"CharacterSet": annotation["system"]["CharacterSet"] or "",
|
297 |
-
"Coding": annotation["system"]["Coding"] or "",
|
298 |
-
"DOS_Codepage": annotation["system"]["DOS_Codepage"] or "",
|
299 |
-
"Delimiter": annotation["system"]["Delimiter"] or "",
|
300 |
-
"Frequency": annotation["system"]["Frequency"] or "",
|
301 |
-
"Memo": annotation["system"]["Memo"] or "",
|
302 |
-
"Script": annotation["system"]["Script"] or "",
|
303 |
-
"Version": annotation["system"]["Version"] or "",
|
304 |
-
},
|
305 |
-
result = {
|
306 |
-
"info": info_dict,
|
307 |
-
"metadata": metadata_dict,
|
308 |
-
"pid": annotation["pid"],
|
309 |
-
"session": session_dict,
|
310 |
-
"system": system_dict,
|
311 |
-
"client_id": annotation["info"]["Speaker_ID"] or "",
|
312 |
'path': rel_filepath,
|
313 |
-
'audio': {"path": rel_filepath, "bytes": audio_bytes},
|
314 |
'sentence': recording["text"],
|
315 |
-
'up_votes':
|
316 |
'down_votes': 0,
|
317 |
-
'age':annotation["info"]["Age"] or "",
|
318 |
-
'
|
319 |
'accent': "",
|
320 |
'locale': "sv",
|
321 |
'segment': "",
|
322 |
-
'channel': self.config.name
|
323 |
}
|
324 |
print(f"Yielding {rel_filepath}")
|
325 |
-
yield rel_filepath,
|
326 |
|
327 |
else:
|
328 |
files_failed_loading.append(rel_filepath)
|
|
|
115 |
|
116 |
def _info(self):
|
117 |
features_dict = {
|
118 |
+
"region_of_birth": datasets.Value("string"),
|
119 |
+
"region_of_youth": datasets.Value("string"),
|
120 |
+
"remarks": datasets.Value("string"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
"pid": datasets.Value("string"),
|
122 |
+
"directory": datasets.Value("string"),
|
123 |
+
"imported_sheet_file": datasets.Value("string"),
|
124 |
+
"mumber_of_recordings": datasets.Value("string"),
|
125 |
+
"rec_date": datasets.Value("string"),
|
126 |
+
"rec_time": datasets.Value("string"),
|
127 |
+
"record_duration": datasets.Value("string"),
|
128 |
+
"record_session": datasets.Value("string"),
|
129 |
+
"sheet_number": datasets.Value("string"),
|
130 |
+
"ansi_codepage": datasets.Value("string"),
|
131 |
+
"board": datasets.Value("string"),
|
132 |
+
"byte_format": datasets.Value("string"),
|
133 |
+
"channels": datasets.Value("string"),
|
134 |
+
"character_set": datasets.Value("string"),
|
135 |
+
"coding": datasets.Value("string"),
|
136 |
+
"dos_codepage": datasets.Value("string"),
|
137 |
+
"delimiter": datasets.Value("string"),
|
138 |
+
"frequency": datasets.Value("string"),
|
139 |
+
"memo": datasets.Value("string"),
|
140 |
+
"script": datasets.Value("string"),
|
141 |
+
"version": datasets.Value("string"),
|
|
|
|
|
|
|
|
|
142 |
"audio": datasets.features.Audio(sampling_rate=16000),
|
143 |
'client_id': datasets.Value("string"),
|
144 |
'path': datasets.Value("string"),
|
|
|
146 |
'up_votes': datasets.Value("int32"),
|
147 |
'down_votes': datasets.Value("int32"),
|
148 |
'age': datasets.Value("string"),
|
149 |
+
'sex': datasets.Value("string"),
|
150 |
'accent': datasets.Value("string"),
|
151 |
'locale': datasets.Value("string"),
|
152 |
'segment': datasets.Value("string"),
|
|
|
249 |
with open(audio_filepath, "rb") as f:
|
250 |
audio_bytes = f.read()
|
251 |
if audio_bytes:
|
252 |
+
results = {
|
253 |
+
"region_of_birth": annotation["info"]["Region_of_Birth"] or "",
|
254 |
+
"region_of_youth": annotation["info"]["Region_of_Youth"] or "",
|
255 |
+
"remarks": annotation["info"]["Remarks"] or "",
|
256 |
+
"pid": annotation["pid"] or "",
|
257 |
+
"directory": annotation["session"]["Directory"] or "",
|
258 |
+
"imported_sheet_file": annotation["session"]["Imported_sheet_file"] or "",
|
259 |
+
"mumber_of_recordings": annotation["session"]["Number_of_recordings"] or "",
|
260 |
+
"rec_date": annotation["session"]["RecDate"] or "",
|
261 |
+
"rec_time": annotation["session"]["RecTime"] or "",
|
262 |
+
"record_duration": annotation["session"]["Record_duration"] or "",
|
263 |
+
"record_session": annotation["session"]["Record_session"] or "",
|
264 |
+
"sheet_number": annotation["session"]["Sheet_number"] or "",
|
265 |
+
"ansi_codepage": annotation["system"]["ANSI_Codepage"] or "",
|
266 |
+
"board": annotation["system"]["Board"] or "",
|
267 |
+
"byte_format": annotation["system"]["ByteFormat"] or "",
|
268 |
+
"channels": annotation["system"]["Channels"] or "",
|
269 |
+
"character_set": annotation["system"]["CharacterSet"] or "",
|
270 |
+
"coding": annotation["system"]["Coding"] or "",
|
271 |
+
"dos_codepage": annotation["system"]["DOS_Codepage"] or "",
|
272 |
+
"delimiter": annotation["system"]["Delimiter"] or "",
|
273 |
+
"frequency": annotation["system"]["Frequency"] or "",
|
274 |
+
"memo": annotation["system"]["Memo"] or "",
|
275 |
+
"script": annotation["system"]["Script"] or "",
|
276 |
+
"version": annotation["system"]["Version"] or "",
|
277 |
+
"audio": {"path": rel_filepath, "bytes": audio_bytes},
|
278 |
+
'client_id': annotation["info"]["Speaker_ID"] or "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
'path': rel_filepath,
|
|
|
280 |
'sentence': recording["text"],
|
281 |
+
'up_votes': 1,
|
282 |
'down_votes': 0,
|
283 |
+
'age': annotation["info"]["Age"] or "",
|
284 |
+
'sex': annotation["info"]["Sex"] or "",
|
285 |
'accent': "",
|
286 |
'locale': "sv",
|
287 |
'segment': "",
|
288 |
+
'channel': self.config.name or ""
|
289 |
}
|
290 |
print(f"Yielding {rel_filepath}")
|
291 |
+
yield rel_filepath, results
|
292 |
|
293 |
else:
|
294 |
files_failed_loading.append(rel_filepath)
|