5.7 KiB
0.1.3 voice activation: design, measurements, limits
What it is
A third transmission mode. The renderer forwards 20 ms frames (48 kHz mono) to the core continuously while
connected and not muted or deafened; the core decides which are sent (core/src/vad.rs, bridge set_transmit,
docs/bridge.md §4.11). Push to talk and the open microphone keep the previous path (direct: every forwarded
frame is sent). There is one decision owner per mode: the renderer for direct, the core for vad.
- Input: the capture after Chromium's WebRTC processing as configured in Settings → Audio (noise suppression,
echo cancellation, gain control; the applied values are logged from
track.getSettings()at capture start). - Detector: earshot 1.2.2 (pure Rust, MIT OR Apache-2.0, pinned), a small embedded neural network returning a voice probability 0–1 per 16 ms window at 16 kHz. It is a statistical voice detector: no speech recognition, no cloud, nothing stored. Upstream accuracy/speed claims are not repeated here as measurements.
- Resampling: windowed-sinc low-pass (63 taps, Blackman, 7 kHz cut-off) and decimation by 3; the filter history carries over between frames (test: frame-wise output equals a direct convolution over the whole signal); output clamped to [-1, 1] (a full-scale square wave rings above 1).
- Windows: each 20 ms frame yields 320 samples at 16 kHz, i.e. one or two 256-sample windows; the remainder is kept for the next frame (test: 5 frames → 6 windows + 64 samples pending).
- Gate: opens after 3 consecutive windows at or above the threshold (High 0.45, Normal 0.6 — default, Low 0.75); while open, a window counts down to 0.15 below the threshold; closes 400 ms (20 frames) after the last voiced frame. Sends the 5 frames (100 ms) before the onset, then the current frame (never duplicated).
- Reset (detector, filter history, held frames): mode change,
audio_end(capture stopped / renderer stopped forwarding), mute, deafen, disconnect, channel or codec change, server talk denial. Not at the natural end of a spurt. After a reset the gate cannot open for 10 frames (the freshly reset network scores the first ~150 ms of any input higher than it settles to), but every frame since the reset is kept (at most 15 frames = 300 ms) and sent with the first spurt. - No per-frame heap allocation or logging; fixed buffers allocated when the mode is applied.
Mode handshake (renderer ↔ core)
set_transmit is answered only after the core discarded frames queued under the previous mode (control
messages use a separate channel and are not affected) and ended any open burst. The renderer forwards nothing
until the answer matches the preferences; a failed change shows an error and sends nothing (never open
microphone). Mute, deafen and disconnect stop forwarding immediately. The own "talking" indicator is the core's
audio_state.transmitting, true only while voice packets are sent. Tests: test/voice-transmit.test.mjs.
Measurements (deterministic unit tests, cargo test, x64 Windows)
Speech: core/tests/fixtures/speech-librivox-48k.wav (public domain, provenance in the fixture README).
Noise: generated in the tests (synthetic, not recordings).
| Case | Result |
|---|---|
| Speech after 10 silent frames (Normal) | decides 40 ms after the first loud frame (High: 0 ms, Low: 40 ms); preroll reaches before it |
| Speech from frame 0 of a fresh/reset gate (all sensitivities) | opens at frame 10 (200 ms); frames 0–9 are all sent before frame 10 → nothing lost, first spurt 200 ms late |
| 4 s of speech after 10 silent frames, then silence | High: 2 spurts, 209 frames sent; Normal: 3 spurts, 202; Low: 3 spurts, 198 (200 speech frames; counts include preroll and hangover; natural pauses longer than the hangover close the gate) |
| Silence, steady broadband noise (−31 dBFS), clicks every 200 ms, 5 s each | gate stays closed at High, Normal and Low |
| 160 ms pause inside speech | one spurt (not split) |
| End of speech | closes 23–26 frames (460–520 ms) after the last speech frame of the fixture |
Added latency: within a spurt none (frames are sent as they arrive). At an onset the preroll (100 ms) goes out at once, so the receiver plays the spurt from up to ~100 ms before the decision; the decision itself comes 0–60 ms after the first loud frame. Right after a reset the first spurt is up to ~260 ms late.
ARM64: the same unit tests run in CI under qemu-aarch64 (emulated); native Apple Silicon/Asahi hardware is not tested.
Real program (scripts/smoke-voice-vad.mjs, runtime/2026-10-24-vad-dev/)
Two TeamsPeach instances on 10.10.10.160 in the otherwise empty default channel (the script refuses occupied channels). A's capture is Chromium's fake device fed from a WAV built from the speech fixture (2 s silence, 4 s speech, 3 s silence, looped); B never transmits and plays at zero gain.
- Core confirms
vadbefore connecting; 6 spurts over 2 loops, on-fraction 0.36; during the long silences B receives 0 frames. - Muted, deafened, push to talk not held: nothing sent, B receives 0 frames. Back to voice activation: sent again.
- Disconnected: nothing sent. After restarting A,
transmitMode: vadand the sensitivity are persisted and the new core confirms the mode.
Limits
- Statistical detector: loud speech-like sound (TV, other voices) can open the gate; quiet speech in heavy noise can be missed. Noise suppression helps, it does not make the detector exact.
- Not proven with a live microphone, with an official TeamSpeak 6 receiver, or on native ARM64 hardware.
- Two TeamsPeach clients agreeing is not interoperability proof; the transmitted packets are the same Opus voice packets as push to talk, which the user confirmed reach the official client.