Files
Tommi Kyntola 22ca5ed598 Dictation: space between consecutive utterances
A pause splits one spoken paragraph into several VAD utterances, each its own
transcript, own :type-text plan and own paste at the same cursor -- and
router/single-line trims, so they butted together: "right now.What happens".
Neither existing whitespace mechanism covered the boundary (the ear's " ".join
only joins whisper segments inside one utterance).

A dictated utterance that CONTINUES an open run is now typed with a leading
space. Leading, not trailing, so a submitted prompt carries no stray
whitespace and a fresh input box never starts with one; suppressed when the
text opens with punctuation that must hug the previous word.

State carries the run as :dictation-run {:at ms :slot n}, open while the last
thing DELIVERED was an unsubmitted dictation. The daemon decides continuation
(continuing?) and stamps the marker (run-after); the router stays pure and
just receives a :continuation opt. Storing the slot makes a target switch end
the run for free. The run also ends on submit/keys/macro, raw send, esc,
"voice off"/mute, and after :dictation-continue-gap-s seconds (60 default).

Two traps worth knowing, both recorded in ai/gotchas.md:

- The reset hangs off the deliberate stops (voice-off, mute, toggle-vad's
  close branch), NOT a generic "mic not open" test -- a latch stop closes the
  mic before its transcript exists, which would kill continuation in
  :manual-recording entirely.
- Nothing delivered must neither open nor close a run: a dry-run, a
  confidence-gated utterance and a failed paste all leave the input box as the
  last real delivery left it.

Also documents three things this session's live verification cost: a private
test daemon must isolate its DIRS and not just its socket, never pkill the
daemon by cmdline (it matches the user's systemd unit), and name-based tmux
pane targets are only stable on hand-renamed windows. AGENTS.md's recipe is
fixed accordingly.
2026-08-17 13:35:48 +03:00

85 lines
4.2 KiB
Clojure

{;; Router: how an utterance is classified.
;; :whole-match command iff the WHOLE utterance matches (default)
;; :prefix commands must start with :prefix word; rest is dictation
;; :key-armed everything is dictation unless armed via `dais-ctl arm`
:router {:strategy :whole-match
:prefix "do"
;; Extra whole-utterance commands (merged over built-in defaults).
;; Entries map a phrase to either {:keys [...]} (key sequence) or
;; {:text "..." :submit true/false} (typed reply).
;; A command may carry :lang to bind it to a transcription language;
;; untagged commands belong to :asr :language (the base, "en" here) and
;; only match while that language is active. A phrase is only matchable
;; when the model is transcribing in its language, so e.g. "ääni pois"
;; below is reachable only under :language "fi".
:commands
{"send the brief"
{:text "Voice input notice: parts of my input arrive via speech-to-text and may contain recognition errors or noise. Read /home/k/dais/BRIEF.md for how to cope (verify unclear intent, match dictated identifiers against the repo, ignore noise fragments, prefer numbered options)."
:submit false}
"ääni pois" {:control :voice-off :lang "fi"}}}
;; Dictation submit behavior: :no-enter | :enter-auto | :enter-always
:enter-mode :no-enter
;; A dictated utterance that CONTINUES the previous one is typed with a leading
;; space — every VAD utterance is its own paste at the same cursor, so without
;; this a short pause yields "right now.What happens". The run also ends on
;; submit/keys/macro, a target switch, "voice off"/mute, and raw sends; this is
;; the silence gap (seconds) that ends it. nil/0 = only those events end it.
:dictation-continue-gap-s 60
;; Target slots. :type :tmux needs :pane "session:window.pane";
;; :type :focus delivers to the focused app via ydotool.
:targets {1 {:type :focus}
2 {:type :tmux :pane "app:claude.0"}}
:active-slot 1
:tmux ["tmux"]
:focus {:ydotool ["/usr/bin/ydotool"]
;; nil -> $XDG_RUNTIME_DIR/.ydotool_socket (the client default)
:ydotool-socket nil
:key-delay-ms 2}
:notifications {:enabled true :timeout-ms 2500}
;; Mic hygiene: force voice-off after a VAD session hears nothing for this
;; many minutes (decimals ok, nil/0 disables). Suspend/lid-close ALWAYS
;; forces voice-off (both at sleep and re-checked at resume) — waking the
;; laptop never resumes listening; deliberately not configurable.
:vad-idle-off-min 5
;; Confidence gate: an utterance whose mean avg_logprob is below this floor is
;; NOT delivered — it's flagged ("Uncertain — say again?") so you just repeat.
;; Distinct from the :vad avg_logprob_min hard drop (kills hallucinated noise);
;; this one catches real-but-garbled speech AFTER it routed to typing/keys.
;; Controls ("voice off", "unmute") always pass. nil disables (deliver as-is).
;; Speech usually lands well above -0.6; start around -0.8 and tune by feel.
:confidence-min-logprob nil
;; The resident ear worker (capture/VAD/ASR). :cmd is absolute so a
;; systemd/KDE-launched daemon needs no user PATH.
:ear {:enabled? true
:cmd ["/home/k/bin/pixi" "run" "-q" "ear"]
:dir "ear"}
;; :source pins a PipeWire input node (`pactl list sources short`);
;; omit it to follow the system default source (headset plug/unplug works).
;;
;; :language is the startup/base language; :languages is the selectable set
;; (dais-ctl/dais-top cycle these plus "auto" = per-utterance detect). Switching
;; needs a MULTILINGUAL model — "*.en" checkpoints only do English; for Finnish
;; use e.g. "small" or (better Finnish, slower) "medium".
:asr {:model "small.en" :device "cpu" :compute-type "int8"
:language "en" :languages ["en" "fi"]}
;; VAD endpointing + false-trigger gates (JSON-serialized to the ear's
;; --tuning; underscore keys match the worker's DEFAULT_TUNING).
:vad {"threshold" 0.5
"release" 0.35
"min_speech_ms" 300
"silence_ms" 700
"pre_roll_ms" 300
"max_utterance_s" 30
"no_speech_prob_max" 0.7
"avg_logprob_min" -1.2}}