Commit 42cd142
Windowed auditory scene classification with AST (#493)
* Add windowed auditory scene classification with AST model
New API:
- classify_audios_in_windows(): sliding window classification with
configurable window_size/hop_size, returns per-window labels with
timestamps. Batched inference for memory efficiency.
- scene_results_to_segments(): converts window results to
plot_aligned_panels segment format for timeline visualization.
Supports any HuggingFace audio-classification model:
- MIT/ast-finetuned-audioset-10-10-0.4593 (521 AudioSet classes)
- Any other HF audio-classification model
Tutorial: auditory_scene_analysis.ipynb — windowed classification,
timeline visualization, event filtering.
3 new tests, all pass. Pre-commit clean.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Refactor: windowed classification as parameters to classify_audios
Instead of a separate classify_audios_in_windows(), windowed
processing is now activated by passing win_length/hop_length to
the existing classify_audios() function:
- win_length=None (default): whole-audio classification (unchanged)
- win_length=1.0: 1-second windows, hop defaults to win_length/2
- Provenance captured: win_length/hop_length in each result dict
- top_k parameter works in both modes
This pattern can be adopted by other senselab functions for
consistent windowed processing across the library.
4 tests pass (basic, short audio, default hop, segment conversion).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix mypy: add type annotation to model variable in tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix review: per-audio memory-bounded windowed processing
- Process one audio at a time instead of collecting all windows
into a single list (memory-efficient for long recordings)
- Guard against empty labels in scene_results_to_segments
- hop_samples already had max(1, ...) guard against infinite loop
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Use Audio.window_generator lazily for memory-efficient windowed classification
Instead of materializing all windows into a list, iterate the generator
in batches of 32 — only one batch of Audio objects is in memory at a
time. Reuses Audio.window_generator() for consistent windowed iteration
across senselab (same pattern as quality_control).
Tests updated for window_generator behavior (includes partial final window).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix PPG venv: remove unnecessary espnet/snorkel/lightning deps
The ppgs package handles its own espnet dependency (pins espnet==202301).
We were adding espnet, snorkel, and lightning explicitly which caused
conflicts: the 'lightning' package was removed from PyPI, and espnet
build failed on sentencepiece.
Minimal requirements: ppgs + torch + torchaudio + numpy + soundfile.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix NeMo venv: pin 1.23 + torch<2.5, add pyarrow<18 + matplotlib
Root cause: NeMo 2.0 removed SortformerEncLabelModel and pyarrow 24+
removed PyExtensionType. Also NeMo needs matplotlib at import time.
- nemo_toolkit==1.23.0 (has SortformerEncLabelModel)
- torch>=2.1,<2.5 (NeMo 1.23 not compatible with torch 2.8)
- pyarrow<18 (24+ breaking change)
- matplotlib (NeMo imports it)
The ensure_venv function auto-recreates when requirements change,
so stale CI venvs will be refreshed on next run.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Document NeMo lightning package removal, revert to torch 2.8
The `lightning` package was removed from PyPI (April 2026). NeMo
depends on it but pytorch-lightning is not a drop-in replacement
(NeMo accesses internal `lightning.pytorch._logger`).
Reverted to nemo_toolkit[asr] (unversioned) + torch 2.8 + added
pyarrow<18 + matplotlib. Existing cached venvs work; new venv
creation blocked until NeMo fixes their lightning dependency.
Added NOTE comments documenting the issue.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 8eeffe6 commit 42cd142
16 files changed
Lines changed: 941 additions & 20 deletions
File tree
- specs/20260429-201758-auditory-scene-analysis
- checklists
- src
- senselab/audio/tasks
- classification
- features_extraction
- speaker_diarization
- speech_to_text
- tests/audio/tasks
- tutorials
- audio
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
0 commit comments