Skip to content

feat(voice): end the capture on silence and keep whisper warm - #34

Closed
YCistak wants to merge 6 commits into
feat/voice-buttonsfrom
feat/voice-latency
Closed

YCistak wants to merge 6 commits into
feat/voice-buttonsfrom
feat/voice-latency

Conversation

@YCistak

@YCistak YCistak commented Aug 6, 2026

Copy link
Copy Markdown
Owner

A spoken turn was dominated by two waits that had nothing to do with thinking. Measured here (RTX 4060 / Vulkan, large-v3-turbo): whisper-cli takes ~880 ms once warm, of which ~610 ms is reloading the model every turn — and before that, record_seconds: 5 made every turn wait out the full window even for a two-second question.

Both fixes were already half-present in the repo. pylon.local.yaml has carried a voice.stt_server block for weeks with no Go field to read it, and the recorder's self-terminating path (commandUsesSeconds) existed but no default command used it.

Silence-stop

The per-OS default now prefers sox's silence effect, which ends the capture ~1 s after you stop talking. record_seconds becomes a ceiling on how long you may talk rather than a fixed wait, and starting to speak gets its own 15 s grace. sox missing → one log line and the old fixed window. A configured record_cmd is still used verbatim.

Warm STT

stt_server.bin makes the daemon supervise a whisper.cpp server for its own lifetime (restart on death, SIGINT + Pdeathsig on shutdown) and transcribe over HTTP. An unreachable server falls back to stt_bin, so a dead server costs latency, not the feature.

Listening on the port only means the weights loaded — the backend still builds its compute graph on the first inference (5.0 s here), so startup fires one throwaway clip.

Measured

Before After
STT call 790–880 ms 130–150 ms
First request after daemon start 5050 ms 150 ms
End-to-end turn (file-fed) ~5.9 s 883–950 ms

Two traps worth naming

sox reads a bare integer duration as a sample count. Formatting 1.0 as "1" ended the capture after one sample and clipped the last word — "Hava bugün nasıl?" for "Hava bugün nasıl olacak?". {silence} always renders with a decimal point now, with a test pinning it.

Input gain dominates everything. Testing against a real mic, this one sat at 51% (−17.56 dB), where speech measured 0.83% RMS against a 0.87% noise floor — indistinguishable, and whisper answered with its silence hallucination ("Altyazı M.K."). At 100% the same voice gave 47.5% peak / 4.8% RMS and transcribed cleanly. The 1% start threshold was also picked without measuring; room noise peaked at 1.27%, above it. Now 3% and tunable via voice.silence_threshold. Both pylon.yaml and the README say to check the level before touching a threshold.

Testing

go test ./... (20 new tests in internal/voice), go vet, gofmt, darwin/arm64 + windows/amd64 cross-compile, and pylon-ui with -tags webkit2_41 — all clean. CI itself could not run: every job fails with "recent account payments have failed or your spending limit needs to be increased", unrelated to this branch.

Verified live: warm server timings above; daemon shutdown really does take whisper-server with it; killing the server mid-session gets it restarted; pointing at a dead port falls back to the CLI and still answers; and a full push-to-talk turn through a real microphone ("Bugün hava nasıl?" → forecast).

