Skip to main content

Module voice

Module voice 

Source
Expand description

Voice speech-to-text endpoint — POST /api/v1/voice/transcribe, and GET /api/v1/voice/status, which says whether the chosen engine has what it needs, so the mic can say so before it records.

The renderer captures mic audio (getUserMedia, gated by the CEF permission handler #1602) and POSTs each silence-bounded utterance here; we forward it to the configured Whisper backend and return the transcript. Keys/paths stay server-side — the renderer never sees them.

Web Speech API can’t transcribe in CEF (closed-source Google service), so this capture-and-send path is the real engine. See docs/specs/SPEC_VOICE_STT_ENGINE_2026_06_20.md and #1591.

Backends (selected by the voice:engine setting):

  • “groq” (default) — hosted whisper-large-v3-turbo; renderer sends webm.
  • “whisper-local” — offline whisper.cpp via a local whisper-cli subprocess; renderer sends 16 kHz mono WAV. Opt-in, configured via settings/env; needs a model file.

Structs§

SetupGap 🔒
What an engine still needs before it can transcribe.
TranscribeQuery 🔒

Enums§

GroqKey 🔒
What the Groq key setting comes to.
GroqKeyState 🔒
SttError 🔒
Transcription failure: distinguishes “not configured” (→ 501, surfaced as the frontend’s “unavailable” guidance) from a real upstream/runtime error (→ 502).

Constants§

DEFAULT_WHISPER_MODEL 🔒
Transcribe via a local whisper-cli (whisper.cpp) subprocess. The renderer sends 16 kHz mono WAV for this engine, so we write the body to a temp .wav and run the CLI. Fully offline; nothing leaves the machine.
GROQ_GONE 🔒
GROQ_MODEL 🔒
GROQ_NOT_CONFIGURED 🔒
GROQ_SETTING 🔒
The setting that holds the Groq key, or the vault:<entry id> that names it.
GROQ_TRANSCRIBE_URL 🔒
MODEL_DOWNLOAD_TIMEOUT_SECS 🔒
Cap the one-time model download so a stuck transfer can’t wedge a request.
VOICE_OFF 🔒

Functions§

ensure_local_model 🔒
Resolve the GGML model path, downloading an auto-managed model on first use.
env_groq_key 🔒
explicit_model_path 🔒
The model file the settings or the environment name outright, if they name one: there, or an error.
groq_key 🔒
Groq key: AGENTMUX_GROQ_API_KEY env (it wins, for CI and scripts), else settings.json voice:groqApiKey: a vault:<entry id> reference, read from the Vault here, or a plain key from before it was moved.
groq_key_state_with 🔒
Whether there is a Groq key to use, without opening a Vault entry.
groq_key_with 🔒
handle_voice_status 🔒
GET /api/v1/voice/status → { "engine": "groq", "ready": false, "missing": "groq-key", "error": "..." }. Whether the chosen engine has what it needs to transcribe, read from the settings and the environment alone: nothing is sent anywhere, no program is run and no model is fetched. The mic asks this before it records, so a person with no engine set up is told at the click, not after speaking into nothing.
handle_voice_transcribe 🔒
POST /api/v1/voice/transcribe?mime=audio/webm&lang=en — body is raw audio. → 200 { "text": "..." } · 400 empty body · 501 no backend configured · 502 upstream/subprocess error.
log_not_configured 🔒
One line in the log per run for a voice request that found no engine set up. The answer goes to the window, which is not in any log: without this line a report of “the mic does nothing” could not be read from the logs at all.
mime_ext 🔒
File extension matching the posted MIME, so Groq’s content sniffing accepts the multipart file part.
model_name 🔒
The name of the auto-managed model (voice:whisperModel, default base.en).
read_settings_json 🔒
Read settings.json once; None if absent/unparseable. The file the config watcher loads, not <config dir>/settings.json: on a shared channel those differ (#1903).
resolve_engine 🔒
voice:engine — “groq” (default) or “whisper-local”. Env override: AGENTMUX_VOICE_ENGINE.
resolve_path 🔒
Env-first, then settings.json, for a path-valued config key.
resolve_whisper_cli 🔒
The whisper-cli program the local engine runs: its path, when one is set and is there.
settings_str 🔒
setup_gap 🔒
The first thing engine still needs, or None when a transcription can be tried. For local whisper a model that is fetched on first use is not a gap: only a model path that was given and is not there.
setup_gap_with 🔒
transcribe_groq 🔒
POST the audio to Groq’s OpenAI-compatible transcription endpoint.
transcribe_local_whisper 🔒
voice_off 🔒
Voice input is switched off: voice:enabled is false in settings.json (Settings > Recording). Absent, it is on.