Skip to content

Commit 5dd79ad

Browse files
Conchylicultorcopybara-github
authored andcommitted
Improve debug message for audio file encoding (Fix #2513)
PiperOrigin-RevId: 335587214
1 parent 89f4fe6 commit 5dd79ad

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tensorflow_datasets/core/features/audio_feature.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ def encode_example(self, audio_or_path_or_fobj):
7474
filename = audio_or_path_or_fobj
7575
file_format = self._file_format or filename.split('.')[-1]
7676
with tf.io.gfile.GFile(filename, 'rb') as audio_f:
77-
return self._encode_file(audio_f, file_format)
77+
try:
78+
return self._encode_file(audio_f, file_format)
79+
except Exception as e: # pylint: disable=broad-except
80+
utils.reraise(e, prefix=f'Error for {filename}: ')
7881
else:
7982
return self._encode_file(audio_or_path_or_fobj, self._file_format)
8083

0 commit comments

Comments
 (0)