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

270 task add 20 aqms to bioacoustic qc #279

Draft
wants to merge 23 commits into
base: 276-feature-implement-bioacoustic-quality-control-framework
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
47e2289
Add metrics field to taxonomy tree
ibevers Mar 14, 2025
788f1fc
Rename check_node to evalutate_node
ibevers Mar 14, 2025
3a9b124
Use generic audio_quality_check function with lambdas
ibevers Mar 14, 2025
85ab4ed
Update checks to return evaluated boolean
ibevers Mar 14, 2025
0281590
Update audio_quality_check to store results in df
ibevers Mar 14, 2025
dabcc47
Move, rename, and optimize audio quality check function
ibevers Mar 14, 2025
7eeac7b
Update evaluate_node to update a dataframe and calculate metrics
ibevers Mar 14, 2025
44ccc93
Update check_quality to take df parameter
ibevers Mar 14, 2025
42522db
Update metrics and checks default to empty list
ibevers Mar 14, 2025
9c36d7a
Update hardcoded test trees to reflect new structure
ibevers Mar 14, 2025
a02886b
Update test_evaluate_node and invert check conditions
ibevers Mar 14, 2025
8946b06
Update test_run_taxonomy_subtree_checks_recursively
ibevers Mar 14, 2025
2c1d681
Update test_check_quality
ibevers Mar 14, 2025
ea31043
Add metrics.py
ibevers Mar 14, 2025
68edaac
Add proportion_silent_metric
ibevers Mar 14, 2025
f7f1ef0
Add normalize method and normalized instance var
ibevers Mar 14, 2025
459e652
Add test_audio_normalize
ibevers Mar 14, 2025
5e55cc1
Merge branch '280-task-add-normalize-method-to-audio' into 270-task-a…
ibevers Mar 14, 2025
5b5fe6e
Update proportion_silent_metric to use normalize method and normalize…
ibevers Mar 14, 2025
0d8411b
Add proportion_silence_at_beginning_metric
ibevers Mar 14, 2025
3292380
Add bioacoustic qc metric tests
ibevers Mar 14, 2025
231e3e1
Add proportion_silence_at_end_metric
ibevers Mar 14, 2025
f7125ba
Add proportion_silence_at_end_metric test
ibevers Mar 14, 2025
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
Prev Previous commit
Next Next commit
Add test_audio_normalize
ibevers committed Mar 14, 2025
commit 459e652ac193d21a3c0989b5d0021801e03599db
20 changes: 20 additions & 0 deletions src/tests/audio/data_structures/audio_test.py
Original file line number Diff line number Diff line change
@@ -235,3 +235,23 @@ def test_window_generator_step_greater_than_audio(audio_fixture: str, request: p
expected_windows = (audio_length - window_size) // step_size + 1 # This is always 1
assert len(windowed_audios) == expected_windows, f"Should yield {expected_windows} \
windows when step size is greater than audio length. Yielded {len(windowed_audios)}."


@pytest.mark.skipif(not TORCHAUDIO_AVAILABLE, reason="torchaudio is not installed.")
@pytest.mark.parametrize("audio_fixture", ["mono_audio_sample", "stereo_audio_sample"])
def test_audio_normalize(audio_fixture: str, request: pytest.FixtureRequest) -> None:
"""Tests the normalize method to ensure peak is 1.0 after normalization."""
audio_sample = request.getfixturevalue(audio_fixture)

# Check original max amplitude
original_max = audio_sample.waveform.abs().max()
assert original_max != 0, "Test assumes audio has non-zero values."

# Normalize
audio_sample.normalize()
new_max = audio_sample.waveform.abs().max()

assert torch.isclose(new_max, torch.tensor(1.0), atol=1e-6), "Waveform not normalized to peak=1.0."
assert (
audio_sample.waveform.shape == audio_sample.waveform.shape
), "Normalization should not change the waveform shape."