feat(terra): hands-free voice mode, toggled with SUPER+V

The key is a toggle rather than push-to-talk, because "voice mode is
active" has to be a state something can display; a held key cannot
sustain one. So the daemon grew a VAD loop: speech starts a capture,
`silenceMs` of quiet ends it. A turn is awaited inline, which is also
what stops her hearing herself — the tick cannot fire while she speaks.

The keybind runs the CLI, not a quickshell GlobalShortcut, so the mic can
still be switched off while the shell is reloading and a QML error can
never leave it open with nothing on screen saying so.

Every threshold had to be resized for terra's mic, which is QUIET:
0.001-0.002 ambient against 0.0045 speaking, about 6dB apart. The VAD
floor of 0.006 and whisper's own 0.015 gate both sat ABOVE the user's
voice, and a 3.5x multiplier cannot separate signals that close — three
independent reasons nothing could ever trigger. Hence vadMult 1.8,
vadFloor 0.0025, and stt::normalize lifting the clip (capped at 30x, so
near-silence is not amplified into words) before whisper sees it.

The floor tracker also had to stop feeding on everything: a rising sound
dragged its own threshold up faster than it rose, and a tone peaking at
0.029 was outrun by a threshold that reached 0.018. Only samples below
the current trigger update it now.

Four diagnostics, because none of the above was visible while it was
failing: `watch` prints the socket protocol, `say` runs a turn from typed
text (a broken mic vs a broken pipeline), `level` is a live meter with
the trigger marked, `devices` lists the inputs. Amplitude is now emitted
on every tick, not only while she speaks — a meter that moves only during
playback cannot answer "is it hearing me".

Also: connect-time replay of mode/state, so restarting the shell while
voice mode is on does not leave it blind until the next event, which in
an idle conversation is never.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 23:37:51 +02:00
co-authored by Claude Opus 5
parent d089743f75
commit 67dd30eb72
7 changed files with 476 additions and 26 deletions
+4 -5
View File
@@ -195,11 +195,10 @@ in
# expand / collapse the hyprchrome bar as a whole
(bind "SUPER + A" (dsp.global "quickshell:chrome"))
# push-to-talk for luna (services/desktop/luna-voice.nix). Two binds,
# not one: the daemon records between the press and the release, so
# the release edge is what ends the utterance.
(bind "SUPER + V" (dsp.exec "luna-voice ptt-down"))
(bindo "SUPER + V" (dsp.exec "luna-voice ptt-up") { release = true; })
# toggle luna's hands-free voice mode (services/desktop/luna-voice.nix).
# Runs the CLI rather than a quickshell GlobalShortcut so the mic can
# still be switched off while the shell is reloading.
(bind "SUPER + V" (dsp.exec "luna-voice toggle"))
(bind "SUPER + B" (dsp.exec "vivaldi"))
(bind "SUPER + E" (dsp.exec "cosmic-files"))