dsh-voice-mode 0.7.38 → 0.7.40

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
@@ -16,9 +16,9 @@ interrupts playback and the running turn. No additional speech-service API key i
16
16
 
17
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
18
 
19
- > **Current status (2026-11-13):** v0.7.37 stop-on-focus-switch, once-interrupt resume, no-split decimals, mic release on early stop. Check npm and Releases for availability.
19
+ > **Current status (2026-11-21):** v0.7.40 adds 7 online TTS presets with per-preset API keys, Xiaomi MiMo TTS, visual ASR replacement rules, a redesigned 4-tab settings panel, touch quick-settings menu, tab-switch draft finalization, and caption history. Check npm and Releases for availability.
20
20
 
21
- Host compatibility check: anchors, types and isolated runtime checks passed for dsh 0.2.2-rc.3 (including the client side). See the [compatibility record](../../docs/compat-contract.md) for evidence and unverified layers; this does not establish microphone or cross-platform acceptance.
21
+ Host compatibility check: anchors, types and isolated runtime checks passed for dsh 0.2.2-rc.5 (including the client side). See the [compatibility record](../../docs/compat-contract.md) for evidence and unverified layers; this does not establish microphone or cross-platform acceptance.
22
22
  >
23
23
  > CI results do not establish real-device audio quality or compatibility with every host version. See the [changelog](https://github.com/qishuilalala/dsh-voice-mode/blob/main/CHANGELOG.md), [compatibility evidence](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/compat-contract.md), and [roadmap](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/plan/roadmap-2026-10.md). The declared dsh range is `>=0.1.1-rc.2 <0.3.0-0`; untested versions are not guaranteed.
24
24
 
@@ -131,16 +131,16 @@ If a wake word is configured, you land in standby first (the status bar prompts
131
131
  - 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).
132
132
 
133
133
 
134
- ### Full 25-key settings table
134
+ ### Full 35-key settings table
135
135
 
136
136
  | Key | Default | Description |
137
137
  | --- | --- | --- |
138
- | `ttsEngine` | `edge` | Read-aloud engine: `edge` Microsoft cloud (default, fast) / `vits` local Chinese / `kokoro` local zh+en; **applies live** |
138
+ | `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** |
139
139
  | `kokoroModel` | `int8` | Kokoro precision: `int8` (default, 109 MB, CPU/low-bandwidth) / `fp32` (311 MB, better quality, GPU/large memory); same 103 voices; **applies live** |
140
140
  | `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 |
141
141
  | `rate` | `1.1` | Reading speed multiplier (0.5 slow ~ 2.0 fast), **applies live** (batch J 1.0→1.1) |
142
142
  | `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) |
143
- | `bargeInMode` | `detect` | Barge-in mode: `detect` auto-probes native echo cancellation (default; falls back to hold-to-talk when it is not in effect) / `auto` force interrupt as soon as you speak (headphones / quiet rooms) / `manual` hold-to-talk (recommended on loudspeakers). Batch 7O default, I10-exempt (ADR-0006) |
143
+ | `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). Batch 7O default, I10-exempt (ADR-0006) |
144
144
  | `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 |
145
145
  | `silenceMs` | `1500` | Silence pause in ms that marks the end of a complete sentence |
146
146
  | `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) |
@@ -150,14 +150,21 @@ If a wake word is configured, you land in standby first (the status bar prompts
150
150
  | `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 |
151
151
  | `showStatusBar` | `true` | Voice status bar above the composer; when off, status lives on the mic button (timer below it, notices beside it) |
152
152
  | `showCaptions` | `true` | Floating caption while reading aloud |
153
- | `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 |
153
+ | `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 |
154
154
  | `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** |
155
155
  | `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` |
156
- | `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; **toggle mode only**; not triggered while the agent is reading |
156
+ | `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 |
157
157
  | `spokenFormat` | `true` | Spoken-format system prompt: inject "short natural sentences, no Markdown decoration" into voice-mode replies only, **applies live** |
158
158
  | `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) |
159
159
  | `toolBeep` | `false` | Tool-call beep (off by default): when on, a short beep plays each time the agent calls a tool; off = silent |
160
160
  | `senseITN` | `true` | SenseVoice inverse text normalization (number / date / currency; on by default) |
161
+ | `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** |
162
+ | `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** |
163
+ | `openaiModel` | empty | Online TTS model override (same priority as `openaiBaseUrl`); **applies live** |
164
+ | `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** |
165
+ | `openaiApiKeys` | `{}` (none) | Per-preset keys (Q2: key follows the preset): `{presetId: key}` map in the settings card; whichever preset is selected uses its own key; empty entries fall back to the global key; **booleans only, never the plaintext**; **applies live** (refresh to use the new key) |
166
+ | `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** |
167
+ | `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** |
161
168
  | `captionFontSize` | `0` | Caption font tier 0=12px / 1=14px / 2=18px / 3=24px (default 0 is byte-equivalent to legacy) |
162
169
  | `captionMaxWidth` | `1` | Caption width tier 0=50vw / 1=70vw / 2=90vw |
163
170
  | `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 |
@@ -214,6 +221,44 @@ You can also edit the `voice-mode:` section of `~/.dsh/settings.yaml` directly (
214
221
  > (`enabled/cacheDir` remain bundle-config-only).
215
222
  > The plugin HTTP namespace is fixed to `/voice-mode` (matching the client bundle contract; not configurable).
216
223
 
224
+ ### OpenAI-compatible & Xiaomi MiMo TTS (`ttsEngine: openai` / `mimo`)
225
+
226
+ 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:
227
+
228
+ ```yaml
229
+ - id: voice-mode
230
+ name: dsh-voice-mode
231
+ config:
232
+ ttsEngine: openai
233
+ voice: vivian # voice name on the server; empty = openaiTts.voice
234
+ openaiTts:
235
+ baseUrl: http://gpu-box:8091/v1 # OpenRouter: https://openrouter.ai/api/v1, OpenAI: https://api.openai.com/v1
236
+ apiKey: '' # Bearer key, empty for servers without auth
237
+ model: Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice
238
+ voice: vivian
239
+ responseFormat: mp3 # mp3 | wav
240
+ timeoutMs: 8000 # per sentence; slower counts as unavailable
241
+ fallback: kokoro # none | vits | kokoro: local engine while the server is down or slow
242
+ fallbackVoice: zf_xiaobei # empty = that engine's default voice
243
+ instructions: '' # optional style text for models that accept it
244
+ ```
245
+
246
+ 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.
247
+
248
+ ### Fixing misheard words (`asrReplacements`)
249
+
250
+ 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.
251
+
252
+ ```yaml
253
+ - id: voice-mode
254
+ config:
255
+ asrReplacements:
256
+ - from: [ski男] # what the recognizer produced, one or more spellings
257
+ to: Sakina # what you want
258
+ ```
259
+
260
+ 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.
261
+
217
262
  ---
218
263
 
219
264
  ## 🌐 API
@@ -310,7 +355,7 @@ An honest disclosure of what the plugin does (mapped to the awesome-dsh-plugin c
310
355
 
311
356
  | Category | What it does | Where data goes |
312
357
  | --- | --- | --- |
313
- | **network** | (1) The default read-aloud engine **Edge** sends the **reply text to be spoken** over WebSocket to Microsoft `speech.platform.bing.com` (cloud synthesis — local VITS / Kokoro avoids this TTS request after its models are ready; host LLM traffic is separate); (2) downloads local models on first use from `huggingface.co` (or your configured mirror `hf-mirror.com`) with host restrictions and pinned digests for primary/listed files; auxiliary directories use manifest/presence checks; (3) registers loopback HTTP routes `/voice-mode/*` on the dsh host (loopback only by default; LAN needs `allowLan`) | Browser audio is sent to the configured dsh host for recognition; the plugin does not use an independent cloud ASR. Edge sends text to Microsoft. Submitted transcripts and optional LLM correction follow the host LLM configuration |
358
+ | **network** | (1) The default read-aloud engine **Edge** sends the **reply text to be spoken** over WebSocket to Microsoft `speech.platform.bing.com` (cloud synthesis — local VITS / Kokoro avoids this TTS request after its models are ready; host LLM traffic is separate); (2) downloads local models on first use from `huggingface.co` (or your configured mirror `hf-mirror.com`) with host restrictions and pinned digests for primary/listed files; auxiliary directories use manifest/presence checks; (3) with `ttsEngine: openai`, sends the text to be spoken to the configured `openaiTts.baseUrl` (and to nothing else); (4) registers loopback HTTP routes `/voice-mode/*` on the dsh host (loopback only by default; LAN needs `allowLan`) | Browser audio is sent to the configured dsh host for recognition; the plugin does not use an independent cloud ASR. Edge sends text to Microsoft. Submitted transcripts and optional LLM correction follow the host LLM configuration |
314
359
  | **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`; **never touches your workspace files** | All local |
315
360
  | **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 |
316
361
  | **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 | — |
@@ -325,7 +370,7 @@ Also: the on-device recording fixture used for debugging is **off by default**;
325
370
 
326
371
  ### Compatibility declaration (what the plugin market's version filter reads)
327
372
 
328
- `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.3 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.
373
+ `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.
329
374
 
330
375
  ## 🚧 Known limitations
331
376
 
package/README.md CHANGED
@@ -25,13 +25,13 @@ dsh ≥0.1.7 上按钮挂在发送键左侧(`conversation.input.activity`)
25
25
  - **说完就关**(`mode: once`):发出后关麦、转圈等回复,自然读完显示对勾并自动退出;长按麦克风或按 Ctrl 打断后恢复收音并留在语音模式
26
26
  - **检测到说话**:右上角橙点;**出错**:左上角红点(悬停看原因)
27
27
  - **点击**:平时进入/退出;不在语音模式但正在朗读(`readAloud: always`)时点一下 = 停止朗读;等待回复或朗读期间单击 = 停止朗读并完全退出。点按钮不会抢走输入框的光标
28
- - **右键菜单**(鼠标右键或键盘菜单键;触屏长按仍是按住说话):交互模式、朗读回复范围、字幕浮层、状态条、自动发送
28
+ - **右键菜单**(鼠标右键、键盘菜单键,或触屏旁侧 `⋯` 按钮 / 空闲非按住态长按):交互模式、朗读回复范围、字幕浮层、状态条、自动发送
29
29
  - 状态条与字幕默认开启;两项都关掉即上图的「全部收进按钮」形态,此时录音计时显示在按钮下方、提示文字显示在按钮旁
30
30
 
31
31
 
32
- > **当前状态(2026-11-13)**:v0.7.37 切会话停朗读、once 打断续说、小数点不拆句、启动窗口释放麦克风;可安装版本以 npm 徽章与 Releases 为准。
32
+ > **当前状态(2026-11-21)**:v0.7.40 新增 7 家在线 TTS 预设与逐预设密钥、小米 MiMo 朗读引擎、纠错词表可视化管理,并完成设置面板四分段重塑与触屏菜单、切页定稿、字幕回看等体验升级;可安装版本以 npm 徽章与 Releases 为准。
33
33
 
34
- 兼容跟进:最新 dsh 0.2.2-rc.3 的锚点、类型与隔离运行时复核通过(含客户端侧);完整证据和未验收层见[兼容契约](../../docs/compat-contract.md)。
34
+ 兼容跟进:最新 dsh 0.2.2-rc.5 的锚点、类型与隔离运行时复核通过(含客户端侧);完整证据和未验收层见[兼容契约](../../docs/compat-contract.md)。
35
35
  >
36
36
  > CI 通过不代表真实听感、所有硬件或所有宿主版本均已验证。详见 [CHANGELOG](https://github.com/qishuilalala/dsh-voice-mode/blob/main/CHANGELOG.md)、[兼容证据](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/compat-contract.md)和[后续路线图](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/plan/roadmap-2026-10.md)。包声明范围为 `>=0.1.1-rc.2 <0.3.0-0`,未测版本不保证。
37
37
 
@@ -121,28 +121,35 @@ dsh plugin --profile web add dsh-voice-mode
121
121
 
122
122
  | 键 | 默认 | 说明 |
123
123
  | --- | --- | --- |
124
- | `ttsEngine` | `edge` | 朗读引擎:`edge` 微软云端(默认,快)/ `vits` 本地中文 / `kokoro` 本地中英;**即时生效** |
124
+ | `ttsEngine` | `edge` | 朗读引擎:`edge` 微软云端(默认,快)/ `vits` 本地中文 / `kokoro` 本地中英 / `openai` 任意 OpenAI 兼容服务 / `mimo` 小米 MiMo(独立 `mimoTts.apiKey`);**即时生效** |
125
125
  | `kokoroModel` | `int8` | Kokoro 模型精度:`int8`(默认,109MB,纯 CPU/低带宽推荐)/ `fp32`(311MB,音质更好,独显/大内存推荐);两档共用 103 音色,**即时生效** |
126
126
  | `voice` | 按引擎 | 音色:VITS 五说话人;Kokoro 103 个(下拉+◀▶,62 深沉/68 浑厚/75 清亮/76 磁性置顶);Edge 进入时自动加载全量 322 个。行内「试听」可即时预览 |
127
127
  | `rate` | `1.1` | 朗读语速倍率(0.5 慢速 ~ 2.0 快速),**即时生效** |
128
128
  | `interruptLevel` | `0` | 发声打断灵敏度(服务端 VAD 帧级检测 + 回声门控):0 高门槛(3 帧)/ 1 中(2 帧)/ 2 低(1 帧) |
129
- | `bargeInMode` | `detect` | 打断方式:`detect` 自动探测本机原生回声消除状态(默认;未生效时切为长按打断)/ `auto` 强制开口即打断(耳机、安静环境推荐)/ `manual` 长按打断(外放推荐)。批 7O 默认,I10 豁免(ADR-0006) |
129
+ | `bargeInMode` | `detect` | 打断方式:`detect` 自动探测本机原生回声消除状态(默认;未生效时朗读期切为长按打断)/ `auto` 强制开口即打断(耳机、安静环境推荐)/ `manual` 手动打断(外放推荐:空闲时可直接说话或说唤醒词,AI 朗读中按住麦克风/Ctrl 打断)。批 7O 默认,I10 豁免(ADR-0006) |
130
130
  | `echoGateDb` | `6` | 无原生 AEC 时的回声门兜底阈值;原生 AEC 有效时不参与。仅在兜底路径中,增大更保守、减小更易触发;先确认设备与打断模式 |
131
131
  | `silenceMs` | `1500` | 说完整一句的静音停顿毫秒数 |
132
132
  | `idleTimeoutMinutes` | `5` | 无活动自动退出语音模式的分钟数(朗读计为活动) |
133
133
  | `modelHost` | 默认源 | 模型下载源(国内网络填 `https://hf-mirror.com`) |
134
134
  | `autoSend` | `true` | 静音到点自动发送(连续多段拼成一条消息);关闭则只进草稿(按住 `Ctrl` / hold 松手仍会发送) |
135
- | `autoResume` | `false` | 切回上次语音会话时自动恢复语音模式(默认关)。开启后:下次进入语音会话即自动进入语音模式 + 恢复上次会话;关闭则需手动按 `Ctrl+Shift+V` 重新进入 |
135
+ | `autoResume` | `false` | 切回上次语音会话时自动恢复语音模式(默认关)。开启后:下次进入语音会话即自动进入语音模式 + 恢复上次会话;关闭则需手动按 `Ctrl+Shift+V` 重新进入。关闭时切回上次语音会话,会在输入框旁用灰色字提示一次这件事(每个浏览器只提示一次) |
136
136
  | `mode` | `toggle` | 交互模式:`toggle` 持续聆听 + 1500ms 静音断句;`hold` 按住说话、松手发送(短按退出);`once` 说一段、回复自然读完自动退出;手动打断后恢复收音并留在语音模式 |
137
137
  | `readAloud` | `voice` | 朗读范围:`voice` 仅语音模式下的回复;`always` 当前可见会话的所有回复(含打字发送,切换会话即停止原朗读);`off` 从不朗读 |
138
138
  | `showStatusBar` | `true` | 输入框上方的语音状态条;关闭后状态只显示在麦克风按钮上(计时在按钮下方、提示在按钮旁) |
139
139
  | `showCaptions` | `true` | 朗读时的字幕浮层 |
140
140
  | `shortcut` | `Ctrl+Shift+V` | 进入 / 退出语音模式的快捷键(修饰键 Ctrl/Shift/Alt/Meta + 一个字母 / 数字 / Enter / Space / Tab);设置页「快捷键」分组里可点「录制」直接按组合键录入(`Esc` 取消、`Backspace` 清空,缺修饰键或方向键 / F 键等不支持的键会提示);**留空 = 禁用快捷键**,改用麦克风按钮;**即时生效** |
141
141
  | `composerShortcut` | `Alt+Enter` | 光标在输入框里时切换语音模式的快捷键(Mac 上即 Option+Enter),不插入换行;格式与录制方式同 `shortcut`;**留空 = 禁用**;设置卡片自己的输入框不拦截;`Cmd/Ctrl+Enter` 不占用;**即时生效**。「恢复默认」把两项快捷键恢复为 `Ctrl+Shift+V` 与 `Alt+Enter` |
142
- | `wakeWord` | 空(关) | 唤醒词(如「你好小D」):进入后先说唤醒词激活,避免误触;空 = 关闭。**可与命令连说**,词头自动剥掉不进消息;匹配带容错(编辑距离 ≤1 + 前 3 字符前导窗口,吸收同音字/语气词);**建议 3-4 字**——单字词无容错、2 字词的容错会连带吸收所有同首字的 2 字词(如「小莫」也会唤醒「小张」),介意误唤醒用 3 字以上;每句断句或打断后回待机需重说;**仅 toggle 模式生效**(hold / 手动打断下不生效);朗读期说唤醒词不触发 |
142
+ | `wakeWord` | 空(关) | 唤醒词(如「你好小D」):进入后先说唤醒词激活,避免误触;空 = 关闭。**可与命令连说**,词头自动剥掉不进消息;匹配带容错(编辑距离 ≤1 + 前 3 字符前导窗口,吸收同音字/语气词);**建议 3-4 字**——单字词无容错、2 字词的容错会连带吸收所有同首字的 2 字词(如「小莫」也会唤醒「小张」),介意误唤醒用 3 字以上;每句断句或打断后回待机需重说;**按住说话 hold 模式下不生效**(`manual` 手动打断与 `detect` 回落 `manual` 时空闲期照常生效);朗读期说唤醒词不触发 |
143
143
  | `toolBeep` | `false` | 工具调用提示音(默认关):开启后 AI 调用工具时「滴」一声;关闭则全程静默 |
144
144
  | `spokenFormat` | `true` | 语音会话注入口语化提示词:开启后**仅当前语音会话**的回复被注入「口语化短句、不用 Markdown 排版符号」提示词(朗读更顺),**即时生效** |
145
145
  | `senseITN` | `true` | SenseVoice 逆文本归一化(数字/日期/货币规范化;默认开) |
146
+ | `openaiPreset` | 空(手动) | 在线 TTS 预设:`siliconflow-cosyvoice2` / `siliconflow-fish` / `openrouter-openai` / `openai-official` / `selfhosted-kokoro` / `selfhosted-vllm`。选中后按预设的 baseUrl/model 走,**音色留空时回落预设音色**;key 用 `openaiTts.apiKey`,或按预设用 `openaiTts.apiKeys[预设 id]` 分别配(**推荐:多家服务商各配一把,切预设不必再手改**)。注意:`apiKeys` 属宿主配置文件,改完需重启宿主;;卡片可点「测试朗读」就地试合成;**即时生效** |
147
+ | `openaiBaseUrl` | 空(跟随预设/配置文件) | 在线 TTS 端点:**设置卡片里直接填**(无需改 profile YAML);优先级 设置 > 预设 > `openaiTts.baseUrl`;配合「自定义」可接任意 OpenAI 兼容平台;**即时生效** |
148
+ | `openaiModel` | 空 | 在线 TTS 模型名覆盖(同上优先级);预设没列出的平台选「自定义」后填这里 |
149
+ | `openaiApiKey` | 空(回落配置文件) | 在线 TTS 的 key:卡片里填,存宿主 0600 设置文件,**永不回传浏览器**;优先级 面板按预设key > 设置全局key > `openaiTts.apiKeys[预设id]` > `openaiTts.apiKey`;卡片「清除」显式清空;**即时生效** |
150
+ | `openaiApiKeys` | `{}`(全未配) | Q2 Key 跟预设走:面板按预设 id 存的 key 表;选中哪个预设用哪把,切预设不再 401;空条目回落全局 key;**只回布尔表、不回传明文**;**即时生效**(保存刷新即用新 key) |
151
+ | `mimoApiKey` | 空(回落配置文件) | 小米 MiMo 的 key(走 `api-key` 头):卡片里填,同样只存宿主、不回传;留空回落 `mimoTts.apiKey` |
152
+ | `asrReplacements` | `[]` | 纠错词表 `[{from:[听错写法],to:想要写法}]`(≤200 条 / ≤12KB UTF-8):转写后统一改写(中间结果+定稿);卡片显示「本次生效以来」命中次数;与 LLM 纠错串联;**即时生效** |
146
153
  | `senseVoice` | `true` | 定稿是否用 SenseVoice 重译(带标点 + 数字归一化,更准;默认开)。**关闭可省 ~228MB 模型**,只走流式识别(更快、精度下降) |
147
154
  | `captionFontSize` | `0` | 字幕字号档位 0=12px / 1=14px / 2=18px / 3=24px(默认 0 与现状字节等价) |
148
155
  | `captionMaxWidth` | `1` | 字幕宽度档位 0=50vw / 1=70vw / 2=90vw(视口 <686px 窄于 480px,≈686px 接近 480px,>686px 宽于 480px) |
@@ -201,6 +208,109 @@ dsh plugin --profile web add dsh-voice-mode
201
208
  > (`enabled` / `cacheDir` 则仅由 bundle 配置决定)。
202
209
  > 插件 HTTP 命名空间固定为 `/voice-mode`(与客户端打包契约一致,不可配置)。
203
210
 
211
+ ### OpenAI 兼容的 TTS 服务(`ttsEngine: openai`)
212
+
213
+ 任何实现了 OpenAI `POST /v1/audio/speech` 的服务都能用来朗读:自己 GPU 机器上的([vLLM-Omni](https://github.com/vllm-project/vllm-omni)、[Kokoro-FastAPI](https://github.com/remsky/Kokoro-FastAPI)、LocalAI 等),或者 OpenAI、[OpenRouter](https://openrouter.ai/docs/guides/overview/multimodal/tts) 这类托管 API。服务地址写在组合包 config 里(仅 host 侧,key 不会下发到浏览器),引擎和其他引擎一样在设置面板里选:
214
+
215
+ ```yaml
216
+ - id: voice-mode
217
+ name: dsh-voice-mode
218
+ config:
219
+ ttsEngine: openai
220
+ voice: vivian # 服务端的音色名;留空 = openaiTts.voice
221
+ openaiTts:
222
+ baseUrl: http://gpu-box:8091/v1 # OpenRouter: https://openrouter.ai/api/v1,OpenAI: https://api.openai.com/v1
223
+ apiKey: '' # Bearer key(未按预设配置时的兜底;服务无鉴权可留空)
224
+ apiKeys: # 可选:按预设 id 分别配 key,切预设不必再手改上面的 apiKey
225
+ siliconflow-cosyvoice2: '' # 硅基流动
226
+ openrouter-openai: '' # OpenRouter
227
+ openai-official: '' # OpenAI 官方
228
+ model: Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice
229
+ voice: vivian
230
+ responseFormat: mp3 # mp3 | wav
231
+ timeoutMs: 8000 # 单句超时,超过视为不可用
232
+ fallback: kokoro # none | vits | kokoro:服务挂了或太慢时用的本地引擎
233
+ fallbackVoice: zf_xiaobei # 留空 = 该引擎的默认音色
234
+ instructions: '' # 可选,支持风格说明的模型才用
235
+ ```
236
+
237
+ 每句一个请求(队列本来就在回复还在生成时逐句合成,句内流式不会让播放更早开始)。`rate` 不为 1 时作为 `speed` 发送。配置了 `fallback` 时,请求失败或超时的那句(以及之后 30 秒)改用本地引擎,然后再试服务,服务挂掉不会让每句都等一次超时。被朗读的文本会发到 `baseUrl`,请选你信得过的服务。
238
+
239
+ ## 在线 TTS 怎么配(2026-11-19 起)
240
+
241
+ 设置卡片 →「朗读引擎」选 `openai`(OpenAI 兼容)或 `mimo`(小米 MiMo):
242
+
243
+ 1. **有预设的平台**:在「在线预设」里选一家(硅基流动 CosyVoice2 / 硅基流动 Fish / OpenRouter / OpenAI 官方 / Groq PlayAI / 自建 Kokoro-FastAPI / 自建 vLLM-Omni),只在「API Key」里填 key 即可,地址与模型自动带出。
244
+ 2. **列表里没有的平台**:预设选「自定义(下方手填)」,然后填三个框——**接口地址(Base URL)**、**模型名**、**API Key**(音色用上面「朗读音色」那栏填)。
245
+ 3. **想改某个预设的地址/模型**:选预设后直接在 URL/模型框里填,覆盖预设值即可(留空 = 用预设值)。
246
+
247
+ 优先级:**设置卡片 > 内置预设 > profile 配置文件**。key 只存宿主(0600 设置文件),GET 设置接口永不回传;卡片上的「清除」用于显式清空。
248
+
249
+ 验证:填完点「测试朗读」,成功会直接出声并就地提示;失败按限流/禁用/引擎/网络/Key 分类给出下一步。
250
+
251
+ ### 小米 MiMo 语音合成(`ttsEngine: mimo`)
252
+
253
+ 小米 MiMo 的 TTS 走 **Chat Completions 形态**(`POST /v1/chat/completions`,音频以 base64 放在 `choices[0].message.audio.data`),不是 OpenAI 的 `/audio/speech`,所以有独立配置块。**与 OpenAI 兼容引擎各用各的 key**(`mimoTts.apiKey` 不借用 `openaiTts.apiKey`,避免把一家的凭据发给另一家):
254
+
255
+ ```yaml
256
+ - id: voice-mode
257
+ name: dsh-voice-mode
258
+ config:
259
+ ttsEngine: mimo
260
+ voice: 冰糖 # 预置音色:mimo_default / 冰糖 / 茉莉 / 苏打 / 白桦 / Mia / Chloe / Milo / Dean;留空 = mimoTts.voice
261
+ mimoTts:
262
+ apiKey: '' # 必填;走 api-key 头(不是 Bearer),key 只在宿主侧
263
+ baseUrl: https://api.xiaomimimo.com/v1
264
+ model: mimo-v2.5-tts # 现行仍是 v2.5 系列(V2.6 指的是 Pro/Flash 推理模型)
265
+ voice: mimo_default
266
+ instructions: '' # 可选:自然语言风格说明(如「温和一些」)
267
+ responseFormat: wav # wav | mp3
268
+ timeoutMs: 8000 # 单句超时(默认 8000ms)
269
+ fallback: kokoro # none | vits | kokoro:失败或超时后 30 秒内用本地引擎
270
+ fallbackVoice: zf_xiaobei
271
+ ```
272
+
273
+ MiMo **没有 `speed` 字段**:`rate` 不为 1 时会译成自然语言风格指令(「语速加快到约 1.2 倍」)随请求下发。失败/超时同样进入 30 秒冷却并回退本地,打断(barge-in)不记为失败。官方文档:<https://mimo.mi.com>。
274
+
275
+
276
+ **真实链路实测(2026-11-19,真 key)**:
277
+
278
+ - 鉴权头是 `api-key: sk-…`(官方 curl 示例口径,非 `Authorization: Bearer`);key 从控制台「API Keys」创建。
279
+ - 可用模型 `mimo-v2.5-tts`(V2.5-TTS 系列未随 V2.5-Pro 下线)。
280
+ - 返回为 base64,解码后是 **WAV:单声道 / 24kHz / 16bit**;实测约 30 字一句话得 5.8s 音频,合成耗时 2~5s。
281
+ - **请求 `audio.format: mp3` 时服务端仍返回 WAV**(200 OK)。引擎按响应字节嗅探容器格式(`sniffAudioMime`),不信配置值,避免把 WAV 当 MP3 解码而播不出声。
282
+ - 401 错误体是 JSON(`type: invalid_key`),错误消息经脱敏后才进日志。
283
+ - 预置音色实测可用:`mimo_default`(中国集群落「冰糖」)、`冰糖`、`苏打`、`茉莉`、`白桦`、`Mia`、`Chloe`、`Milo`、`Dean`。
284
+ ### 纠正听错的词(`asrReplacements`)
285
+ ### 宿主级端到端验证(2026-11-19,隔离 profile)
286
+
287
+ 在 `/tmp` 下新建独立 `DSH_HOME` + `mt` profile(`dsh plugin --profile mt add <本地插件目录>` 装成本地 link),patch 用 `!!js process.env.MIMO_API_KEY` 引用 `.env` 里的真 key,`--port 3098` 起独立实例(不碰 3018):
288
+
289
+ | 验证点 | 结果 |
290
+ |---|---|
291
+ | 组合配置 | `--dump-config` 显示 `id: voice-mode` 段被 patch 覆盖,条目 id 是 `voice-mode`(`dsh-voice-mode` 是 name) |
292
+ | 引擎选择 | `GET /voice-mode/config` → `ttsEngine: mimo`;`GET /voice-mode/models/status` → `tts: {engine: mimo, ready: true}` |
293
+ | 真实合成 | `POST /voice-mode/preview {voice: mimo_default}` → **HTTP 200 / content-type: audio/wav / 199,724 B / WAV 24kHz 单声道 16bit / 4.16s / RMS 3561(有声)** |
294
+ | MIME 修正生效 | `/config` 的 `audioMime: audio/wav`(嗅探结果,而非配置里的 wav 巧合) |
295
+ | 路由无泄漏 | `GET /voice-mode/presets` 只含 baseUrl/model/voice 三字段(ADR-0013 边界,线上实证) |
296
+
297
+ 验证后已 `kill` 实例并删除临时 `DSH_HOME` 与 `mimotest` profile,端口 3098/3099 已释放。
298
+
299
+ **仍未做(需人)**:把正在跑的 web profile(3018)从 npm 0.7.35 换成本地构建并重启服务——重启会断开当前页面连接,需你决定时机。
300
+
301
+
302
+ 识别器会把中文里夹的人名、英文词听错(例如「Sakina」听成「ski男」)。常规办法热词在这里用不上:sherpa-onnx 只有 transducer 模型支持热词,流式 zipformer 以汉字为单位、写不出英文词,出定稿的 SenseVoice 又没有热词入口。在有热词能力的模型能覆盖之前,替换表是权宜办法:识别之后改写文本,中间结果和定稿都改,所以字幕、草稿和唤醒词看到的都是改好的文本。
303
+
304
+ ```yaml
305
+ - id: voice-mode
306
+ config:
307
+ asrReplacements:
308
+ - from: [ski男] # 识别器给出的写法,可写多个
309
+ to: Sakina # 想要的写法
310
+ ```
311
+
312
+ 匹配不区分大小写,中英交界处的空白不影响(「ski 男」同样命中)。写法以英文字母或数字开头/结尾时只匹配整词,所以 `sina` 不会改到 `Sinatra`;汉字没有词界,中文写法按子串匹配。同一位置优先匹配更长的写法,替换结果不会再被匹配。只写确实听到过的错法:太短或太常见的写法也会改掉正常的词。替换表读自插件配置,配置重载后下一次识别请求起生效。
313
+
204
314
  ---
205
315
 
206
316
  ## 🌐 API
@@ -297,7 +407,7 @@ flowchart LR
297
407
 
298
408
  | 类别 | 具体行为 | 数据去向 |
299
409
  | --- | --- | --- |
300
- | **network** | Edge 将待朗读文本发往微软在线服务;本地模型从官方源或配置镜像下载,主要模型及清单内支持文件做摘要校验,辅助目录用清单/存在性检查;插件在宿主注册 `/voice-mode/*` 路由 | 浏览器音频发送到所连接的 dsh 宿主识别,不使用独立云 ASR;提交文本及可选 LLM 纠错遵循宿主配置。切换本地 TTS 不会让宿主 LLM 自动离线 |
410
+ | **network** | Edge 将待朗读文本发往微软在线服务;`ttsEngine: openai` 时将待朗读文本发往配置的 `openaiTts.baseUrl`(不发往别处);本地模型从官方源或配置镜像下载,主要模型及清单内支持文件做摘要校验,辅助目录用清单/存在性检查;插件在宿主注册 `/voice-mode/*` 路由 | 浏览器音频发送到所连接的 dsh 宿主识别,不使用独立云 ASR;提交文本及可选 LLM 纠错遵循宿主配置。切换本地 TTS 不会让宿主 LLM 自动离线 |
301
411
  | **fs-read / fs-write** | 模型缓存(Linux/macOS `~/.cache/dsh-voice-mode/models/`,Windows `%LOCALAPPDATA%\dsh-voice-mode\models\`);dsh 0.1.7+ 的设置覆盖层 `$DSH_HOME/voice-mode.settings.json`;**不读写你的工作区文件** | 全部在本机 |
302
412
  | **shell(子进程)** | 本地 TTS 合成跑在独立子进程(`child_process.fork` → `lib/tts-vits-worker.cjs`);宿主为 Electron(官方桌面端)时,为 Kokoro 额外探测并启动一个真正的 Node.js(`node -p …` 探测版本,见 ADR/兼容契约)。**不执行用户输入、不经 shell 拼接命令** | 本机 |
303
413
  | **env** | 使用目录和运行时定位相关环境设置,如 `DSH_HOME`、`LOCALAPPDATA`、`PATH` 和可选 `DSHVM_NODE`;默认语音路径无需额外语音服务密钥 | 宿主 LLM 的配置和费用另计 |
@@ -312,7 +422,7 @@ flowchart LR
312
422
 
313
423
  ### 兼容声明(插件市场的版本筛选依据)
314
424
 
315
- `package.json` 声明 `engines.dsh = ">=0.1.1-rc.2 <0.3.0-0"`。这是版本准入范围,不代表区间内每个版本都已实测。兼容记录列出了截至 0.2.2-rc.3 的已测版本及实际测试形态。默认验证集按“支持区间两端 + 每条小版本线最新已验证版 + latest/next”去重,当前为 9 版锚点/双类型检查、8 核心冒烟。历史实证保留,可用 `verify-dual.sh --full` 或显式版本复验;纯补验不发版。每日工作流比对上游标签并为未覆盖版本开 issue,不会自动跑完整矩阵。`peerDependencies` 声明宿主提供的 `@deepseek-ai/cordis` 与 `react`。
425
+ `package.json` 声明 `engines.dsh = ">=0.1.1-rc.2 <0.3.0-0"`。这是版本准入范围,不代表区间内每个版本都已实测。兼容记录列出了截至 0.2.2-rc.5 的已测版本及实际测试形态。默认验证集按“支持区间两端 + 每条小版本线最新已验证版 + latest/next”去重,当前为 9 版锚点/双类型检查、8 核心冒烟。历史实证保留,可用 `verify-dual.sh --full` 或显式版本复验;纯补验不发版。每日工作流比对上游标签并为未覆盖版本开 issue,不会自动跑完整矩阵。`peerDependencies` 声明宿主提供的 `@deepseek-ai/cordis` 与 `react`。
316
426
 
317
427
  ## 🚧 已知限制
318
428