From 6397febe5d5cbd9c1a771a04f9bf248b4f705338 Mon Sep 17 00:00:00 2001 From: Joe Weiss Date: Wed, 24 Apr 2024 11:28:03 -0400 Subject: [PATCH 1/2] Add ability to handle length too small error from librosa --- src/birdnetlib/utils.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/birdnetlib/utils.py b/src/birdnetlib/utils.py index 0853c82..bbd744e 100644 --- a/src/birdnetlib/utils.py +++ b/src/birdnetlib/utils.py @@ -30,14 +30,18 @@ def read_audio_segments( start_sample = 0 while True: - audio_chunk, _ = librosa.load( - file_path, - sr=sr, - mono=True, - offset=start_sample / sr, - duration=chunk_duration, - res_type="kaiser_fast", - ) + try: + audio_chunk, _ = librosa.load( + file_path, + sr=sr, + mono=True, + offset=start_sample / sr, + duration=chunk_duration, + res_type="kaiser_fast", + ) + except ValueError: + # Specifically to catch "ValueError: Input signal length=0 is too small to resample" + break # Check if the chunk is empty, indicating the end of the file if not audio_chunk.any(): From d77f3c25453d969aac8f15704509b1e19aa5360f Mon Sep 17 00:00:00 2001 From: Joe Weiss Date: Wed, 24 Apr 2024 11:28:44 -0400 Subject: [PATCH 2/2] Bump for 0.17.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4cc3252..9a6c076 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ exclude = [ [project] name = "birdnetlib" -version = "0.17.1" +version = "0.17.2" authors = [ { name="Joe Weiss", email="joe.weiss@gmail.com" }, ]