feat(terra): talk to luna with push-to-talk

luna-voiced: mic -> whisper-cpp (local, vulkan) -> Hermes' API on mars ->
ElevenLabs streaming TTS -> speaker, bound to SUPER+V. State, amplitude
and a viseme timeline are published on a unix socket; nothing consumes
that yet, but it is the data source the quickshell avatar will read.

STT stays local on purpose. mars already runs faster-whisper for Telegram
voice notes, but routing the mic through it would put every spoken word
on the network for no latency win.

Shape notes, all of them things the first live runs decided:

  - Viseme offsets are relative to speech_start (emitted when the first
    PCM frame reaches the speaker), never wall clock, so the shell and
    the daemon never have to compare clocks. ElevenLabs sends character
    alignment, not visemes, so the mapping is ours; the glTF morph target
    names are the contract.
  - clean_for_speech is a whitelist. She writes "(¬‿¬)", whose characters
    live in Latin-1 and punctuation blocks rather than any emoji range,
    so enumerating what to drop never converges. Em dashes become commas
    because they are a pause — dropping one ran two clauses together and
    changed what a sentence meant.
  - whisper invents words out of silence ("you", "Thank you."), and a
    held key over a quiet room is long AND empty, so has_speech gates on
    the loudest 100ms window rather than on duration.
  - Beeps on key down/up and a distinct low tone for "heard nothing":
    push-to-talk with no acknowledgement is indistinguishable from broken,
    and a dead mic must not feel like a slow reply.
  - A warmup request at startup: her first reply after the container
    starts costs ~16s against ~5s warm, and the first one is always the
    one you are waiting for.
  - `luna-voice watch` prints the socket protocol and `luna-voice say`
    runs a turn from typed text, which is how a broken mic is told apart
    from a broken pipeline.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 22:45:17 +02:00
co-authored by Claude Opus 5
parent 8dc3affdda
commit d089743f75
17 changed files with 3934 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
{ lib
, rustPlatform
, pkg-config
, alsa-lib
}:
# luna-voiced — the push-to-talk voice loop for luna (Hermes Agent on mars).
# Wiring (secrets, whisper model, systemd user unit) lives in
# services/desktop/luna-voice.nix; this only builds the binary.
#
# cargoLock.lockFile rather than a cargoHash: the lockfile is committed, so a
# dependency bump is a visible diff instead of a hash nobody can read.
#
# alsa-lib is cpal's backend even on a pipewire box — pipewire's ALSA
# compatibility layer is what actually serves it, so there is no pipewire
# build dependency here.
rustPlatform.buildRustPackage {
pname = "luna-voice";
version = "0.1.0";
src = ./luna-voice;
cargoLock.lockFile = ./luna-voice/Cargo.lock;
nativeBuildInputs = [ pkg-config ];
buildInputs = [ alsa-lib ];
meta = {
description = "Push-to-talk voice loop for luna (Hermes Agent)";
mainProgram = "luna-voice";
platforms = lib.platforms.linux;
};
}