fix(live-dictate): talk to whisper.cpp's HTTP API instead of Lemonade realtime

Live dictation sent the OpenAI realtime protocol to ws://host/v1/realtime,
which only Lemonade-style servers implement.  Against the local
whisper-server on port 13305 every connection failed with
"websocket-received-error-http-response 404".

Retarget the module at whisper.cpp's native POST /inference endpoint:

- capture 16 kHz mono PCM16 with FFmpeg (now with binary process coding,
  which the old version lacked and which would have corrupted the audio)
- cut the stream into utterances with an energy-based VAD: speech starts
  above live-dictate-silence-threshold, flushes after a configurable
  silence window, with pre-roll and a max-utterance cap
- wrap each utterance in a WAV header and post it with curl, one request
  at a time so transcripts are inserted in spoken order
- insert text at the dictation marker with correct spacing, keep the
  mode-line indicator and follow-cursor behaviour
- warn when the microphone delivers pure digital silence (OS permission)

New defcustoms: live-dictate-language, -prompt, -silence-threshold,
-silence-duration, -min-utterance, -max-utterance, -preroll.

Comments in config-mac.el and packages.el updated; websocket is no
longer needed by dictation.
This commit is contained in:
Willem van den Ende
2026-11-05 12:14:30 +00:00
parent 183036a333
commit 580b213793
3 changed files with 335 additions and 229 deletions
+5 -3
View File
@@ -31,9 +31,11 @@
(package! mastodon)
(package! pi-coding-agent
:recipe (:host github :repo "dnouri/pi-coding-agent"))
;; speech-to-text: `whisper' is used by config-linux.el, and `websocket' is a
;; hard dependency of lisp/live-dictate.el -- it is what makes streaming
;; dictation possible.
;; speech-to-text: `whisper' is used by config-linux.el (and by
;; config-mac.el against a local whisper.cpp server). lisp/live-dictate.el
;; no longer needs `websocket': it POSTs utterances to whisper.cpp's
;; /inference endpoint, so `websocket' is only kept because whisper.el pulls
;; it in transitively.
(package! whisper
:recipe (:host github :repo "natrys/whisper.el"))
(package! websocket)