diff --git a/tensorflow_datasets/core/features/audio_feature.py b/tensorflow_datasets/core/features/audio_feature.py index 05b3a5e4dec..7f5e6561e2b 100644 --- a/tensorflow_datasets/core/features/audio_feature.py +++ b/tensorflow_datasets/core/features/audio_feature.py @@ -74,7 +74,10 @@ def encode_example(self, audio_or_path_or_fobj): filename = audio_or_path_or_fobj file_format = self._file_format or filename.split('.')[-1] with tf.io.gfile.GFile(filename, 'rb') as audio_f: - return self._encode_file(audio_f, file_format) + try: + return self._encode_file(audio_f, file_format) + except Exception as e: # pylint: disable=broad-except + utils.reraise(e, prefix=f'Error for {filename}: ') else: return self._encode_file(audio_or_path_or_fobj, self._file_format)