Datasets:
Decode Error
#2
by brthor - opened
There are about 78 rows in the large dataset subset currently experiencing a decode error due to issues with 4 malformed/corrupted librivox source files.
An immediate fix is not planned, and it is recommended to use a workaround if you are hitting this error. Something like this should suffice for many use cases:
class ZeroOnErrorAudio(datasets.Audio):
def decode_example(
self, value: dict, token_per_repo_id: Optional[Dict[str, Union[str, bool, None]]] = None
) -> dict:
try:
return super().decode_example(value, token_per_repo_id=token_per_repo_id)
except Exception as exc:
traceback.print_exc()
print('audio load err', exc)
print(value)
# return silence so processing likely still works
return {"path": value['path'], "array": np.zeros((self.sampling_rate, ), dtype=np.float32), "sampling_rate": self.sampling_rate}
Then
dset = load_dataset('mythicinfinity/libriheavy', 'large')
# You may want to set sampling_rate, etc here
dset = dset.cast_column('audio', ZeroOnErrorAudio())
Exact workarounds will differ by use-case. In my own scripts I catch the error in an outer dataset iteration wrapper and simply return the next sample instead.