Test 1: record 5s from USB mic with RMS meter (PA_ALSA_PLUGHW for resampling)

This commit is contained in:
2026-06-11 14:35:45 +00:00
parent 99be524fab
commit 431fe7cfbc
3 changed files with 99 additions and 0 deletions
@@ -10,6 +10,8 @@
**TDD note:** These are hardware-in-the-loop probes, not modules with unit tests. The "test" for each task is a manual run on the Pi against the spec's pass criteria. Every code-producing task ends with a deploy + run step that names the specific behaviour to look for.
**Audio note:** The Pi's USB Speaker Phone only supports 48 kHz natively. We set `PA_ALSA_PLUGHW=1` at the top of every test's `main.py` (before importing sounddevice) so PortAudio opens via ALSA's `plughw:` device, which auto-resamples to the requested 16 kHz.
**Spec:** `docs/superpowers/specs/2026-06-11-voice-assistant-prototypes-design.md`
---
@@ -230,6 +232,9 @@ Pass criteria for the record stage:
- Level meter visibly responds to speech and to silence.
- out.wav is written and non-empty.
"""
import os
os.environ.setdefault("PA_ALSA_PLUGHW", "1")
import sys
import time
@@ -422,6 +427,9 @@ This task validates that the model loads, the mic stream produces 1280-sample
frames, and predict() returns a non-empty score dict. Detection + beep come
in the next task.
"""
import os
os.environ.setdefault("PA_ALSA_PLUGHW", "1")
import sys
import time
@@ -534,6 +542,9 @@ Pass criteria (per spec):
- During ~1 minute of unrelated speech, <= ~1 false positive.
- Python process < 50% of one core (check with htop).
"""
import os
os.environ.setdefault("PA_ALSA_PLUGHW", "1")
import sys
import time