AymanElmar commited on
Commit ·
b2ff34a
1
Parent(s): ce89bc8
targz
Browse files
joha.py
CHANGED
|
@@ -139,26 +139,14 @@ class johaDataset(datasets.GeneratorBasedBuilder):
|
|
| 139 |
# Else, read the audio file and yield an example
|
| 140 |
for path, f in archive_iterator:
|
| 141 |
if path.startswith(path_to_clips +"/data"):
|
| 142 |
-
if not metadata_found:
|
| 143 |
-
raise FileNotFoundError(
|
| 144 |
-
"The metadata file %s was not found in the archive %s" % (metadata_filepath, archive_iterator.archive_path)
|
| 145 |
-
)
|
| 146 |
-
if not all_field_values:
|
| 147 |
-
break
|
| 148 |
if path in all_field_values:
|
| 149 |
# retrieve the metadata corresponding to this audio file
|
| 150 |
field_values = all_field_values[path]
|
| 151 |
|
| 152 |
-
# if data is incomplete, fill with empty values
|
| 153 |
-
if len(field_values) < len(data_fields):
|
| 154 |
-
field_values += (len(data_fields) - len(field_values)) * ["''"]
|
| 155 |
-
|
| 156 |
result = {key: value for key, value in zip(data_fields, field_values)}
|
| 157 |
|
| 158 |
-
|
| 159 |
-
path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
|
| 160 |
result["audio"] = {"path": path, "bytes": f.read()}
|
| 161 |
# set path to None if the audio file doesn't exist locally (i.e. in streaming mode)
|
| 162 |
-
result["path"] = path if local_extracted_archive else None
|
| 163 |
|
| 164 |
yield path, result
|
|
|
|
| 139 |
# Else, read the audio file and yield an example
|
| 140 |
for path, f in archive_iterator:
|
| 141 |
if path.startswith(path_to_clips +"/data"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
if path in all_field_values:
|
| 143 |
# retrieve the metadata corresponding to this audio file
|
| 144 |
field_values = all_field_values[path]
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
result = {key: value for key, value in zip(data_fields, field_values)}
|
| 147 |
|
| 148 |
+
|
|
|
|
| 149 |
result["audio"] = {"path": path, "bytes": f.read()}
|
| 150 |
# set path to None if the audio file doesn't exist locally (i.e. in streaming mode)
|
|
|
|
| 151 |
|
| 152 |
yield path, result
|