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:
@@ -19,6 +19,10 @@ pub struct Config {
|
||||
pub whisper_model: PathBuf,
|
||||
|
||||
pub socket_path: PathBuf,
|
||||
/// Silence that ends an utterance in hands-free mode. Hermes' own default.
|
||||
pub silence_ms: u64,
|
||||
/// Level above the running noise floor that starts one.
|
||||
pub vad_mult: f32,
|
||||
/// Speech during playback louder than noise_floor * this counts as barge-in.
|
||||
pub barge_in_mult: f32,
|
||||
pub barge_in_grace_ms: u64,
|
||||
@@ -63,6 +67,12 @@ impl Config {
|
||||
"LUNA_SOCKET",
|
||||
&format!("{runtime}/luna-voiced.sock"),
|
||||
)),
|
||||
silence_ms: env_or("LUNA_SILENCE_MS", "2000").parse().unwrap_or(2000),
|
||||
// 1.8, not Hermes' 3.0-ish: terra's interface has speech only
|
||||
// ~6dB over its own ambient (0.0045 against 0.0022 measured), and
|
||||
// no multiplier above ~2 can separate those. The real fix is gain
|
||||
// on the interface; this makes it work at the gain it has.
|
||||
vad_mult: env_or("LUNA_VAD_MULT", "1.8").parse().unwrap_or(1.8),
|
||||
barge_in_mult: env_or("LUNA_BARGE_IN_MULT", "3.0").parse().unwrap_or(3.0),
|
||||
barge_in_grace_ms: env_or("LUNA_BARGE_IN_GRACE_MS", "500")
|
||||
.parse()
|
||||
|
||||
Reference in New Issue
Block a user