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: Resolve detect Command Failure with Specific Audio Files (GH-31) #36

Merged
merged 7 commits into from
Nov 10, 2024

Conversation

mbsantiago
Copy link
Collaborator

This PR addresses issue #31, where the detect command failed to process a set of 5 audio recordings provided by @Jeff37.

The root cause was traced to the batdetect2.utils.audio_utils.pad_audio function, which incorrectly handled cases with short audio inputs. This function prepares audio data for the batdetect2 model by padding it to ensure the resulting spectrogram has dimensions compatible with the model's downsampling and upsampling layers.

To resolve this:

  • Refactored pad_audio for improved clarity and correctness, introducing helper functions for spectrogram width calculations and audio sample conversions.
  • Added unit tests for pad_audio and the new helper functions to ensure proper functionality.
  • Included an integration test that runs the detect command on the problematic audio files provided by @Jeff37, verifying the fix.

All tests now pass, confirming that the issue has been resolved.

Key changes in this PR:

Acknowledgments:

Many thanks to @Jeff37 for reporting this issue and providing the valuable test files.

@mbsantiago mbsantiago linked an issue Nov 10, 2024 that may be closed by this pull request
@mbsantiago mbsantiago merged commit 7dc2869 into main Nov 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error processing file!: negative dimensions are not allowed
1 participant