Skip to content

Commit

Permalink
Improve debug message for audio file encoding (Fix #2513)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 335587214
  • Loading branch information
Conchylicultor authored and copybara-github committed Oct 6, 2020
1 parent 89f4fe6 commit 5dd79ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tensorflow_datasets/core/features/audio_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5dd79ad

Please sign in to comment.