Add wave.Error in clause when loading audio
Sometimes this gets thrown
This commit is contained in:
parent
d2d9c34931
commit
d5441f4898
@ -46,9 +46,10 @@ def load_audio(file: Any) -> np.ndarray:
|
|||||||
samples: Sample rate and audio samples from 0..1
|
samples: Sample rate and audio samples from 0..1
|
||||||
"""
|
"""
|
||||||
import wavio
|
import wavio
|
||||||
|
import wave
|
||||||
try:
|
try:
|
||||||
wav = wavio.read(file)
|
wav = wavio.read(file)
|
||||||
except EOFError:
|
except (EOFError, wave.Error):
|
||||||
wav = wavio.Wav(np.array([[]], dtype=np.int16), 16000, 2)
|
wav = wavio.Wav(np.array([[]], dtype=np.int16), 16000, 2)
|
||||||
if wav.data.dtype != np.int16:
|
if wav.data.dtype != np.int16:
|
||||||
raise InvalidAudio('Unsupported data type: ' + str(wav.data.dtype))
|
raise InvalidAudio('Unsupported data type: ' + str(wav.data.dtype))
|
||||||
|
Loading…
Reference in New Issue
Block a user