Based on feat/voice-buttons (#33), which owns the listen IPC handler this builds on.

🤖 Generated with Claude Code

YCistak and others added 6 commits July 19, 2026 19:49
Voice is now one click away in the app, and the daily briefing too.

- daemon: a "listen" IPC command runs one push-to-talk cycle in-process —
  record → transcribe → resolve+execute the intent → speak the reply. The say
  and listen handlers now share a runIntent closure, so typed and spoken input
  take the exact same path. Returns "» <heard>\n<reply>" for the UI to show.
- GUI: a VoiceBar under the Pylon stage with two buttons — "🎤 Konuş"
  (push-to-talk, pulses while listening) and "📰 Brifing Ver" (desktop banner +
  spoken). Both call new Wails bindings App.Listen / App.Briefing (a longer
  socket deadline, since recording takes a few seconds).
- Settings: a "Ses & Konuşma" card to pick the push-to-talk shortcut. Wayland
  can't grab a global hotkey from the app, so the card captures the combo and
  generates the exact `bind = …, exec, pylon listen` line to paste into
  hyprland, with a copy button.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two changes on top of the voice buttons.

Briefing has no button — you ask for it by voice ("brifing ver"). Running the
briefing action now shows the desktop banner itself, so every trigger (the
spoken command, the daily scheduler, `pylon briefing`) presents it the same way:
banner + spoken. The dedicated "briefing" IPC command, its Wails binding, and
the 📰 button are gone; the mic button is the single entry point.

The shortcut card is no longer hyprland-only. A new App.Platform() detects the
desktop (hyprland / Sway / GNOME / KDE / other Linux / macOS / Windows) and the
card generates the matching way to bind the captured combo to `pylon listen` —
a hyprland `bind =` line, a Sway `bindsym`, an skhd line for macOS, an
AutoHotkey binding for Windows, or the command to paste into GNOME/KDE custom
shortcuts. A dropdown overrides the detected platform.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Settings gains an "API Anahtarı" card: paste the Gemini key, and it's saved to
the daemon's encrypted vault (never to config in plaintext) and the daemon is
bounced so it takes effect. A "kayıtlı ✓" badge shows when one is already stored,
without ever revealing the value.

- daemon: a "secret" IPC command (set / rm / has) so the GUI can manage the
  vault over the local socket, the same store as `pylon secret set`.
- intent chain: each model's key now falls back to the vault (secret:<provider>)
  when its env var is unset — so a user who never exported GEMINI_API_KEY can
  enable the model straight from Settings.
- GUI: App.SetSecret / HasSecret / RestartDaemon bindings, and a daemonManager
  restart that re-applies config for a daemon the GUI started.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Settings gains a "Bağlı Hesaplar" card with a Google row — sign in to let Pylon
reach your calendar, mail and Drive. The consent runs in the daemon (the same
OAuth flow as `pylon auth google`), and the token lands in the encrypted vault.

The row reflects real state via a new "auth google status" IPC: "connected"
(signed in) shows a badge, "ready" shows an active sign-in button, and
"unavailable" (no OAuth client embedded in this build yet) shows the button
disabled with a "yakında" note — so it's present in the GUI now, honest about
not being wired for this build, and works the moment a client is embedded.

- daemon: "auth google <status|login>" IPC handler.
- GUI: App.GoogleStatus / App.GoogleLogin bindings (login uses a long deadline
  since it waits on the browser).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A spoken turn was dominated by two waits that had nothing to do with
thinking. Measured on this machine (RTX 4060 / Vulkan, large-v3-turbo):
whisper-cli takes ~880 ms once warm, of which ~610 ms is reloading the
model every single turn — and before that, `record_seconds: 5` made every
turn wait out the full window even for a two-second question.

Both fixes were already half-present. `pylon.local.yaml` has carried a
`voice.stt_server` block for weeks with no Go field to read it, and the
recorder's self-terminating path (commandUsesSeconds) was there but no
default command used it.

Silence-stop: the per-OS default now prefers sox's `silence` effect, which
ends the capture ~1 s after you stop talking; `record_seconds` becomes a
ceiling rather than a fixed wait. sox missing → one log line and the old
fixed window. A configured record_cmd is still used verbatim.

Warm STT: `stt_server.bin` makes the daemon supervise a whisper.cpp server
for its own lifetime (restart on death, SIGINT + Pdeathsig on shutdown) and
transcribe over HTTP. Unreachable server falls back to stt_bin, so a dead
server costs latency, not the feature. Listening on the port only means the
weights loaded — the backend still builds its graph on first inference
(5.0 s here), so startup fires one throwaway clip: first real request went
5050 ms → 150 ms.

Measured end to end with a file-fed recording, warm server: 883-950 ms per
turn against ~5.9 s before.

One trap worth naming: sox reads a bare integer duration as a *sample
count*, so formatting 1.0 as "1" ended the capture after one sample and
clipped the last word ("Hava bugün nasıl?" for "Hava bugün nasıl olacak?").
{silence} always renders with a decimal point now, with a test pinning it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Testing silence-stop against a real microphone turned up two problems the
file-fed runs could not.

The deadline was still `record_seconds + 3s`, inherited from the fixed
window. But a silence-triggered capture waits for the speaker to *begin*,
which is unbounded — so reading the prompt and drawing a breath blew the
deadline and failed the turn with "record: rec: context deadline exceeded".
record_seconds now caps only how long you may talk; starting gets its own
15s grace. A deadline with nothing captured is no longer an error either:
it returns errNoSpeech, which the CLI and the daemon report as the plain
"ses algılanamadı".

The 1% start threshold was picked without measuring. Room noise on this
desk mic peaked at 1.27%, i.e. above it — the capture could trigger on the
room. Measured silence at 3% instead: it never fired across a quiet room,
and speech runs far above it. voice.silence_threshold makes it tunable,
since mic levels vary more than any default can cover.

Worth recording for the next person: input gain dominates all of this. This
mic sat at 51% (-17.56 dB), where speech measured 0.83% RMS against a 0.87%
noise floor — indistinguishable, and whisper answered with its silence
hallucination ("Altyazı M.K."). At 100% the same voice gave 47.5% peak /
4.8% RMS and transcribed cleanly. Both pylon.yaml and the README now say to
check the level before touching a threshold.

NewRecorder took five positional arguments after this; it takes
RecorderOptions now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@YCistak
YCistak force-pushed the feat/voice-buttons branch from bddfee1 to dd914bc Compare August 6, 2026 20:49
@YCistak
YCistak deleted the branch feat/voice-buttons August 6, 2026 20:49
@YCistak YCistak closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant