dsh-voice-mode 0.7.43 → 0.7.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -1,486 +1,277 @@
1
1
  # dsh-voice-mode
2
2
 
3
- [![License: MIT](https://img.shields.io/github/license/qishuilalala/dsh-voice-mode?style=flat-square&color=blue)](./LICENSE)
4
- [![Latest Release](https://img.shields.io/github/v/release/qishuilalala/dsh-voice-mode?style=flat-square&color=brightgreen&include_prereleases)](https://github.com/qishuilalala/dsh-voice-mode/releases)
5
- [![npm version](https://img.shields.io/npm/v/dsh-voice-mode?style=flat-square&color=orange)](https://www.npmjs.com/package/dsh-voice-mode)
3
+ [![npm version](https://img.shields.io/npm/v/dsh-voice-mode?style=flat-square&color=cb3837)](https://www.npmjs.com/package/dsh-voice-mode)
4
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-voice-mode?style=flat-square&color=blue)](https://www.npmjs.com/package/dsh-voice-mode)
5
+ [![Plugin Security Scan](https://github.com/qishuilalala/dsh-voice-mode/actions/workflows/hol-scanner.yml/badge.svg?branch=main)](https://github.com/qishuilalala/dsh-voice-mode/actions/workflows/hol-scanner.yml)
6
6
  [![CI](https://github.com/qishuilalala/dsh-voice-mode/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/qishuilalala/dsh-voice-mode/actions/workflows/ci.yml)
7
+ [![License: MIT](https://img.shields.io/github/license/qishuilalala/dsh-voice-mode?style=flat-square)](https://github.com/qishuilalala/dsh-voice-mode/blob/main/plugin/dsh-voice-mode/LICENSE)
7
8
 
8
- Full-duplex voice conversation mode for DeepSeek Harness (dsh): speak, get a
9
- spoken answer. Streamed zipformer2 ASR → editable draft → auto send → the
10
- final reply is read out sentence-by-sentence via Edge TTS, and your voice
11
- interrupts playback and the running turn. No additional speech-service API key is needed for the default path; the host LLM has its own configuration and costs.
9
+ Full-duplex voice conversation plugin for **DeepSeek Harness (DSH)** across Web and official Desktop: local host-side streaming speech recognition (ASR / STT) into an editable draft, sentence-by-sentence TTS read-aloud with live captions, and instant voice or keyboard barge-in. No extra speech-service API key is required on the default path; the host LLM uses its own configured model and billing.
12
10
 
13
- > **English** · [中文](https://github.com/qishuilalala/dsh-voice-mode/blob/HEAD/plugin/dsh-voice-mode/README.md)
11
+ [简体中文](https://github.com/qishuilalala/dsh-voice-mode/blob/main/plugin/dsh-voice-mode/README.md) · **English** · [Changelog](https://github.com/qishuilalala/dsh-voice-mode/blob/main/CHANGELOG.md) · [Compatibility Contract](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/compat-contract.md)
14
12
 
15
13
  ![dsh-voice-mode full-duplex voice conversation](https://raw.githubusercontent.com/qishuilalala/dsh-voice-mode/HEAD/assets/hero-banner.png)
16
14
 
17
- ![Real recording: streaming transcription → auto-send → sentence-by-sentence read-aloud with live captions](https://raw.githubusercontent.com/qishuilalala/dsh-voice-mode/HEAD/plugin/dsh-voice-mode/assets/demo-voice-flow.gif)
18
-
19
- > **Current status:** Supports 7 built-in online TTS presets with per-preset API keys, Xiaomi MiMo TTS, editable post-ASR replacement rules, a 4-tab settings panel, localized keyboard/touch guidance (including macOS keycap badges and `220ms` keyboard push-to-talk), and cross-platform worker isolation. Check npm and [Releases](https://github.com/qishuilalala/dsh-voice-mode/releases) for published versions.
20
- >
21
- > **Compatibility & verification boundaries:** Client injection anchors, host/client typechecks, and isolated runtime checks pass through `dsh 0.2.2-rc.5`. See the [compatibility contract](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/compat-contract.md) for the full host/OS/browser matrix and unverified layers, the [changelog](https://github.com/qishuilalala/dsh-voice-mode/blob/main/CHANGELOG.md), and the [roadmap](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/plan/roadmap-2026-10.md). CI does not replace real-device microphone or acoustic acceptance; the declared `dsh` range is `>=0.1.1-rc.2 <0.3.0-0`, and untested host versions are not guaranteed.
22
-
23
-
24
15
  ---
25
16
 
26
- ## 🤝 Fork enhancements (this repo)
17
+ ## Key Capabilities
27
18
 
28
- - **Edge cloud TTS by default; local TTS optional (privacy-first)**: local VITS (Chinese) and local Kokoro (zh+en, 103 voices; `int8` default ~109 MB / `fp32` ~311 MB with a larger model; native `sherpa-onnx-node` addon, no WASM memory limits) run in an isolated child process;
29
- - **103 Kokoro voices** (F0-measured gender labels, 4 favourite male voices pinned), browsed with a ◀▶ stepper;
30
- - **Delta transport**: partials upload only the new 0.9 s — long push-to-talk segments finalize in seconds;
31
- - **Interaction**: a mode-switch button next to the mic (continuous ⇄ hold, persisted); hold mode records only while held;
32
- - **Long segments**: continuous listening stitches consecutive segments into one message (internally chunked at 30 s and concatenated across chunks); 1500 ms silence split by default; hold keeps pauses from splitting;
33
- - **Hardening**: session-existence check, loopback + Origin guards, endpoint-specific rate limits, pinned digests for primary/listed model files (auxiliary directories use manifest/presence checks), download-host allowlist.
19
+ - **Host-side streaming speech recognition (ASR / STT)**: runs `zipformer2` streaming recognition and optional `SenseVoice` finalization (punctuation + inverse text normalization) locally via `sherpa-onnx`. Words stream into the composer draft as you speak, split after ~1.5 s of silence, and auto-send after ~1.2 s more quiet (or stay in the draft as dictation when auto-send is off).
20
+ - **Three interaction modes**: **Continuous listening (`toggle`)**, **Push-to-talk (`hold`, via pointer/touch on the mic button or holding `Ctrl` / macOS `⌃ Control`)**, and **One-shot (`once`)** — switchable live from Settings, right-click menu, or touch `⋯` menu.
21
+ - **Five read-aloud TTS engines**: Microsoft Edge online TTS by default; fully offline local Chinese `vits` and bilingual zh+en `kokoro` (103 voices); 7 built-in OpenAI-compatible online presets (with independent per-preset API keys) plus custom endpoints; and Xiaomi MiMo TTS — with automatic 30-second local fallback on remote timeout or failure.
22
+ - **Live caption overlay & compact button UI**: bottom-right caption overlay with 4 font-size tiers, 3 width tiers, mobile safe-area inset handling, and recent 8-sentence history; turning off both the status bar and captions folds all voice indicators, timers, and error badges onto the single mic button.
23
+ - **True barge-in & backchannel yielding**: speaking during playback cancels queued audio and the running turn while salvaging the 250 ms pre-onset speech buffer so initial syllables are not swallowed; short backchannels (`right`, `嗯`, `对`) pause playback for 1.5 s instead of aborting the reply; loudspeaker setups without native echo cancellation automatically degrade to hold-to-interrupt.
24
+ - **Editable post-ASR replacements & wake word**: maintain custom post-recognition replacement rules with hit counters right inside the Settings panel, with optional pre-send LLM typo correction and standby wake-word activation.
34
25
 
35
- > ℹ️ The `demo-voice-flow.gif` at the top is a **recorded example of the UI** (voice mode → live transcription → pause auto-send → sentence-by-sentence read-aloud with live captions), produced by driving the real pipeline via `screenshots/scripts/capture-demo.mjs`; the UI keeps evolving, so the actual interface prevails.
36
-
37
- ---
26
+ ![Real recording: streaming transcription → pause auto-send → sentence read-aloud with live captions](https://raw.githubusercontent.com/qishuilalala/dsh-voice-mode/HEAD/plugin/dsh-voice-mode/assets/demo-voice-flow.gif)
38
27
 
39
- ## ✨ Features
40
-
41
- - **Voice mode**: toggle with the microphone button in the input toolbar or the global shortcut `Ctrl+Shift+V` (`⌃ Control + ⇧ Shift + V` on macOS — note `Control`, not `⌘ Command`); with the caret in the composer, `Alt+Enter` (`⌥ Option + Return` on macOS) toggles it too, without inserting a newline; globally single-active (only one session is in voice mode at a time; switching sessions yields automatically)
42
- - **Three interaction modes (switchable in settings, right-click menu, or touch `⋯` menu)**:
43
- - `toggle` (default) continuous listening: RMS VAD segmentation → streaming zipformer2 ASR (words appear as you speak, live caption preview) → automatic sentence split after 1500 ms of silence into the draft, consecutive segments joined into one message, then auto-sent after ~1.2 s more of silence (≈2.7 s total); hold `Ctrl` (`⌃ Control` on macOS) while speaking to force an immediate send
44
- - `hold` push-to-talk: from idle, **just hold the mic button to start recording and release to send** (no need to tap in first; a short tap still enters/exits); while voice mode is active, you can also **hold `Ctrl` (`⌃ Control` on macOS, ≥220 ms)** to record by keyboard and release to send; after sending, voice mode exits on its own once the reply finishes (read aloud, if on); with auto-send off, releasing only leaves the text in the composer (not sent) and exits; if you hold without speaking it exits after ~25 s; swipe up, `Esc`, window blur, or pressing another key combo cancels the segment; pauses do not split while held
45
- - `once` one-shot: talk like `toggle`; after sending, the mic turns off and voice mode exits once the reply finishes naturally; holding the mic button or pressing `Ctrl` (`⌃ Control` on macOS) interrupts the reply, resumes the mic, and keeps voice mode on for another utterance (with auto-send off: exits after the utterance, text stays in the draft)
46
- - **Read-aloud scope** (`readAloud`): `voice` (default) only replies in voice mode; `always` every reply in the visible session, typed ones included (with the session open in several tabs, only the last-viewed tab plays; switching sessions immediately stops the previous session and discards its queued speech); `off` never
47
- - **The mic button is the status panel** (PR #16 by [@dyguests](https://github.com/dyguests)): green bars follow your voice while listening, blue bars follow playback while reading, a spinner while `once` waits for the reply, a check mark before it exits; orange dot = speech detected, red dot = error (hover for details). Right-click (or keyboard menu key) on desktop, or tap the `⋯` button (or 450 ms idle long-press outside `hold` mode) on touch devices for quick settings. Turn off the status bar and captions to keep all voice UI on the button
48
- - **Wake word (optional, off by default)**: after setting `wakeWord`, entering voice mode starts in standby, and recognition only begins once the wake word is spoken (e.g. `你好小D`). **You may say it together with your command** ("wake word, check the weather") — the wake word is stripped from the transcript/caption and never sent; matching is fault-tolerant (homophone substitutions, a wrong first char, leading fillers); 3-4 characters recommended; in standby the status bar live-shows "say '<word>' · what it heard". Boundaries (important): **toggle mode only** (inactive in `hold` mode; works normally when idle under `manual` or `detect` fallback); **it must be repeated after each completed utterance or barge-in** (if you only said the wake word, the engine keeps listening so you may pause before the command); **saying it while the agent is reading does not trigger** (barge-in is VAD-based and unrelated to the wake word)
49
- - **Caption tiers**: `captionFontSize` 4 levels (0=12px / 1=14px / 2=18px / 3=24px) + `captionMaxWidth` 3 levels (0=50vw / 1=70vw / 2=90vw); adapts to narrow viewports and safe areas, with recent-sentence history after playback
50
- - **Yield semantics (ADR-0008)**: `backchannelYield` on by default — saying `嗯 / 对 / right` while the AI is reading auto-pauses for 1.5 s; genuine speech still triggers hard barge-in; lets the LLM yield the turn
51
- - **Output pipeline**: only the final answer's `text-delta` is read (reasoning/tool calls are skipped), streamed sentence-by-sentence (Edge cloud by default; local VITS / Kokoro, int8/fp32, optional) with a live caption overlay at the bottom-right; tool calls trigger a beep; the full text is still written to the chat; in voice mode a spoken-format system prompt is injected (short natural sentences, no Markdown decoration), and the reader side strips markers as well for a smoother listening experience
52
- - **Barge-in**: three sensitivity levels of voice-onset detection → local mute + host synth queue invalidation (epoch) + running turn cancellation (the half-finished part is kept and naturally flows into your new message). With a wake word set, barge-in **remains speak-to-interrupt** (the gate is the VAD, not the wake word; the engine returns to standby afterwards)
53
- - **Lazy model download with progress**: the zipformer2 Chinese streaming model (~160 MB, `.part` resumable) is downloaded on first use with live progress in the status bar; `npm run prefetch` can pre-download it
54
- - **Resilience and diagnostics**: mic-denied red hint, visible model-download failure, TTS unreachable status hint (auto retry), failed submit keeps the text in the draft, SSE auto-reconnect; the status bar also hints when the recognition / barge-in detect channel fails several times in a row or the state sync drops (self-healing transient failures stay quiet); when SenseVoice finalization takes over 2 s the status bar counts up "recognizing… Ns"; a "copy diagnostics" button copies version / runtime state / settings snapshot / phase timings in one click — **never any transcript text** (privacy)
55
- - **Settings**: location depends on your dsh version (see Settings below), with voice / rate / interrupt sensitivity / silence pause / idle timeout / model mirror / auto send / interaction mode / wake word / ITN / caption tiers / yield semantics / yield window / barge-in salvage / LLM correction; **voices are previewable** (the "试听/Preview" button synthesizes and plays the current voice at the current rate (first use may download or load a model), no need to enter voice mode; custom ShortNames are previewable too)
56
- - **Interface language**: follows dsh's language setting (Settings → General → Language) and **switches instantly, no reload** — the settings page, voice status bar, captions, voice names/gender/accent and error messages all follow it, and the LLM spoken-style prompt is chosen in English or Chinese accordingly. Dictionaries are registered in dsh's official locale service under the `voice-mode` namespace, so community language packs can add more languages (missing ones fall back to English). The plugin's name and description in the Plugins page are localized too.
57
- - **Idle exit**: auto-exit and mic release after 5 minutes of inactivity (reading, speech and a running turn renew the timer, subject to a two-hour cap since the last user activity)
28
+ ![Compact UI: all voice states folded into the mic button](https://raw.githubusercontent.com/qishuilalala/dsh-voice-mode/HEAD/plugin/dsh-voice-mode/assets/demo-compact-ui.gif)
58
29
 
59
30
  ---
60
31
 
61
- ## ⌨️ Interaction gestures & shortcuts
32
+ ## Installation & Quick Start
62
33
 
63
- Speaking to trigger a hard interruption stops playback and requests cancellation of the current running turn. Pressing `Esc` once (or clicking stop) stops read-aloud only; double-pressing `Esc` exits voice mode.
64
-
65
- | Action | Windows / Linux | macOS | Behaviour |
66
- | --- | --- | --- | --- |
67
- | Enter / exit voice mode | `Ctrl+Shift+V` | `⌃ Control + ⇧ Shift + V` | App-wide toggle (note: `Control` on macOS, not `⌘ Command`; customizable or clearable in Settings → Shortcuts). Clicking the mic button does not steal composer focus |
68
- | Toggle from composer | `Alt+Enter` | `⌥ Option + Return` | Toggles voice mode while the caret is in the chat input without inserting a newline; leaves `Ctrl/⌘ + Enter` intact for sending |
69
- | Continuous listening (`toggle`) | Speak directly; hold `Ctrl` to send now | Speak directly; hold `⌃ Control` to send now | Splits into draft after ~1500 ms silence and auto-sends after ~2.7 s total quiet; holding `Ctrl` / `⌃ Control` ≥250 ms while speaking sends immediately on release |
70
- | Push-to-talk (`hold`) — pointer/touch | Hold the mic button | Hold the mic button | From idle, hold the mic button directly to record and release to send (auto-exits once the reply finishes); swipe up or press `Esc` to cancel; short tap enters/exits |
71
- | Push-to-talk (`hold`) — keyboard | Hold `Ctrl` (≥220 ms) | Hold `⌃ Control` (≥220 ms) | While in voice mode, hold `Ctrl` / `⌃ Control` to record and release to send; pressing `Esc`, blurring the window, or pressing another key combo discards the segment |
72
- | Interrupt / stop reading | Speak / hold `Ctrl` / `Esc` | Speak / hold `⌃ Control` / `Esc` | Under `auto`, speaking interrupts immediately; under `manual` (or `detect` without native AEC), hold mic or `Ctrl` / `⌃ Control` during playback to interrupt; `Esc` stops reading, double-`Esc` exits |
73
- | Quick settings menu | Right-click mic (or Menu key) | Right-click / two-finger click mic | On touch devices, tap `⋯` next to the mic (or 450 ms idle long-press outside `hold` mode) |
74
- | Type in the input box | Type in composer | Type in composer | Auto-exits voice mode while preserving the current draft |
75
-
76
- ---
77
-
78
- ## 🚀 Quick Start (model download time varies)
79
-
80
- **Requirements**: dsh web (the plugin declares Node ≥18; the host may require a newer version), a modern browser (Chrome / Edge / Firefox, supporting `getUserMedia` and Web Audio).
34
+ **Requirements**: DeepSeek Harness `>=0.1.1-rc.2 <0.3.0-0` (verified across client injection anchors, dual host/client typechecks, and isolated runtime smoke tests from `0.1.1-rc.2` through `0.2.3-alpha.2`), Node.js `>=18.0.0`, and a modern browser supporting `getUserMedia` + Web Audio (Chrome / Edge / Firefox / Safari 16+) or the official DSH Desktop app.
81
35
 
82
36
  ```sh
83
- # Option 1: from npm (recommended)
37
+ # Option 1: Install from npm (recommended; replace "web" with your target profile if needed)
84
38
  dsh plugin --profile web add dsh-voice-mode
85
- # Equivalent via npx if the dsh CLI is not installed locally:
86
- npx -y @deepseek-ai/dsh plugin --profile web add dsh-voice-mode
87
39
 
88
- # Option 2: local tarball
89
- dsh plugin --profile web add ./dsh-voice-mode-<version>.tgz
40
+ # Equivalent via npx when the dsh CLI is not installed globally:
41
+ npx -y @deepseek-ai/dsh plugin --profile web add dsh-voice-mode
90
42
 
91
- # Option 3: from source
43
+ # Option 2: Build and install from source (Node.js 22.18+ on the 22.x line and pnpm 11)
92
44
  git clone https://github.com/qishuilalala/dsh-voice-mode.git
93
- cd dsh-voice-mode/plugin/dsh-voice-mode && pnpm install && pnpm build
45
+ cd dsh-voice-mode/plugin/dsh-voice-mode
46
+ pnpm install --frozen-lockfile
47
+ pnpm run build
94
48
  dsh plugin --profile web add .
95
49
  ```
96
50
 
97
- **Bundle plugins require a dsh restart to take effect** (restart methods by platform):
98
-
99
- - **Linux with a configured systemd service**: restart the actual service (for example, `systemctl restart dsh` only if that is its name). The install command above targets the web profile; use your actual profile for other deployments.
100
- - **Windows / macOS / manual hosting**: restart your dsh process (kill and run `dsh web` again, or restart it in your service manager)
101
-
102
- **Optional**: pre-download the ASR model to reduce the download wait on the first voice-mode entry:
103
-
104
- ```sh
105
- npm run prefetch # run inside the plugin dir; writes to the platform cache dir
106
- # or specify the cache location: node scripts/prefetch.mjs --cache-dir /where/ever/models
107
- ```
108
-
109
- **First run**:
51
+ Restart the DSH host process after installing or updating the bundle. On first entry into voice mode, the plugin lazily downloads the local recognition models (~160 MB streaming model + optional ~228 MB SenseVoice model, with `.part` resume and live progress in the status bar; users in mainland China can set `modelHost` to `https://hf-mirror.com`, or pre-download via `npm run prefetch` inside the package directory).
110
52
 
111
- 1. Click the mic button in the input toolbar (or press `Ctrl+Shift+V`) to enter voice mode; a status bar appears above the input box
112
- 2. Choose how to speak: just talk and let the ~1500 ms pause split and ~2.7 s of quiet auto-send (toggle); or hold the mic button and release to send (hold)
113
- 3. The AI answer is read sentence-by-sentence with a caption overlay at the bottom-right; click "Skip" or just start speaking to interrupt
114
- 4. Click "Exit" in the status bar (or press `Ctrl+Shift+V` again) to leave voice mode
53
+ ---
115
54
 
116
- On first entry the recognition model is downloaded; the status bar shows `Loading model… <file> <percent>%`.
55
+ ## Gestures & Shortcuts (Windows / Linux vs macOS)
117
56
 
118
- If a wake word is configured, you land in standby first (the status bar prompts `Say "<wake word>" to start`), and recognizing starts after you speak the wake word.
57
+ | Action | Windows / Linux | macOS | Behaviour |
58
+ | --- | --- | --- | --- |
59
+ | Enter / exit voice mode | `Ctrl+Shift+V` | `⌃ Control + ⇧ Shift + V` | App-wide toggle (uses `Control` on macOS by default, not `⌘ Command`; customizable or clearable in Settings → Shortcuts) |
60
+ | Toggle from composer | `Alt+Enter` | `⌥ Option + Return` | Toggles voice mode while focused in the chat composer without inserting a newline; leaves `Ctrl/⌘ + Enter` intact for sending |
61
+ | Continuous listening (`toggle`) | Speak directly; hold `Ctrl` to send now | Speak directly; hold `⌃ Control` to send now | Splits into draft after ~1500 ms silence and auto-sends after ~1.2 s more quiet; hold `Ctrl` / `⌃ Control` ≥250 ms while speaking to send immediately on release |
62
+ | Push-to-talk (`hold`) — pointer/touch | Hold the mic button, release to send | Hold the mic button, release to send | From idle, **hold the mic button directly to start recording**, release to send, and voice mode auto-exits once the reply finishes; swipe up or press `Esc` to cancel |
63
+ | Push-to-talk (`hold`) — keyboard | Hold `Ctrl` (≥220 ms) | Hold `⌃ Control` (≥220 ms) | While voice mode is active, hold `Ctrl` / `⌃ Control` to record continuously and release to send; `Esc`, window blur, or pressing another key combo cancels the segment |
64
+ | One-shot (`once`) | Speak one turn; auto-exits after reply | Speak one turn; auto-exits after reply | Turns off the mic after sending and exits once read-aloud finishes; holding mic or `Ctrl` / `⌃ Control` during playback interrupts and resumes listening |
65
+ | Interrupt / stop reading | Speak / hold `Ctrl` / `Esc` | Speak / hold `⌃ Control` / `Esc` | Under `auto`, speaking interrupts immediately; under `manual` (or `detect` without native AEC), hold mic or `Ctrl` / `⌃ Control` during playback; `Esc` stops reading, double-`Esc` exits |
66
+ | Quick settings menu | Right-click mic button (or Menu key) | Right-click / two-finger click mic | On touch devices, tap `⋯` next to the mic (or 450 ms idle long-press outside `hold` mode) to switch modes, read-aloud scope, captions, status bar, and auto-send |
119
67
 
120
68
  ---
121
69
 
122
- ## ⚙️ Settings
70
+ ## Settings Panel & Full 36-Key Reference
123
71
 
124
- **Works on every dsh version: Settings → Voice Mode** (the plugin registers its own page in the Settings dialog). Secondary entry points (same card) vary by version:
72
+ **Universal entry on every DSH version: Settings → Voice Mode**. Secondary entry points by host version:
125
73
 
126
- - dsh ≤ 0.1.5: Settings → Plugins → plugin config → voice mode
127
- - dsh 0.1.6-alpha and later (incl. 0.1.7 / 0.2.0): left sidebar **Plugins** → the installed `dsh-voice-mode` → the "Voice Mode" card on its detail page
128
- - On dsh 0.1.7+ the values are stored in the plugin's own file `~/.dsh/voice-mode.settings.json` (under `$DSH_HOME`) and take precedence over same-named keys in the profile config. The first run migrates the old `voice-mode:` block from `settings.yaml(.imported)` once. To reset, set the file's content to `{}` (do not delete it).
74
+ - `dsh <= 0.1.5`: Settings → Plugins → Plugin config → Voice Mode
75
+ - `dsh >= 0.1.6-alpha`: Left sidebar **Plugins** → installed `dsh-voice-mode` → "Voice Mode" card on its detail page (on `0.1.7+`, values persist in `$DSH_HOME/voice-mode.settings.json` with `0600` permissions; to reset to defaults, replace its content with `{}` rather than deleting the file)
129
76
 
77
+ ![Redesigned 4-tab Settings Panel](https://raw.githubusercontent.com/qishuilalala/dsh-voice-mode/HEAD/plugin/dsh-voice-mode/assets/settings-panel.png)
130
78
 
131
- ### Full 35-key settings table
79
+ ### Settings Reference (36 Keys)
132
80
 
133
81
  | Key | Default | Description |
134
82
  | --- | --- | --- |
135
- | `ttsEngine` | `edge` | Read-aloud engine: `edge` Microsoft cloud (default, fast) / `vits` local Chinese / `kokoro` local zh+en / `openai` any OpenAI-compatible server / `mimo` Xiaomi MiMo (independent `mimoTts.apiKey`, see below); **applies live** |
136
- | `kokoroModel` | `int8` | Kokoro precision: `int8` (default, 109 MB, CPU/low-bandwidth) / `fp32` (311 MB, better quality, GPU/large memory); same 103 voices; **applies live** |
137
- | `voice` | per engine | Voice: 5 VITS speakers; 103 Kokoro voices (◀▶ stepper; 62/68/75/76 favourite males pinned); Edge ShortNames below. The inline "试听" button previews it at the current rate |
138
- | `rate` | `1.1` | Reading speed multiplier (0.5 slow ~ 2.0 fast), **applies live** |
139
- | `interruptLevel` | `0` | Barge-in sensitivity (host-side VAD frame detection + echo gate): 0 high threshold (3 frames) / 1 medium (2 frames) / 2 low (1 frame) |
140
- | `bargeInMode` | `detect` | Barge-in mode: `detect` auto-probes native echo cancellation (default; switches playback to hold-to-interrupt when inactive) / `auto` force interrupt as soon as you speak (headphones / quiet rooms) / `manual` manual interrupt (recommended on loudspeakers: speak directly or say the wake word when idle, and hold mic/`Ctrl` to interrupt during playback; see ADR-0006) |
141
- | `echoGateDb` | `6` | Fallback echo-gate threshold when native AEC is unavailable. Inactive with native AEC. Only on the fallback path, a higher value is more conservative; verify the device and barge-in mode before tuning |
142
- | `silenceMs` | `1500` | Silence pause in ms that marks the end of a complete sentence |
143
- | `idleTimeoutMinutes` | `5` | Minutes of inactivity before auto-exiting voice mode (reading, speech and a running turn renew the timer, subject to a two-hour cap since the last user activity) |
144
- | `modelHost` | default | Model download host (use `https://hf-mirror.com` on mainland networks) |
145
- | `autoSend` | `true` | Auto-send once quiet (consecutive segments join into one message); when off, text only goes to the draft (hold `Ctrl` / release in hold mode still sends) |
146
- | `mode` | `toggle` | Interaction mode: `toggle` continuous listening + 1500 ms silence split; `hold` push-to-talk, release to send (short tap exits); `once` one utterance, then exit after the reply finishes naturally; manual interruption resumes the mic and keeps voice mode on |
147
- | `readAloud` | `voice` | What gets read aloud: `voice` only replies in voice mode; `always` every reply in the visible session, typed ones included; switching sessions stops the previous read-aloud; `off` never |
148
- | `showStatusBar` | `true` | Voice status bar above the composer; when off, status lives on the mic button (timer below it, notices beside it) |
149
- | `showCaptions` | `true` | Floating caption while reading aloud |
150
- | `autoResume` | `false` | Auto-restore voice mode when switching back to your last voice session (off by default). When on: the next time you enter that session it auto-enters voice mode and restores it; when off, press `Ctrl+Shift+V` manually. While it is off, switching back to your last voice session shows a short grey hint about this next to the input box, once per browser |
151
- | `shortcut` | `Ctrl+Shift+V` | Shortcut to enter / exit voice mode (modifiers Ctrl/Shift/Alt/Meta + one letter / digit / Enter / Space / Tab). In the "Shortcuts" group of the settings page, click "Record" and press the combo (`Esc` cancels, `Backspace` clears; a missing modifier or an unsupported key such as arrows / F-keys is flagged); **empty = disabled**, use the mic button instead; **applies immediately** |
152
- | `composerShortcut` | `Alt+Enter` | Shortcut that toggles voice mode while the caret is in the composer (Option+Enter on Mac), no newline inserted; same format and recording as `shortcut`; **empty = disabled**; the settings card's own inputs are not intercepted; `Cmd/Ctrl+Enter` is not used; **applies immediately**. "Restore defaults" resets both shortcuts to `Ctrl+Shift+V` and `Alt+Enter` |
153
- | `wakeWord` | empty (off) | Wake word (e.g. `你好小D`): speak it after entering to activate; empty = off. **May be said together with your command** — the wake word is stripped and never sent; fault-tolerant matching (edit distance ≤1 + a 3-char leading window absorbs homophones/fillers); **3-4 characters recommended** (single-char words get no tolerance; a 2-char word also absorbs any same-first-char 2-char word); must be repeated after each utterance split or barge-in; **inactive in hold-to-talk mode** (works normally when idle under `manual` or `detect` fallback); not triggered while the agent is reading |
154
- | `spokenFormat` | `true` | Spoken-format system prompt: inject "short natural sentences, no Markdown decoration" into voice-mode replies only, **applies live** |
155
- | `senseVoice` | `true` | Re-transcribe the finalized utterance with SenseVoice (punctuation + number normalization, more accurate; on by default). **Turning it off saves ~228 MB of models** and uses streaming recognition only (faster, less accurate) |
156
- | `toolBeep` | `false` | Tool-call beep (off by default): when on, a short beep plays each time the agent calls a tool; off = silent |
157
- | `senseITN` | `true` | SenseVoice inverse text normalization (number / date / currency; on by default) |
158
- | `openaiPreset` | empty (manual) | Online TTS preset id (`siliconflow-cosyvoice2` / `siliconflow-fish` / `openrouter-openai` / `openai-official` / `groq-playai` / `selfhosted-kokoro` / `selfhosted-vllm`, or `custom`). Fills baseUrl/model and falls back to the preset voice when `voice` is empty; keys prefer settings card > `openaiTts.apiKeys[preset]` > `openaiTts.apiKey`; **applies live** |
159
- | `openaiBaseUrl` | empty (preset/config) | Online TTS endpoint override configurable directly in the settings card (priority: settings > preset > `openaiTts.baseUrl`); pair with `custom` preset for any OpenAI-compatible server; **applies live** |
160
- | `openaiModel` | empty | Online TTS model override (same priority as `openaiBaseUrl`); **applies live** |
161
- | `openaiApiKey` | empty (config fallback) | Online TTS API key entered in the settings card; stored in the host-side `0600` settings file and **never sent back to the browser** (`GET /voice-mode/settings` returns empty string + `keys.*` booleans); priority: per-preset key > global key > `openaiTts.apiKeys[preset]` > `openaiTts.apiKey`; **applies live** |
162
- | `openaiApiKeys` | `{}` (none) | Per-preset API keys: `{presetId: key}` map in the settings card; whichever preset is selected uses its own key without 401 mismatches when switching presets; empty entries fall back to the global key; **booleans only, never plaintext**; **applies live** |
163
- | `mimoApiKey` | empty (config fallback) | Xiaomi MiMo API key (`api-key` header) entered in the settings card; host-only `0600` storage, never sent back to the browser; falls back to `mimoTts.apiKey`; **applies live** |
164
- | `asrReplacements` | `[]` | Post-recognition correction table `[{from:[misheard], to:wanted}]` (≤200 rules / ≤12 KB UTF-8); applies to both partials and finals, editable in the settings card with hit counters; **applies live** |
165
- | `captionFontSize` | `0` | Caption font tier 0=12px / 1=14px / 2=18px / 3=24px (default 0 is byte-equivalent to legacy) |
166
- | `captionMaxWidth` | `1` | Caption width tier 0=50vw / 1=70vw / 2=90vw |
167
- | `backchannelYield` | `true` | Yield semantics (ADR-0008); saying `嗯 / 对` while reading auto-pauses for 1.5 s; genuine speech still triggers hard barge-in; off = behavior identical to pre-change |
168
- | `bargeInSalvage` | `true` | Barge-in salvage (ADR-0012): when you speak to interrupt while the agent is reading aloud, keep what you said from speech onset to break confirmation and merge it into recognition (prevents swallowed break-in speech; off = discard pre-break audio; recommended off only on speakers without echo cancellation) |
169
- | `llmCorrect` | `false` | LLM correction (off by default): before sending, run one LLM pass over the whole transcribed text (typos/homophones/punctuation only, meaning preserved; reuses the host configured model). On = about one extra second per message; falls back to the original text if correction fails or the model answers you instead of correcting |
170
- | `yieldMs` | `1500` | Yield-window length (ms, 500-3000): how long TTS frames are dropped after `backchannelYield` triggers; if you really want to speak in the window the normal `hardBreak` takes over, and playback resumes when the window ends |
171
-
172
- Effect timing, in four tiers: ① immediately — shortcut / composer shortcut / interaction mode / read-aloud scope / auto-send / captions / status bar / engine / voice / rate / spoken format (applies to later replies) / model mirror (next download attempt); ② next recognition — finalization re-transcription (SenseVoice) / ITN; ③ next utterance — silence threshold (endpoint; the send wait stays a fixed 1.2 s); ④ next time you enter voice mode — interrupt sensitivity / barge-in mode / echo gate / auto-resume / wake word / tool beep / caption font / caption width / backchannel yielding / yield window / barge-in salvage / LLM correction / idle timeout. Saved-but-not-yet-effective items are listed at the top of the settings card with their current effective values. Defaults come from the plugin config (`base` layer) — they follow the config unless explicitly changed.
173
-
174
- ### Common voices (full list: `node scripts/list-voices.mjs`)
175
-
176
- > **Desktop (Electron) note**: the official desktop host runs inside Electron, whose V8 forbids the external buffers returned by Kokoro's native add-on. The plugin automatically runs Kokoro in a real Node.js instead — **it needs Node.js >= 18 on PATH** (or set `DSHVM_NODE` to its path). Without it Kokoro reports an error; use the default Edge engine or local VITS (both work on desktop).
177
-
178
- | ShortName | Description |
83
+ | `ttsEngine` | `edge` | Read-aloud engine: `edge` Microsoft online (default) / `vits` local Chinese / `kokoro` local zh+en / `openai` OpenAI-compatible server / `mimo` Xiaomi MiMo; **applies live** |
84
+ | `kokoroModel` | `int8` | Kokoro model precision: `int8` (default, ~109 MB, CPU-friendly) / `fp32` (~311 MB, higher fidelity); shares 103 voices; **applies live** |
85
+ | `voice` | per engine | Voice id: 5 VITS speakers; 103 Kokoro voices (dropdown + ◀▶ stepper, popular male voices `62/68/75/76` pinned); 322 Edge voices; inline "Preview" button synthesizes a sample live; **applies live** |
86
+ | `rate` | `1.1` | Playback speed multiplier (`0.5` slow – `2.0` fast); **applies live** |
87
+ | `interruptLevel` | `0` | Barge-in sensitivity (host VAD frame count + echo gate): `0` high threshold (3 frames) / `1` medium (2 frames) / `2` low (1 frame) |
88
+ | `bargeInMode` | `detect` | Barge-in mode: `detect` probes native browser echo cancellation (falls back to hold-to-interrupt during playback when inactive) / `auto` speak-to-interrupt (headphones) / `manual` hold mic or `Ctrl` to interrupt (loudspeakers) |
89
+ | `echoGateDb` | `6` | Fallback echo-gate threshold (`3`–`12` dB) used only when native AEC is unavailable |
90
+ | `silenceMs` | `1500` | Silence duration in milliseconds (`500`–`30000`) that ends a spoken sentence |
91
+ | `idleTimeoutMinutes` | `5` | Minutes of inactivity before auto-exiting voice mode (`1`–`120`; playback and running turns renew activity, capped at 2 hours) |
92
+ | `modelHost` | empty (official) | Model download mirror override (e.g. `https://hf-mirror.com` for mainland China); applies on the next download attempt |
93
+ | `autoSend` | `true` | Auto-send after silence (consecutive segments join into one message); when off, transcripts stay in the draft (holding `Ctrl` or releasing in `hold` still sends); **applies live** |
94
+ | `autoResume` | `false` | Automatically re-enter voice mode when switching back to your last active voice session (off by default) |
95
+ | `mode` | `toggle` | Interaction mode: `toggle` continuous listening / `hold` push-to-talk / `once` single turn then auto-exit; **applies live** |
96
+ | `readAloud` | `voice` | Read-aloud scope: `voice` only in voice mode / `always` all replies in the visible session (including typed prompts) / `off` never; **applies live** |
97
+ | `showStatusBar` | `true` | Show the voice status bar above the composer; when off, indicators fold onto the mic button; **applies live** |
98
+ | `showCaptions` | `true` | Show the floating live caption overlay during playback; **applies live** |
99
+ | `shortcut` | `Ctrl+Shift+V` | App-wide shortcut to enter/exit voice mode (modifier + letter/digit/Enter/Space/Tab; supports live recording in Settings, empty = disabled); **applies live** |
100
+ | `composerShortcut` | `Alt+Enter` | Shortcut to toggle voice mode while focused in the composer (`Option+Return` on macOS, no newline inserted, empty = disabled); **applies live** |
101
+ | `wakeWord` | empty (off) | Standby wake word (e.g. `你好小D`, 3–4 chars recommended): active in `toggle` standby only, can be spoken continuously with the command (prefix stripped), resets to standby after each utterance or barge-in |
102
+ | `toolBeep` | `false` | Play a short subtle beep when the agent invokes a tool (off by default) |
103
+ | `spokenFormat` | `true` | Inject a spoken-style prompt ("short natural sentences, no Markdown formatting") into active voice-mode replies only; **applies live** |
104
+ | `senseVoice` | `true` | Re-transcribe finalized segments with SenseVoice for punctuation and ITN (disabling saves ~228 MB of model downloads and uses streaming zipformer only) |
105
+ | `senseITN` | `true` | SenseVoice inverse text normalization (normalizes spoken numbers, dates, and currencies) |
106
+ | `openaiPreset` | empty (manual) | Built-in online TTS preset: `siliconflow-cosyvoice2` / `siliconflow-fish` / `openrouter-openai` / `openai-official` / `groq-playai` / `selfhosted-kokoro` / `selfhosted-vllm` (or `custom`); **applies live** |
107
+ | `openaiBaseUrl` | empty (preset/config) | Online TTS base URL override (priority: settings panel > preset > bundle config); **applies live** |
108
+ | `openaiModel` | empty (preset/config) | Online TTS model override (same priority as `openaiBaseUrl`); **applies live** |
109
+ | `openaiApiKey` | empty (config fallback) | Global fallback API key for OpenAI-compatible TTS (`0600` host-only storage, never returned to the browser); **applies live** |
110
+ | `openaiApiKeys` | `{}` | Per-preset API key map (`{presetId: key}` stored host-side; switching presets automatically switches keys without 401 mismatches; API exposes booleans only); **applies live** |
111
+ | `mimoApiKey` | empty (config fallback) | Dedicated Xiaomi MiMo API key (`api-key` header, isolated from OpenAI keys, host-only `0600` storage); **applies live** |
112
+ | `asrReplacements` | `[]` | Post-ASR replacement rules `[{from:[misheard], to:target}]` (up to 200 rules / 12 KB, rewrites partials and finals with hit counters); **applies live** |
113
+ | `captionFontSize` | `0` | Caption font-size tier: `0`=12px / `1`=14px / `2`=18px / `3`=24px |
114
+ | `captionMaxWidth` | `1` | Caption max-width tier: `0`=50vw / `1`=70vw / `2`=90vw |
115
+ | `backchannelYield` | `true` | Backchannel yielding: short acknowledgements during playback pause TTS briefly instead of triggering a hard barge-in |
116
+ | `yieldMs` | `1500` | Backchannel yield window in milliseconds (`500`–`3000`) before playback resumes automatically |
117
+ | `bargeInSalvage` | `true` | Barge-in speech salvage: merges 250 ms pre-onset audio from the playback ring buffer into the new ASR segment so initial words are preserved |
118
+ | `llmCorrect` | `false` | Optional pre-send LLM pass to fix homophones/typos/punctuation using the host's configured model (falls back to raw transcript on error or timeout) |
119
+
120
+ **Four effect-timing tiers**: ① **Immediate** (shortcuts, interaction mode, read-aloud scope, auto-send, caption/status-bar toggles, TTS engine/preset/keys/voice/rate, replacement rules, spoken-format prompt, model mirror) ② **Next recognition** (SenseVoice finalization, ITN) ③ **Next utterance** (silence threshold) ④ **Next voice-mode entry** (barge-in sensitivity/mode, echo gate, wake word, caption dimensions, idle timeout). Pending changes display a banner at the top of the settings card showing their **current effective values**.
121
+
122
+ ### Local Voices & Common Edge Voices
123
+
124
+ > **Official Desktop (Electron) note**: Electron's V8 sandbox disallows external native buffers used by Kokoro's addon, so the plugin automatically spawns a system Node.js (`>=18` on `PATH`, or pointed to by `DSHVM_NODE`) for local `kokoro`. If standalone Node.js is not installed, use `edge` or pure-WASM local `vits`.
125
+
126
+ - **Local VITS (Chinese, 5 speakers)**: `suyingxue`, `gunian`, `fushiyu`, `bingjiao`, `bazong`
127
+ - **Local Kokoro (zh+en bilingual, 103 voices)**: pinned male voices `62`, `68`, `75`, `76`; common Mandarin female voices `48` (`zf_xiaobei`), `49` (`zf_xiaoni`), `50` (`zf_xiaoxiao`), `51` (`zf_xiaoyi`)
128
+ - **Common Edge ShortNames** (run `node scripts/list-voices.mjs` in the package directory to list all 322 voices):
129
+
130
+ | Edge ShortName | Description |
179
131
  | --- | --- |
180
- | `zh-CN-XiaoxiaoNeural` | Xiaoxiao · Female (default) |
181
- | `zh-CN-XiaoyiNeural` | Xiaoyi · Female |
182
- | `zh-CN-YunxiNeural` | Yunxi · Male |
183
- | `zh-CN-YunjianNeural` | Yunjian · Male |
184
- | `zh-CN-YunyangNeural` | Yunyang · Male |
185
- | `zh-CN-YunxiaNeural` | Yunxia · Male |
186
- | `zh-CN-liaoning-XiaobeiNeural` | Xiaobei · Northeastern Mandarin · Female |
187
- | `zh-CN-shaanxi-XiaoniNeural` | Xiaoni · Shaanxi Mandarin · Female |
188
- | `zh-HK-HiuMaanNeural` | HiuMaan · Cantonese · Female |
189
- | `zh-HK-WanLungNeural` | WanLung · Cantonese · Male |
190
- | `zh-TW-HsiaoYuNeural` | HsiaoYu · Taiwanese Mandarin · Female |
191
- | `zh-TW-YunJheNeural` | YunJhe · Taiwanese Mandarin · Male |
192
- | `en-US-AriaNeural` | Aria · English · Female |
193
- | `en-US-GuyNeural` | Guy · English · Male |
132
+ | `zh-CN-XiaoxiaoNeural` | Xiaoxiao · Mandarin Female (default) |
133
+ | `zh-CN-XiaoyiNeural` | Xiaoyi · Mandarin Female |
134
+ | `zh-CN-YunxiNeural` | Yunxi · Mandarin Male |
135
+ | `zh-CN-YunjianNeural` | Yunjian · Mandarin Male |
136
+ | `zh-CN-YunyangNeural` | Yunyang · Mandarin Male |
137
+ | `zh-CN-liaoning-XiaobeiNeural` | Xiaobei · Northeastern Mandarin Female |
138
+ | `zh-HK-HiuMaanNeural` | HiuMaan · Cantonese Female |
139
+ | `zh-TW-HsiaoYuNeural` | HsiaoYu · Taiwanese Mandarin Female |
140
+ | `en-US-AriaNeural` | Aria · English Female |
141
+ | `en-US-GuyNeural` | Guy · English Male |
194
142
 
195
143
  ---
196
144
 
197
- ## 🔧 Configuration (bundle patch / settings.yaml)
145
+ ## Advanced YAML Configuration (`settings.yaml` / `cordis.patch.yml`)
146
+
147
+ In addition to configuring everything in the GUI Settings panel, you can seed defaults in your host configuration (`enabled`, `cacheDir`, and `allowLan` are host-config-only; runtime settings prioritize the GUI Settings file):
198
148
 
199
- You can also edit the `voice-mode:` section of `~/.dsh/settings.yaml` directly (the GUI card and RPC write to the same document layer):
149
+ ### OpenAI-Compatible TTS (`ttsEngine: openai`)
200
150
 
201
151
  ```yaml
202
152
  - id: voice-mode
203
153
  name: dsh-voice-mode
204
154
  config:
205
- enabled: true # false = disables voice mode entirely (toggle rejects)
206
- cacheDir: ~/.cache/dsh-voice-mode/models # overridable; platform default otherwise
207
- # Defaults seeded for the settings (the settings panel overrides; the panel is authoritative):
208
- voice: zh-CN-XiaoxiaoNeural
209
- rate: 1.1
210
- interruptLevel: 0
211
- silenceMs: 1500
212
- idleTimeoutMinutes: 5
213
- modelHost: https://huggingface.co
155
+ enabled: true
156
+ ttsEngine: openai
157
+ voice: vivian
158
+ openaiTts:
159
+ baseUrl: http://127.0.0.1:8091/v1
160
+ apiKey: ''
161
+ apiKeys:
162
+ siliconflow-cosyvoice2: ''
163
+ openrouter-openai: ''
164
+ openai-official: ''
165
+ model: Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice
166
+ voice: vivian
167
+ responseFormat: mp3
168
+ timeoutMs: 8000
169
+ fallback: kokoro
170
+ fallbackVoice: zf_xiaobei
171
+ instructions: ''
214
172
  ```
215
173
 
216
- > Note: the effective values of `voice/rate/interruptLevel/silenceMs/idleTimeoutMinutes/modelHost/autoSend`
217
- > come from the **settings panel**; the bundle config only seeds defaults for those keys
218
- > (`enabled/cacheDir` remain bundle-config-only).
219
- > The plugin HTTP namespace is fixed to `/voice-mode` (matching the client bundle contract; not configurable).
220
-
221
- ### OpenAI-compatible & Xiaomi MiMo TTS (`ttsEngine: openai` / `mimo`)
174
+ ### Xiaomi MiMo TTS (`ttsEngine: mimo`)
222
175
 
223
- Any server that implements OpenAI's `POST /v1/audio/speech` can read replies aloud: a self-hosted one on a GPU machine ([vLLM-Omni](https://github.com/vllm-project/vllm-omni), [Kokoro-FastAPI](https://github.com/remsky/Kokoro-FastAPI), LocalAI, ...) or a hosted API such as SiliconFlow, OpenAI, [OpenRouter](https://openrouter.ai/docs/guides/overview/multimodal/tts), or Groq PlayAI. You can pick one of the **7 built-in presets** (or `custom`) and enter `openaiBaseUrl` / `openaiModel` / `openaiApiKey` directly in the **Settings card** (priority: settings card > preset > bundle config), or seed them in the bundle config below; keys remain host-only (`0600`) and are never returned to the browser. Xiaomi MiMo (`ttsEngine: mimo`) uses its own independent key (`mimoApiKey` in the card or `mimoTts.apiKey` in config) so keys never leak across providers:
176
+ Xiaomi MiMo uses `POST /v1/chat/completions` audio output with an `api-key` header and keeps its credential strictly isolated from `openaiTts` (official docs: <https://mimo.mi.com>):
224
177
 
225
178
  ```yaml
226
179
  - id: voice-mode
227
180
  name: dsh-voice-mode
228
181
  config:
229
- ttsEngine: openai
230
- voice: vivian # voice name on the server; empty = openaiTts.voice
231
- openaiTts:
232
- baseUrl: http://gpu-box:8091/v1 # OpenRouter: https://openrouter.ai/api/v1, OpenAI: https://api.openai.com/v1
233
- apiKey: '' # Bearer key, empty for servers without auth
234
- model: Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice
235
- voice: vivian
236
- responseFormat: mp3 # mp3 | wav
237
- timeoutMs: 8000 # per sentence; slower counts as unavailable
238
- fallback: kokoro # none | vits | kokoro: local engine while the server is down or slow
239
- fallbackVoice: zf_xiaobei # empty = that engine's default voice
240
- instructions: '' # optional style text for models that accept it
182
+ ttsEngine: mimo
183
+ voice: 冰糖
184
+ mimoTts:
185
+ apiKey: ''
186
+ baseUrl: https://api.xiaomimimo.com/v1
187
+ model: mimo-v2.5-tts
188
+ voice: mimo_default
189
+ instructions: ''
190
+ responseFormat: wav
191
+ timeoutMs: 8000
192
+ fallback: kokoro
193
+ fallbackVoice: zf_xiaobei
241
194
  ```
242
195
 
243
- Each sentence is one request (the queue already synthesizes sentence by sentence while the reply is still streaming, so in-sentence streaming would not start playback any sooner). `rate` is sent as `speed` when it is not 1. With a `fallback`, a failed or timed-out request makes that sentence (and the next 30 s) use the local engine, then the server is tried again, so a dead server does not cost a timeout per sentence. The text to be spoken goes to `baseUrl`, so pick a server you trust with your replies.
244
-
245
- ### Fixing misheard words (`asrReplacements`)
196
+ ### Post-ASR Replacement Rules (`asrReplacements`)
246
197
 
247
- Recognizers keep mishearing some names and English words inside Chinese speech (a name such as "Sakina" can come out as "ski男"). The usual fix, hotwords, doesn't fit here: sherpa-onnx supports hotwords only for transducer models, the streaming zipformer works on Chinese characters and can't spell English words, and the SenseVoice model that produces the final text has no hotword input. Until a model with hotwords covers this, a replacement list is a stopgap: it rewrites the text after recognition, in partial and final results alike, so captions, the draft and the wake word all see the corrected text.
198
+ Editable live in **Settings → Voice Mode → Advanced → Recognition replacements** (applies immediately), or seeded in YAML:
248
199
 
249
200
  ```yaml
250
201
  - id: voice-mode
202
+ name: dsh-voice-mode
251
203
  config:
252
204
  asrReplacements:
253
- - from: [ski男] # what the recognizer produced, one or more spellings
254
- to: Sakina # what you want
205
+ - from: [ski男, ski 男]
206
+ to: Sakina
255
207
  ```
256
208
 
257
- Matching is case-insensitive and ignores whitespace between Latin and CJK text ("ski 男" matches too). A spelling that starts or ends with a Latin letter or digit only matches a whole word, so `sina` leaves `Sinatra` alone; CJK text has no word boundaries, so a Chinese spelling matches as a substring. The longest spelling wins at each position and replaced text is not matched again. Keep entries to what you have actually seen misheard: a short or common spelling will also rewrite real words. The list is read from the plugin config, so a change takes effect with the next recognition request after the profile reloads.
258
-
259
- ---
260
-
261
- ## 🌐 API
262
-
263
- | Route | Description |
264
- | --- | --- |
265
- | `GET /voice-mode/stream` | SSE: `event: audio` (`{sessionId, seq, text, audio(base64 MP3)}`), `event: mode` (global single-active ownership), `event: tool` (beep), `event: asr-progress / asr-ready / asr-error / tts-error` |
266
- | `POST /voice-mode/toggle` | `{sessionId, on}` enter/exit voice mode (globally single-active) |
267
- | `POST /voice-mode/asr` | Raw f32 LE 16k PCM payload → `{text}` (streaming zipformer2); returns `202 {loading}` until the model is ready; `?reset=1` discards the in-flight segment (used on wake-word hit) |
268
- | `POST /voice-mode/cancel` | `{sessionId}` invalidates the TTS queue and drops the in-flight ASR segment |
269
- | `POST /voice-mode/preview` | `{voice, rate?}` one-shot synthesis preview → `audio/mpeg` (400 missing voice / voice too long; 502 synthesis failure, e.g. invalid ShortName; 403 when the plugin's `enabled=false`). Does not require voice mode to be active; uses an isolated synthesis connection and does not affect the reading queue |
270
- | `GET /voice-mode/config` | Client bootstrap parameters (silence threshold / sensitivity / voice and rate, etc.) — includes the ASR-side fields `senseITN` / `senseVoice` / `captionFontSize` / `captionMaxWidth` / `backchannelYield` / `yieldMs` / `bargeInSalvage` / `llmCorrect` |
271
- | `POST /voice-mode/correct` | `{text}` one LLM correction pass before sending (typos/homophones/punctuation only; reuses the host-configured model) → `{text}`; on failure/timeout/no model it falls back to the original text and never blocks sending |
272
- | `GET /voice-mode/voices` | Full Edge voice list (fetched when Edge is selected in settings; the client falls back to the common list on network failure) |
273
- | `GET /voice-mode` | Health check `{ok, name, enabled, active}` |
274
-
275
- ---
276
-
277
- ## 💾 Model & cache
278
-
279
- - Recognition model: `csukuangfj/sherpa-onnx-streaming-zipformer-zh-int8-2025-06-30` (encoder ≈154 MB / decoder / joiner / tokens, ~160 MB total), running host-side via sherpa-onnx (Node WASM, Apache-2.0, natively cross-platform)
280
- - Cache directory defaults by platform:
281
- - **Windows**: `%LOCALAPPDATA%\dsh-voice-mode\models`
282
- - **macOS / Linux**: `~/.cache/dsh-voice-mode/models`
283
- - both overridable via `cacheDir`
284
- - Downloads use `.part` resume (single-file models only); `huggingface.co` falls back to `hf-mirror.com` on failure (configurable via `modelHost`)
285
- - A 120 s idle watchdog guards downloads: any received bytes reset it, a stalled upstream is aborted and the next source tried, and closing the panel aborts in-flight downloads
286
- - Main model files are SHA256-pinned; within one process a file whose size+inode+ctime is unchanged is not re-verified (the cache is in memory only, so the first run after a restart verifies in full); the Kokoro espeak-ng-data tree is judged complete by manifest file sizes / file count, and once first downloaded Kokoro works fully offline
209
+ Rules starting or ending with ASCII letters/digits match whole words only (`sina` will not alter `Sinatra`), while CJK rules match longest-first substrings in a single pass across partial captions, composer drafts, and wake-word checks.
287
210
 
288
211
  ---
289
212
 
290
- ## 🏛️ How it works
291
-
292
- ```mermaid
293
- flowchart LR
294
- subgraph Client[Browser Client]
295
- Mic[Microphone 16kHz<br/>AudioWorklet<br/>echoCancellation:true] --> VAD[Client-side VAD<br/>RMS segmentation]
296
- VAD -->|partial 0.9s| UI[Statusbar + caption overlay]
297
- end
298
-
299
- subgraph Host[dsh.host]
300
- ASR[zipformer2 streaming ASR<br/>host-side WASM]
301
- SV[SenseVoice finalization<br/>+ ITN + punctuation]
302
- Tap[llm/stream tap<br/>observe-only]
303
- Seg[sentence segmenter]
304
- Q[TtsQueue<br/>epoch barge-in]
305
- TTS{Engine}
306
- Edge[Edge cloud]
307
- Vits[Local VITS WASM]
308
- Kokoro[Local Kokoro<br/>native addon]
309
- OpenAI[OpenAI-compatible TTS]
310
- MiMo[Xiaomi MiMo TTS]
311
- end
312
-
313
- UI -->|audio f32 PCM<br/>POST /voice-mode/asr| ASR
314
- ASR --> SV
315
- SV --> Draft[composer draft<br/>autoSend]
316
- Draft --> Tap
317
- Tap --> Seg
318
- Seg --> Q
319
- Q --> TTS
320
- TTS -->|edge| Edge
321
- TTS -->|vits| Vits
322
- TTS -->|kokoro| Kokoro
323
- TTS -->|openai| OpenAI
324
- TTS -->|mimo| MiMo
325
- Edge -.->|SSE audio frame| UI
326
- Vits -.->|SSE audio frame| UI
327
- Kokoro -.->|SSE audio frame| UI
328
- OpenAI -.->|SSE audio frame| UI
329
- MiMo -.->|SSE audio frame| UI
330
- VAD -.->|wake-word / barge-in| Q
331
- ```
213
+ ## Architecture & Host HTTP Routes
332
214
 
333
- - Speech and reading only happen for the session pointed to by the global single-active pointer `activeVoiceSession`; other sessions pass through `llm/stream` with zero overhead (mode isolation)
334
- - The `llm/stream` tap is lossless: every chunk passes through unchanged; segmentation/synthesis only observe and never block the model stream
335
- - ASR runs host-side (sherpa-onnx WASM, zipformer2 Chinese streaming + SenseVoice finalization which adds punctuation); the browser only captures audio (`getUserMedia` 16k mono) and does endpoint detection
336
- - Local TTS (VITS / lazily-loaded native Kokoro) runs in an isolated child process (fork, auto-restart); barge-in kills the in-flight synthesis to release its worker resources
337
- - The TTS queue is per-session with an epoch version: old frames are all invalidated after a barge-in, so it is truly silent
215
+ ![dsh-voice-mode architecture diagram](https://raw.githubusercontent.com/qishuilalala/dsh-voice-mode/HEAD/plugin/dsh-voice-mode/assets/architecture.svg)
338
216
 
339
- ---
217
+ - **Single-active session isolation**: only the session referenced by `activeVoiceSession` engages ASR/TTS; all other sessions pass through `llm/stream` with zero overhead.
218
+ - **Lossless stream tap**: observes final answer `text-delta` chunks without blocking chat rendering, skipping reasoning blocks, tool calls, and fenced code blocks.
219
+ - **Epoch invalidation**: every barge-in increments the per-session queue epoch and aborts in-flight synthesis so stale audio frames never play.
340
220
 
341
- ## 🔍 Historical comparison with the early upstream implementation
342
-
343
- | Dimension | Early upstream (historical) | dsh-voice-mode (this plugin) |
344
- | --- | --- | --- |
345
- | Recognition model | Cloud API (needs key) | **Local zipformer2 + SenseVoice** (zero key) |
346
- | Multi-language | English-first | **SenseVoice auto-recognition + ITN** |
347
- | TTS engine | Cloud TTS | **Edge cloud + local VITS/Kokoro + OpenAI-compatible / Xiaomi MiMo** |
348
- | Barge-in detection | Basic VAD | **3 sensitivity levels + echo gate + yield semantics** |
349
- | Caption a11y | None | **4 font tiers + 3 width tiers + theme-following** |
350
- | Wake word | None | **Lightweight streaming match + prefix filler whitelist** |
351
- | dsh compatibility | — | Declared range `>=0.1.1-rc.2 <0.3.0-0`; consult the tested-version matrix |
221
+ | Host HTTP Route | Description |
222
+ | --- | --- |
223
+ | `GET /voice-mode` | Health check returning `{ok, name, enabled, active}` |
224
+ | `GET /voice-mode/stream` | SSE stream for audio chunks, session mode sync, model download progress, and error codes |
225
+ | `POST /voice-mode/toggle` | Enter or exit voice mode (validates session existence and tab ownership) |
226
+ | `POST /voice-mode/asr` | Accepts `16kHz` mono `Float32` PCM deltas and returns streaming transcripts, finals, or VAD speech flags |
227
+ | `POST /voice-mode/cancel` | Invalidates the TTS queue and optionally cancels the running agent turn |
228
+ | `POST /voice-mode/preview` | Isolated one-shot voice synthesis preview |
229
+ | `POST /voice-mode/correct` | Pre-send LLM transcript correction (falls back to original text on failure/timeout) |
230
+ | `GET /voice-mode/config` | Client bootstrap configuration snapshot |
231
+ | `GET /voice-mode/voices` | Available voice catalog |
352
232
 
353
233
  ---
354
234
 
355
- ## 🔐 Permissions and data flow
356
-
357
- An honest disclosure of what the plugin does (mapped to the awesome-dsh-plugin capability scan: `network / fs-read / fs-write / shell / env`):
235
+ ## Permissions, Privacy & Security
358
236
 
359
- | Category | What it does | Where data goes |
237
+ | Capability | Plugin Behaviour | Data Destination |
360
238
  | --- | --- | --- |
361
- | **network** | (1) Default **Edge** TTS sends spoken reply text over WebSocket to Microsoft `speech.platform.bing.com`; (2) `ttsEngine: openai` sends spoken text to the selected preset or configured `openaiBaseUrl` / `openaiTts.baseUrl`; (3) `ttsEngine: mimo` sends spoken text to `mimoTts.baseUrl` (`https://api.xiaomimimo.com/v1` by default); (4) local VITS / Kokoro synthesize offline once models are downloaded from `huggingface.co` (or configured `hf-mirror.com`) with SHA256 digest checks; (5) registers loopback HTTP routes `/voice-mode/*` on the dsh host (loopback only by default; LAN needs `allowLan`) | Browser audio is sent only to the connected dsh host for local recognition (no third-party cloud ASR). Submitted transcripts and optional `llmCorrect` follow the host LLM configuration |
362
- | **fs-read / fs-write** | Model cache (Linux/macOS `~/.cache/dsh-voice-mode/models/`, Windows `%LOCALAPPDATA%\dsh-voice-mode\models\`); the dsh 0.1.7+ settings overlay `$DSH_HOME/voice-mode.settings.json` (`0600`, API keys remain host-only and are never returned to the browser); **never touches your workspace files** | All local |
363
- | **shell (child processes)** | Local TTS synthesis runs in a separate child process (`child_process.fork` → `lib/tts-vits-worker.cjs`); when the host is Electron (the official desktop app), it additionally probes and launches a real Node.js for Kokoro (`node -p …` to check the version). **It never executes user input and never builds shell command strings** | Local |
364
- | **env** | Uses directory/runtime environment settings such as `DSH_HOME`, `LOCALAPPDATA`, `PATH` and optional `DSHVM_NODE`; this default speech path does not require an extra speech-service API key | — |
365
-
366
- Also: the on-device recording fixture used for debugging is **off by default**; the plugin sends no telemetry. See [`SECURITY.md`](https://github.com/qishuilalala/dsh-voice-mode/blob/main/SECURITY.md) for the threat model and how to report vulnerabilities.
367
-
368
- ### Third-party models and services
369
-
370
- - **Local models are not shipped in the package**: the ASR (streaming zipformer, SenseVoice re-transcription), VAD and local TTS (VITS / Kokoro) models are **downloaded on first use from Hugging Face (or your configured mirror)** into a local cache; they come from export repositories in the [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx) ecosystem (`csukuangfj/*`). Each model is licensed by its **original authors** — this plugin's MIT license does **not** cover them; verify the upstream licenses before commercial use (the model list is under "Model & cache"; the constants are in `src/asr-host.ts` / `src/tts-local.ts`).
371
- - **The Edge cloud read-aloud is a third-party online service**: the default engine uses the Microsoft Edge browser "Read Aloud" endpoint via [`msedge-tts`](https://github.com/Migushthe2nd/MsEdgeTTS). It is not an officially supported Microsoft API — **availability, rate limits and terms are Microsoft's** and may change at any time. For stability/compliance-sensitive use, switch to local VITS / Kokoro (offline).
372
- - Licenses of the third-party code inlined into the published package (`msedge-tts` and its dependencies) are in [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md); `pnpm audit` checks known high+ advisories and does not establish the absence of undisclosed or untracked vulnerabilities (CI `audit` job keeps watching).
239
+ | **network** | `edge` sends spoken reply text to Microsoft's Read Aloud service; `openai` / `mimo` send spoken text to your selected preset or custom endpoint; local `vits` / `kokoro` synthesize completely offline after downloading SHA256-pinned models from Hugging Face (or your configured mirror); `/voice-mode/*` binds to host loopback by default | Microphone audio goes only to your connected DSH host for local ASR (no cloud ASR). Chat prompts follow your host LLM setup |
240
+ | **fs-read / fs-write** | Reads/writes the model cache (`~/.cache/dsh-voice-mode/models/` on macOS/Linux, `%LOCALAPPDATA%\dsh-voice-mode\models\` on Windows) and `$DSH_HOME/voice-mode.settings.json` (`0600`); **never accesses workspace files** | Local machine |
241
+ | **shell (child process)** | Runs local TTS in a dedicated `child_process.fork` worker; under Electron desktop, probes system Node.js for Kokoro; **never interpolates shell strings or user input** | Local machine |
242
+ | **env** | Reads path/runtime environment variables (`DSH_HOME`, `LOCALAPPDATA`, `PATH`, optional `DSHVM_NODE`) | Local machine |
373
243
 
374
- ### Compatibility declaration (what the plugin market's version filter reads)
375
-
376
- `package.json` declares `engines.dsh = ">=0.1.1-rc.2 <0.3.0-0"`. This is an eligibility range, not evidence that every version in it has passed tests. The compatibility record lists tested releases through 0.2.2-rc.5 and the forms actually exercised. The default set deduplicates the support endpoints, the latest verified release on each version line, and upstream latest/next: currently 9 versions for anchors and host/client typechecks, with 8 runtime cores. Historical evidence remains available; use `verify-dual.sh --full` or explicit versions to rerun it. Compatibility-only verification does not trigger a release. The daily workflow compares upstream tags and opens an issue for uncovered versions; it does not automatically rerun the full matrix. `peerDependencies` lists `@deepseek-ai/cordis` and `react` supplied by the host.
377
-
378
- ## 🚧 Known limitations
379
-
380
- - Barge-in relies on browser echo cancellation (`echoCancellation`); loud speaker volume may leak into the mic (a self-built NLMS canceller only kicks in as a fallback when native AEC is unavailable)
381
- - `Ctrl+Shift+V` overrides the browser's "paste as plain text" shortcut (normal `Ctrl+V` paste still works)
382
- - The recognition model prioritizes Simplified Chinese; recognition quality is affected by ambient noise
383
- - Browser autoplay policy: reading requires prior user interaction on the page (clicking the mic satisfies it); if the browser blocks playback and the status bar shows no hint, make sure the page is foregrounded and not muted
384
- - **The wake word is a lightweight implementation** (text matching on the streaming transcript, not a dedicated KWS engine): it may lag or misfire in noisy environments; the wake word itself never enters the chat (the buffer is dropped on hit)
385
- - In hold mode, switching windows/tabs while holding **abandons the segment** (prevents continuous recording); come back and hold again
386
- - The hero (new-session empty state) has no voice entry: voice mode is a session-level feature; enter a session first and use the mic button in the input toolbar
387
- - Entering/exiting voice mode, reading/writing settings and preview all rely on `AbortSignal.timeout` (Chrome 103+ / Firefox 100+ / Safari 16+); on older browsers these actions immediately show a failure hint — an expected degradation
388
- - **Cloud read-aloud (Edge) depends on a Microsoft online service**: the server side may change its handshake or limits at any time (it did on 2026-10-15 — see CHANGELOG 0.7.24). If several sentences in a row fail, the status bar/toast suggests switching to local VITS / Kokoro, which the settings panel does in one click
389
- - `spokenFormat` is injected through the official `system-prompt/assemble` waterfall; if the current session uses a **complete prompt** (persona `complete: true` agent preset) it is not injected (the official `complete` contract wins)
390
- - Local Kokoro needs about 1 s to rebuild its engine before the next sentence after a barge-in (the price of killing in-flight synthesis)
391
- - **Apple Safari / iOS**: needs **HTTPS or localhost** (a secure context is mandatory; the mic is unavailable on `http://` LAN IPs); grant the mic on first entry (iOS: Settings → Safari → Microphone if denied); recognition and read-aloud pause while backgrounded or locked and resume on return (sentences may be lost)
392
- - **Security note**: the plugin's HTTP surface (`/voice-mode/*`) follows the host's security model — do not expose the dsh port to the public internet; behind a reverse proxy, authenticate at the proxy (e.g. basic auth)
244
+ - In Voice Mode, select **Copy diagnostics** in the status bar above the chat input. To show the bar, use **Settings → Voice Mode → Display & interaction**. The snapshot includes a build hash, runtime state, selected settings, and any available stage timings. It contains no audio or transcript text. The plugin sends no telemetry.
245
+ - API keys are stored host-only (`0600`) and never returned to browsers; third-party notices for bundled code are listed in [THIRD_PARTY_NOTICES.md](https://github.com/qishuilalala/dsh-voice-mode/blob/main/plugin/dsh-voice-mode/THIRD_PARTY_NOTICES.md), and vulnerability reporting is documented in [SECURITY.md](https://github.com/qishuilalala/dsh-voice-mode/blob/main/SECURITY.md).
246
+ - Downloaded speech models from the [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx) ecosystem remain under their upstream model licenses (not covered by this package's MIT license).
393
247
 
394
248
  ---
395
249
 
396
- ## 🛠️ Troubleshooting
250
+ ## Troubleshooting
397
251
 
398
- | Symptom | Fix |
252
+ | Symptom | Resolution |
399
253
  | --- | --- |
400
- | Mic click does nothing, red hint in the status bar | The browser denied mic permission: allow it in the address bar and retry |
401
- | Status bar stuck on `Loading model… x%` | Check the network; the model is large (160 MB) — `npm run prefetch` first; on mainland networks set `modelHost` to `https://hf-mirror.com` |
402
- | Status bar shows `Model download failed (<file>)` | Both mirrors are unreachable: check network/proxy and re-enter voice mode (resumable) |
403
- | Local Kokoro on the official desktop app shows "failed" and asks for Node.js | The desktop host is Electron, where Kokoro's native add-on cannot run: install Node.js >= 18 on PATH (or set `DSHVM_NODE` to its path) and retry, or use the default Edge / local VITS (unaffected on desktop) |
404
- | No sound and no captions on the default (Edge cloud) engine | Edge read-aloud depends on a Microsoft online service. If several sentences fail in a row you will see "cloud read-aloud unavailable" — switch the engine to local VITS / Kokoro in settings. v0.7.23 and earlier are silent since 2026-10-15 (server-side handshake rejection) — upgrade to ≥0.7.24 |
405
- | Caption appears (overlay) but no sound | Check system volume/output; if autoplay is blocked, click anywhere on the page and retry |
406
- | Status bar shows `朗读连接失败:正在重试…` | Edge TTS unreachable (overseas service), auto-retries; if it persists, check network/proxy |
407
- | Poor recognition | Reduce background noise and compare partial/final text. `interruptLevel` controls barge-in, not recognition accuracy |
408
- | Hold mode has no effect | Make sure hold mode is active and you're in voice mode (button shows `按住说话`); the browser window must be in the foreground |
409
- | Preview button reports synthesis failure | Edge TTS unreachable (overseas) or the ShortName doesn't exist: verify the name (`node scripts/list-voices.mjs` lists all) and retry later |
410
- | Caption is hidden behind the input box | Default `captionMaxWidth=1` (70vw) + `captionFontSize=0` (12px) can overlap the bottom input on narrow viewports; raise the tier or click the caption's `×` to dismiss |
411
- | Yield behavior is wrong (saying `嗯` doesn't pause / real speech gets hard-barge) | Short backchannel words (`嗯 / 对`) auto-pause 1.5 s then reading resumes; continuing to speak triggers hard barge-in; disable `backchannelYield` to restore pre-change behavior (ADR-0008) |
412
- | Says `嗯` but no yield happens | Confirm `backchannelYield=true` (default on); in hold mode, continuing to talk within 1.5 s of release triggers hard barge-in |
413
- | Auto-exits after 5 minutes idle (don't want) | Raise `idleTimeoutMinutes` (default 5 min; reading, the AI speaking and a running turn all count as activity, and background tabs renew too; it still exits 2 hours after your last real action) |
414
- | Mic button spins forever | The host not answering times out after 8 s; click the mic again while it spins to cancel entering, leaving no voice session behind |
415
-
416
- ---
417
-
418
- ## 🛣️ Roadmap
419
-
420
- The [current roadmap](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/plan/roadmap-2026-10.md) defines priorities, candidate admission, acceptance gates and rollback conditions.
421
-
422
- 1. Close confirmed defects and validate one real ASR → editable draft → send → TTS workflow.
423
- 2. Address the highest-loss experience problems: dropped speech, unintended sends, edit conflicts and recovery.
424
- 3. Make model updates and fallback controlled; evaluate new models or protocols only against a measured bottleneck. A new backend is optional, not a delivery promise.
425
-
426
- Client-side VAD, WebSocket migration, voice cloning and broad tool integration are not approved near-term work. The [historical backlog](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/competitive/backlog.md) preserves earlier research; its old Ready labels and estimates are not current commitments.
254
+ | Clicking mic shows permission denied | Allow microphone access in the browser address bar (or iOS Settings → Safari → Microphone); non-loopback origins require `HTTPS` |
255
+ | Model download is slow or stalls | Downloads resume automatically via `.part` files; in mainland China set `modelHost` to `https://hf-mirror.com` in Settings → Advanced |
256
+ | Unsure how to trigger push-to-talk | From idle, **hold the mic button directly**; for keyboard push-to-talk, enter voice mode first and hold **`Ctrl` (bottom-left `⌃ Control` on macOS, not `⌘ Command`)** for ≥220 ms until the status bar shows recording |
257
+ | Default Edge TTS has no audio | Edge relies on Microsoft's online service; switch to offline local `vits` / `kokoro` or a configured online preset in Settings → Read-aloud (`0.7.23` and earlier are deprecated due to an upstream handshake change — upgrade to latest) |
258
+ | Desktop Kokoro asks for Node.js | Install Node.js `>=18` on system `PATH` (or set `DSHVM_NODE`) and restart the desktop app, or switch to `vits` / `edge` |
259
+ | Loudspeaker echo interrupts playback | Default `detect` switches to hold-to-interrupt when native AEC is absent; you can also set `bargeInMode` to `manual` or `interruptLevel` to `0` |
260
+ | Wake word does not trigger | Ensure interaction mode is `toggle` (`hold` disables wake word); after each utterance or barge-in the session returns to standby — check the live standby transcript in the status bar |
427
261
 
428
262
  ---
429
263
 
430
- ## 🛠️ Development
264
+ ## Development & License
431
265
 
432
- Use Node.js 22.18+ on the 22.x line and pnpm 11 for source development/tests; macOS builds require macOS 12+. The plugin runtime declaration is not the test-toolchain requirement.
433
-
434
- ### Dependency discipline (important)
435
-
436
- - **Runtime dependencies** (`dependencies`): `@deepseek-ai/schemastery`, `sherpa-onnx`, `sherpa-onnx-node` — external at runtime, resolved from the registry.
437
- - **`msedge-tts` is a build-time `devDependency`** and is inlined together with all of its transitive dependencies into `lib/msedge-tts.cjs` (ADR-0011): it ships a `preinstall: npx only-allow pnpm` that pnpm 11 rejects, and its `require("buffer/index")` breaks under dsh ≥0.1.7's resolver. Inlined packages are listed in `THIRD_PARTY_NOTICES.md`; the inlined `axios` is pinned `>=1.20.0` via `pnpm-workspace.yaml` overrides, and CI runs `pnpm audit`.
438
- - **Host framework packages** (`@deepseek-ai/cordis`, `react`) → `peerDependencies` (provided by the dsh runtime; putting them in `dependencies` would make dshmarket treat the plugin as shadowing host versions).
439
- - **Type-only references** (`@deepseek-ai/dsh-settings` / `dsh-host-webserver` / `dsh-llm` / `dsh-system-prompt`) are `devDependencies` used for type checking only; no runtime imports between instances.
440
-
441
- After changing dependencies run `npm pack --dry-run`, `npm test` and `bash scripts/verify-install.sh` (fresh install of the packed tarball with pnpm + npm).
442
-
443
- ### Build & test
266
+ Use Node.js 22.18+ on the 22.x line and pnpm 11 for local development. See the [contribution guide](https://github.com/qishuilalala/dsh-voice-mode/blob/main/CONTRIBUTING.md#本地开发) for the full workflow.
444
267
 
445
268
  ```sh
446
- pnpm install && pnpm build # esbuild: lib/index.js (host) + lib/client.js (browser) + lib/msedge-tts.cjs
447
- pnpm test # runs unit tests, harnesses, structure guards, and pre-release checks via scripts/run-tests.mjs
448
- bash scripts/smoke-runtime.sh <dsh-core-bin.js> <port> # boot an isolated dsh core: endpoints, mic button, settings page, i18n
449
- bash scripts/full-e2e.sh <dsh-core-bin.js> <port> # real-LLM end to end: create → toggle → prompt → SSE audio frames
450
- systemctl restart dsh # Linux; restart the dsh process on other platforms
269
+ cd plugin/dsh-voice-mode
270
+ pnpm install --frozen-lockfile
271
+ pnpm run check:lib-drift # check committed bundles before build overwrites lib
272
+ pnpm run build # builds lib/index.js, lib/index.d.ts, lib/client.js, and workers
273
+ pnpm run typecheck # dual host + browser TypeScript checks
274
+ pnpm test # unit tests, structure guards, and doc-consistency gates
451
275
  ```
452
276
 
453
- > Note: dsh installs the plugin as a pnpm `file:` link (directory copy); after `node build.mjs` you
454
- > must copy `lib/client.js` to `<profile>/node_modules/dsh-voice-mode/lib/` and restart dsh before
455
- > the browser picks up the new bundle.
456
-
457
- ### Structure
458
-
459
- ```
460
- src/index.ts host: single-active pointer, llm/stream tap, SSE, settings registration, spoken-style prompt injection
461
- src/asr-host.ts host: zipformer2 streaming ASR + SenseVoice finalization + lazy model download (.part resume)
462
- src/models.ts host: model download/verification (SHA256 pinning + host allowlist + path checks)
463
- src/security.ts host: rate limiter and guards
464
- src/tts-local.ts host: local TTS engines (VITS WASM / Kokoro native addon, child-process management)
465
- src/tts-runtime.ts host: picks a real Node for the Kokoro child under Electron hosts
466
- src/tts-queue.ts host: per-session TTS queue + epoch barge-in + consecutive-failure streak
467
- src/settings-store.ts, settings-http-scope.ts host: ≥0.1.7 settings self-persistence (ADR-0009)
468
- src/segmenter.ts host: sentence segmentation + text sanitizing
469
- src/asr.ts client: capture, VAD segmentation, incremental recognition, wake word, hold-to-talk gate
470
- src/client.tsx client: mic button + mode toggle + status bar + caption overlay + barge-in
471
- src/strings.ts, i18n.ts, error-text.ts client: zh/en dictionary + official locale service + stable error-code texts
472
- src/voice-catalog.ts, voice-labels.ts voice catalog (single source) + per-language labels
473
- src/errors.ts, prompts.ts stable error codes; LLM spoken-style prompts and preview sentences
474
- test/*.test.mjs unit tests, harnesses and structure guards (see `npm test`)
475
- scripts/ smoke-runtime.sh, full-e2e.sh, verify-install.sh, verify-dual.sh (version matrix), list-voices.mjs, prefetch.mjs
476
- ```
477
-
478
- Integration probes (`hold-e2e.js`, `spoken-prompt-rpc.sh`, `spoken-toggle-ui-check.js`) live in the repo root `test/`, outside this npm package.
479
-
480
- ---
481
-
482
- ## 📄 License
483
-
484
- [MIT](./LICENSE)
485
-
486
- > Portions derived from [haoku123/dsh-voice](https://github.com/haoku123/dsh-voice) (see [`LICENSE`](./LICENSE)).
277
+ Released under the [MIT License](https://github.com/qishuilalala/dsh-voice-mode/blob/main/plugin/dsh-voice-mode/LICENSE), with early foundations derived from [haoku123/dsh-voice](https://github.com/haoku123/dsh-voice) (MIT).