macaodha / batdetect2

Other
48 stars 9 forks source link

Doesn't handle 0 length audio files gracfully #20

Open EvansMike opened 11 months ago

EvansMike commented 11 months ago

Some of the files my AudioMoth recorded were empty causing the output below.

 0 run/media/mikee/boot/20231007_234400.WAV
 /home/mikee/.local/lib/python3.11/site-packages/batdetect2/utils/audio_utils.py:147: UserWarning: PySoundFile failed.  Trying audioread instead.
 audio_raw, sampling_rate = librosa.load(
 /home/mikee/.local/lib/python3.11/site-packages/librosa/core/audio.py:183: FutureWarning:  librosa.core.audio.__audioread_load
 Deprecated as of librosa version 0.10.0.
 It will be removed in librosa version 1.0.
 y, sr_native = __audioread_load(path, offset, duration, dtype)

 Aborted!

I simply removed the empty files to fix the issue but maybe these should be handled gracefully within batdetect2?

macaodha commented 11 months ago

Thanks for the heads up. Can you share an example of a file that broke it. You can email it to me if too big to link here. Email address is on my website. Thanks!

EvansMike commented 11 months ago

Any empty file with the .wav extension. As in linux : touch bat.wav I suspect that the SD card ran out of space and AudioMoth kept making files that were truncated to zero bytes.

Edit: I've added a zero length file.