Skip to content

Conversation

@Josef-Haupt
Copy link
Member

No description provided.

@Josef-Haupt Josef-Haupt marked this pull request as ready for review June 16, 2025 10:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issues with timestamp calculations when different audio speeds and overlaps are used in the analysis. Key changes include updating tests to verify error conditions for invalid audio speeds and overlaps, modifying the timestamp calculations in the analysis utils, and adding parameter validation for overlap and audio speed in the core parameters setter.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/analyze/test_analyze.py Updated and added tests to verify error handling for invalid audio_speed and overlap values, and refined expected timestamp calculations.
pyproject.toml Added pytest-timeout dependency and set a timeout for tests.
birdnet_analyzer/analyze/utils.py Adjusted timestamp calculations to incorporate audio speed adjustments.
birdnet_analyzer/analyze/core.py Added parameter validation for overlap and audio_speed.

soundscape_path = "birdnet_analyzer/example/soundscape.wav"

assert os.path.exists(soundscape_path), "Soundscape file does not exist"
file_length = 120
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding inline comments to clarify the logic behind calculating step_size and how audio_speed and overlap interact to produce the expected timestamp intervals.

Suggested change
file_length = 120
file_length = 120
# Calculate the step size for timestamp intervals:
# - 3 * audio_speed: Duration of a segment after speeding up the audio.
# - overlap * audio_speed: Duration of the overlapping portion between consecutive segments.
# The step size is the effective interval between the start of consecutive segments.

Copilot uses AI. Check for mistakes.
Comment on lines 631 to +632
# Advance start and end
start += cfg.SIG_LENGTH - cfg.SIG_OVERLAP
end = start + cfg.SIG_LENGTH
start += (cfg.SIG_LENGTH - cfg.SIG_OVERLAP) * cfg.AUDIO_SPEED
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that applying the audio speed multiplier here consistently adjusts the timestamp calculations; adding an inline comment to explain this rationale would improve clarity for future maintainers.

Copilot uses AI. Check for mistakes.
@Josef-Haupt Josef-Haupt merged commit 928bf9f into main Jun 16, 2025
4 checks passed
@Josef-Haupt Josef-Haupt deleted the fix-speed-overlap branch June 16, 2025 15:13
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.

Batch analysis with audio speed modification doesn't run on full files

2 participants