Conversation
Replace the split-in-half STFT approach in spectrogram_visualizer with the model's audio_frontend (load_processed_waveform + featurize_waveform). This produces a single mel spectrogram with uniform color normalization, fixing the purple/blue half-and-half artifacts in the moderator UI. https://claude.ai/code/session_018X71PrWAjeFTXkEdqH65W7
…ms (#429) Spectrogram visualizer now uses its own visualization config instead of the model's inference config: - No resampling — uses native sample rate (48kHz for hydrophones) - mel_f_min=20Hz, mel_f_max=Nyquist (full audible bandwidth) - 960 mel bins matching 960px image height for 1:1 pixel rendering - n_fft=8192, hop_length=2048 for good frequency resolution - Output: 1920x960 PNG with uniform magma colormap Also adds an optional pytest (test_spectrogram_viz) under test_audio_preprocessing for local visual inspection via --save-debug. https://claude.ai/code/session_018X71PrWAjeFTXkEdqH65W7
There was a problem hiding this comment.
Pull request overview
This PR updates spectrogram generation in the InferenceSystem so the moderator UI receives more consistent, visualization-optimized spectrogram images derived from the audio clip’s native sample rate (instead of the model inference config). It also adds a local-only pytest for visually inspecting the generated PNG output.
Changes:
- Refactors
spectrogram_visualizer.write_spectrogram()to usemodel.audio_frontendand a visualization-specific config derived from the WAV’s native sample rate. - Adds an optional
test_spectrogram_viztest that generates and validates a 1280x480 spectrogram PNG (and can save a debug artifact). - Registers a new
optionalpytest marker.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| InferenceSystem/src/spectrogram_visualizer.py | Replaces the previous “two halves stitched together” approach with a single mel-spectrogram render pipeline using audio_frontend + Matplotlib. |
| InferenceSystem/tests/test_audio_preprocessing.py | Adds an optional visual-inspection test to generate/validate a spectrogram image. |
| InferenceSystem/tests/conftest.py | Registers the optional pytest marker for local-debug tests. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Improves the InferenceSystem’s spectrogram PNG generation used by the orchestrator (and ultimately shown in the moderator UI) by switching the visualizer to the shared model.audio_frontend mel-spectrogram pipeline and adding a small visualization-focused test.
Changes:
- Refactors
spectrogram_visualizer.write_spectrogram()to compute a mel spectrogram viamodel.audio_frontendand render it with matplotlib (including frequency labels + new colormap). - Adds a new pytest test that generates a spectrogram from the 1-minute fixture WAV and asserts the output image dimensions (with optional
--save-debugoutput copying).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| InferenceSystem/src/spectrogram_visualizer.py | Replaces the previous STFT/concatenation approach with a single mel-spectrogram render path and overlays frequency labels. |
| InferenceSystem/tests/test_audio_preprocessing.py | Adds a visualization-oriented test that generates and validates the PNG output (and optionally saves it for local inspection). |
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Dave Thaler <dthaler1968@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary
src.audio_frontendmodule (same for model inference)n_fft=4096,hop_length=1024)test_spectrogram_vizpytest for local visual inspection (--save-debug)magma->BluesTest plan
pytest tests/test_audio_preprocessing.py -k "spectrogram_viz" --save-debug— generates 1280x480 PNG totests/tmp/for inspection*LocalDebugorch_configFixes #429
Fixes #139