Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with librosa.load #114

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
]
Expand Down
20 changes: 12 additions & 8 deletions src/birdnetlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading