dsh-voice-mode 0.7.22 → 0.7.24

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,9 +1,9 @@
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)
3
+ [![License: MIT](https://img.shields.io/github/license/qishuilalala/dsh-voice-mode?style=flat-square&color=blue)](./LICENSE)
4
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
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)
6
- [![Tests: 431 passing](https://img.shields.io/badge/tests-431%20%E2%9C%93-2ea043?style=flat-square)](../../docs/rules/STATE.md)
6
+ [![Tests: 440 passing](https://img.shields.io/badge/tests-440%20%E2%9C%93-2ea043?style=flat-square)](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/rules/STATE.md)
7
7
 
8
8
  Full-duplex voice conversation mode for DeepSeek Harness (dsh): speak, get a
9
9
  spoken answer. Streamed zipformer2 ASR → editable draft → auto send → the
@@ -16,7 +16,7 @@ interrupts playback and the running turn. No API key.
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
- > **Runtime changes (most recent batch: v0.7.17 – v0.7.19, 2026-10-02)**: (1) **Settings work on every dsh version** — fixed the settings page and persistence on dsh 0.1.7+ (dedicated Settings → Voice Mode page, writes survive restarts); (2) **i18n reworked** — the UI follows dsh's official language setting, Chinese/English are fully consistent and switch without a reload; (3) **fixed fresh-install failures with npm/pnpm and `failed to import` on dsh ≥0.1.7** (affects 0.7.17 and earlier — please upgrade to ≥0.7.18); (4) **local Kokoro fixed on the official Electron desktop host** — needs Node.js ≥18 on PATH (see the desktop note below). Earlier batches (v0.7.10: silent-audio fixes, etc.) and the full history are in [`CHANGELOG.md`](https://github.com/qishuilalala/dsh-voice-mode/blob/main/CHANGELOG.md).
19
+ > **Runtime changes (latest: v0.7.18 – v0.7.24)**: (1) **Settings work on every dsh version** — fixed the settings page and persistence on dsh 0.1.7+ (Settings → Voice Mode page, writes survive restarts); (2) **i18n rebuilt** — the UI follows dsh's official language setting, zh/en fully consistent, switching needs no refresh; (3) **fixed fresh npm/pnpm installs and the dsh ≥0.1.7 installed-form "failed to import"** (0.7.17 and earlier are affected — upgrade to ≥0.7.18); (4) **local Kokoro fixed under the official desktop (Electron) app** — needs Node.js ≥18 on PATH (or set `DSHVM_NODE`); (5) **v0.7.24: Edge cloud read-aloud restored** — since 2026-10-15 Microsoft's service rejects the old handshake (v0.7.23 and earlier are silent on the default Edge engine; local VITS / Kokoro are unaffected), so the inlined msedge-tts is bumped to 2.1.0; when read-aloud **fails several sentences in a row** the plugin now suggests switching to a local engine; plus host hardening (`/models/retry` is same-origin POST only, model-tree path checks, raw error strings no longer sent downstream). Compatible with dsh up to 0.2.1-alpha.3 (its Settings entry moved into the sidebar "More" menu; both of this plugin's entry points still work).
20
20
 
21
21
  ---
22
22
 
@@ -41,7 +41,7 @@ interrupts playback and the running turn. No API key.
41
41
  - `hold` push-to-talk: short tap to enter/exit, **hold the mic button to talk, release to send** (swipe up to cancel, `Esc`/blur abandons the segment; pauses do not split while held, up to 10 min); hold `Ctrl` to record-by-keyboard, release to send
42
42
  - **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 with `hold` / manual barge-in); **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)
43
43
  - **Caption tiers (batch 3)**: `captionFontSize` 4 levels (0=12px / 1=14px / 2=18px / 3=24px) + `captionMaxWidth` 3 levels (0=50vw / 1=70vw / 2=90vw); adapts to narrow viewports
44
- - **Yield semantics (batch 5 / ADR-0008)**: `backchannelYield` on by default (I10-exempt) — 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
44
+ - **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
45
45
  - **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
46
46
  - **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)
47
47
  - **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
@@ -78,7 +78,7 @@ dsh plugin --profile web add dsh-voice-mode
78
78
  npx -y @deepseek-ai/dsh plugin --profile web add dsh-voice-mode
79
79
 
80
80
  # Option 2: local tarball
81
- dsh plugin --profile web add ./dsh-voice-mode-0.1.0.tgz
81
+ dsh plugin --profile web add ./dsh-voice-mode-<version>.tgz
82
82
 
83
83
  # Option 3: from source
84
84
  git clone https://github.com/qishuilalala/dsh-voice-mode.git
@@ -120,26 +120,7 @@ If a wake word is configured, you land in standby first (the status bar prompts
120
120
  - 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).
121
121
 
122
122
 
123
- ### 4 new settings (11 batches of comprehensive fixes)
124
-
125
- | Key | Default | Description |
126
- | --- | --- | --- |
127
- | `senseITN` | `true` | Batch 2 P0: SenseVoice inverse text normalization (number / date / currency; on by default) |
128
- | `captionFontSize` | `0` | Batch 3 P0: caption font tier 0=12px / 1=14px / 2=18px / 3=24px (default 0 is byte-equivalent to legacy) |
129
- | `captionMaxWidth` | `1` | Batch 3 P0: caption width tier 0=50vw / 1=70vw / 2=90vw |
130
- | `backchannelYield` | `true` | Batch 5 P1: yield semantics (ADR-0008); saying `嗯 / 对` while reading auto-pauses for 1.5 s; genuine speech still triggers hard barge-in. I10-exempt (default-on is a product decision); off = behavior identical to pre-change |
131
-
132
- ### 5 defaults micro-adjusted (batch J)
133
-
134
- | Key | Old | New | Why |
135
- | --- | --- | --- | --- |
136
- | `rate` | 1.0 | **1.1** | Edge TTS defaults slightly slow; +10% improves perceived quality |
137
- | `idleTimeoutMinutes` | 10 | **5** | More responsive idle exit (reading still counts as activity) |
138
- | `interruptLevel` description | old wording | new wording | Make "3/2/1 frame confirmation" explicit |
139
-
140
- > Field names unchanged → 100% backward compatible with existing `~/.dsh/settings.yaml`.
141
-
142
- ### Full 19-key settings table
123
+ ### Full 23-key settings table
143
124
 
144
125
  | Key | Default | Description |
145
126
  | --- | --- | --- |
@@ -161,10 +142,10 @@ If a wake word is configured, you land in standby first (the status bar prompts
161
142
  | `spokenFormat` | `true` | Spoken-format system prompt: inject "short natural sentences, no Markdown decoration" into voice-mode replies only, **applies live** |
162
143
  | `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) |
163
144
  | `toolBeep` | `false` | Tool-call beep (off by default): when on, a short beep plays each time the agent calls a tool; off = silent |
164
- | `senseITN` | `true` | Batch 2 P0: SenseVoice inverse text normalization (number / date / currency; on by default) |
165
- | `captionFontSize` | `0` | Batch 3 P0: caption font tier 0=12px / 1=14px / 2=18px / 3=24px (default 0 is byte-equivalent to legacy) |
166
- | `captionMaxWidth` | `1` | Batch 3 P0: caption width tier 0=50vw / 1=70vw / 2=90vw |
167
- | `backchannelYield` | `true` | Batch 5 P1: yield semantics (ADR-0008); saying `嗯 / 对` while reading auto-pauses for 1.5 s; genuine speech still triggers hard barge-in. I10-exempt (default-on is a product decision); off = behavior identical to pre-change |
145
+ | `senseITN` | `true` | SenseVoice inverse text normalization (number / date / currency; on by default) |
146
+ | `captionFontSize` | `0` | Caption font tier 0=12px / 1=14px / 2=18px / 3=24px (default 0 is byte-equivalent to legacy) |
147
+ | `captionMaxWidth` | `1` | Caption width tier 0=50vw / 1=70vw / 2=90vw |
148
+ | `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
149
  | `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 |
169
150
 
170
151
  Effect timing: `voice`/`rate`/`ttsEngine`/`kokoroModel`/`spokenFormat` take effect **immediately** (TTS hot-swap); the rest apply on the next voice-mode entry. Defaults come from the plugin config (`base` layer) — they follow the config unless explicitly changed.
@@ -296,10 +277,9 @@ flowchart LR
296
277
  | Multi-language | English-first | **SenseVoice auto-recognition + ITN** |
297
278
  | TTS engine | Cloud TTS | **Edge cloud + local VITS/Kokoro** (three-way switch) |
298
279
  | Barge-in detection | Basic VAD | **3 sensitivity levels + echo gate + yield semantics** |
299
- | Hotword biasing | None | None (removed in v0.7.7; see version note) |
300
280
  | Caption a11y | None | **4 font tiers + 3 width tiers + theme-following** |
301
281
  | Wake word | None | **Lightweight streaming match + prefix filler whitelist** |
302
- | dsh compatibility | — | **full range since 0.1.1-rc.2 (incl. 0.1.7-rc.1)** |
282
+ | dsh compatibility | — | **full range since 0.1.1-rc.2 (incl. 0.2.1-alpha.3)** |
303
283
 
304
284
  ---
305
285
 
@@ -316,13 +296,19 @@ An honest disclosure of what the plugin does (mapped to the awesome-dsh-plugin c
316
296
 
317
297
  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.
318
298
 
299
+ ### Third-party models and services
300
+
301
+ - **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`).
302
+ - **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).
303
+ - 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` is clean at release time (CI `audit` job keeps watching).
304
+
319
305
  ### Compatibility declaration (what the plugin market's version filter reads)
320
306
 
321
- `package.json` declares `engines.dsh = ">=0.1.1-rc.2"` (the market uses it for "filter by host version"). Verified range: **0.1.1-rc.2 → 0.2.1-alpha.1** (including an Electron host equivalent to the official desktop app). The upper bound is open; a weekly CI check watches upstream releases and opens an issue for any uncovered version. `peerDependencies` only lists `@deepseek-ai/cordis` and `react` (provided by the host).
307
+ `package.json` declares `engines.dsh = ">=0.1.1-rc.2"` (the market uses it for "filter by host version"). Verified range: **0.1.1-rc.2 → 0.2.1-alpha.3** (including an Electron host equivalent to the official desktop app). The upper bound is open; a weekly CI check watches upstream releases and opens an issue for any uncovered version. `peerDependencies` only lists `@deepseek-ai/cordis` and `react` (provided by the host).
322
308
 
323
309
  ## 🚧 Known limitations
324
310
 
325
- - Barge-in relies on browser echo cancellation (`echoCancellation`); loud speaker volume may leak into the mic (no JS-level AEC)
311
+ - 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)
326
312
  - `Ctrl+Shift+V` overrides the browser's "paste as plain text" shortcut (normal `Ctrl+V` paste still works)
327
313
  - The recognition model prioritizes Simplified Chinese; recognition quality is affected by ambient noise
328
314
  - 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
@@ -330,6 +316,11 @@ Also: the on-device recording fixture used for debugging is **off by default**;
330
316
  - In hold mode, switching windows/tabs while holding **abandons the segment** (prevents continuous recording); come back and hold again
331
317
  - 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
332
318
  - The preview request timeout uses `AbortSignal.timeout` (Chrome 103+ / Firefox 100+ / Safari 16+); on older browsers clicking preview immediately shows a failure hint — an expected degradation
319
+ - **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
320
+ - `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)
321
+ - 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)
322
+ - **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)
323
+ - **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)
333
324
 
334
325
  ---
335
326
 
@@ -341,6 +332,7 @@ Also: the on-device recording fixture used for debugging is **off by default**;
341
332
  | 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` |
342
333
  | Status bar shows `Model download failed (<file>)` | Both mirrors are unreachable: check network/proxy and re-enter voice mode (resumable) |
343
334
  | 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) |
335
+ | 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 |
344
336
  | Caption appears (overlay) but no sound | Check system volume/output; if autoplay is blocked, click anywhere on the page and retry |
345
337
  | Status bar shows `朗读连接失败:正在重试…` | Edge TTS unreachable (overseas service), auto-retries; if it persists, check network/proxy |
346
338
  | Poor recognition | Get closer to the mic, reduce ambient noise; if echo remains, raise the interrupt sensitivity by one step |
@@ -355,7 +347,7 @@ Also: the on-device recording fixture used for debugging is **off by default**;
355
347
 
356
348
  ## 🛣️ Roadmap
357
349
 
358
- Full backlog (43 P0-P3 items) at [`docs/competitive/backlog.md`](../../docs/competitive/backlog.md).
350
+ Full backlog (43 P0-P3 items) at [`docs/competitive/backlog.md`](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/competitive/backlog.md).
359
351
 
360
352
  - ✅ **Done (v0.7.7)**: 11 batches of comprehensive fixes (caption tiers / yield semantics / model prewarm / defaults micro-adjust / dead-code cleanup / etc.)
361
353
  - 🚧 **P0 (near-term)**: ADR-0003 client-side VAD / ADR-0006 first-level probe wired to manual / F1 emotion DSL full roll-out
@@ -369,33 +361,20 @@ Full backlog (43 P0-P3 items) at [`docs/competitive/backlog.md`](../../docs/comp
369
361
 
370
362
  ### Dependency discipline (important)
371
363
 
372
- Three categories, each with its own home:
373
-
374
- - **Third-party runtime deps** (`msedge-tts` / `sherpa-onnx`) and **registry-resolvable framework packages**
375
- (`@deepseek-ai/schemastery`) → `dependencies`. schemastery is a public npm package and the
376
- dsh host platform does not shadow it internally, so installing it into a profile causes no
377
- version conflicts.
378
- - **Host framework packages** (`@deepseek-ai/cordis` / `@deepseek-ai/dsh-web` / `react`) →
379
- `peerDependencies`. Host packages are provided by the dsh runtime; putting them in
380
- dependencies makes dshmarket treat it as "shadowing host versions" and blocks marketplace
381
- upgrades. Peer versions must match the current dsh runtime
382
- (locally: cordis `^4.0.1`, dsh-web `^0.1.0-rc.6 || ^0.1.1-rc.0`, react `^18.2.0`),
383
- and be bumped when dsh is upgraded.
384
- - **Type-only references** (`@deepseek-ai/dsh-settings` / `dsh-host-webserver` / `dsh-llm`) →
385
- no runtime imports between instances (`import type` + esbuild stripping), no declaration needed;
386
- during development the types link via pnpm `file:` to the local dsh distribution's node_modules
387
- (the registry's rc.1 type snapshot lags behind the distribution; the distribution types are the
388
- runtime truth).
389
-
390
- `dependencies` must contain only true third-party runtime deps — never host-shared packages; after
391
- changing deps, run `npm pack --dry-run` and `pnpm test` as regression.
364
+ - **Runtime dependencies** (`dependencies`): `@deepseek-ai/schemastery`, `sherpa-onnx`, `sherpa-onnx-node` — external at runtime, resolved from the registry.
365
+ - **`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`.
366
+ - **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).
367
+ - **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.
368
+
369
+ 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).
392
370
 
393
371
  ### Build & test
394
372
 
395
373
  ```sh
396
- pnpm install && pnpm build # esbuild: lib/index.js (host) + lib/client.js (browser)
397
- pnpm test # segmenter/wakeword unit tests + pre-release self-check (no network)
398
- node test/hold-e2e.js # hold-mode acceptance (standalone browser, /asr route interception)
374
+ pnpm install && pnpm build # esbuild: lib/index.js (host) + lib/client.js (browser) + lib/msedge-tts.cjs
375
+ pnpm test # 34 test files chained: unit tests + harnesses (fake browser driving the real engine) + structure guards + pre-release self-check (no network)
376
+ bash scripts/smoke-runtime.sh <dsh-core-bin.js> <port> # boot an isolated dsh core: endpoints, mic button, settings page, i18n
377
+ bash scripts/full-e2e.sh <dsh-core-bin.js> <port> # real-LLM end to end: create → toggle → prompt → SSE audio frames
399
378
  systemctl restart dsh # Linux; restart the dsh process on other platforms
400
379
  ```
401
380
 
@@ -406,18 +385,22 @@ systemctl restart dsh # Linux; restart the dsh process on other platform
406
385
  ### Structure
407
386
 
408
387
  ```
409
- src/index.ts host: single-active pointer, llm/stream tap, SSE, settings registration
410
- src/asr-host.ts host: zipformer2 streaming ASR + lazy model download (.part resume)
411
- src/tts-queue.ts host: per-session TTS queue + epoch barge-in
412
- src/segmenter.ts host: sentence segmentation (markdown stripping + terminating punctuation)
413
- src/client.tsx client: mic button + status bar + reading overlay + barge-in
414
- src/asr.ts client: getUserMedia + RMS VAD + partial polling
415
- scripts/prefetch.mjs model pre-download (cross-platform cache dir + resume)
416
- test/segmenter.test.mjs sentence segmentation unit tests
417
- test/wakeword.test.mjs wake-word matching unit tests
418
- test/verify-client.mjs pre-release self-check (bundle manifest/exports/shape)
419
- test/hold-e2e.js hold-mode end-to-end acceptance (standalone browser)
420
- scripts/list-voices.mjs print all Edge TTS voices (source of the voice table)
388
+ src/index.ts host: single-active pointer, llm/stream tap, SSE, settings registration, spoken-style prompt injection
389
+ src/asr-host.ts host: zipformer2 streaming ASR + SenseVoice finalization + lazy model download (.part resume)
390
+ src/models.ts host: model download/verification (SHA256 pinning + host allowlist + path checks)
391
+ src/security.ts host: rate limiter and guards
392
+ src/tts-local.ts host: local TTS engines (VITS WASM / Kokoro native addon, child-process management)
393
+ src/tts-runtime.ts host: picks a real Node for the Kokoro child under Electron hosts
394
+ src/tts-queue.ts host: per-session TTS queue + epoch barge-in + consecutive-failure streak
395
+ src/settings-store.ts, settings-http-scope.ts host: ≥0.1.7 settings self-persistence (ADR-0009)
396
+ src/segmenter.ts host: sentence segmentation + text sanitizing
397
+ src/asr.ts client: capture, VAD segmentation, incremental recognition, wake word, hold-to-talk gate
398
+ src/client.tsx client: mic button + mode toggle + status bar + caption overlay + barge-in
399
+ src/strings.ts, i18n.ts, error-text.ts client: zh/en dictionary + official locale service + stable error-code texts
400
+ src/voice-catalog.ts, voice-labels.ts voice catalog (single source) + per-language labels
401
+ src/errors.ts, prompts.ts stable error codes; LLM spoken-style prompts and preview sentences
402
+ test/*.test.mjs unit tests, harnesses and structure guards (see `npm test`)
403
+ scripts/ smoke-runtime.sh, full-e2e.sh, verify-install.sh, verify-dual.sh (version matrix), list-voices.mjs, prefetch.mjs
421
404
  ```
422
405
 
423
406
  Integration probes (`hold-e2e.js`, `spoken-prompt-rpc.sh`, `spoken-toggle-ui-check.js`) live in the repo root `test/`, outside this npm package.
@@ -426,4 +409,4 @@ Integration probes (`hold-e2e.js`, `spoken-prompt-rpc.sh`, `spoken-toggle-ui-che
426
409
 
427
410
  ## 📄 License
428
411
 
429
- [MIT](../../LICENSE)
412
+ [MIT](./LICENSE)
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![License: MIT](https://img.shields.io/github/license/qishuilalala/dsh-voice-mode?style=flat-square&color=blue)](LICENSE)
4
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
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)
6
- [![Tests: 431 passing](https://img.shields.io/badge/tests-431%20%E2%9C%93-2ea043?style=flat-square)](../../docs/rules/STATE.md)
6
+ [![Tests: 440 passing](https://img.shields.io/badge/tests-440%20%E2%9C%93-2ea043?style=flat-square)](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/rules/STATE.md)
7
7
 
8
8
  DeepSeek Harness 语音双工对话模式:会话内一键进入 → 边说边出字的流式识别 → 停顿自动发送 → 最终答复按句流式朗读 + 实时字幕,开口即可打断(真 barge-in)。无需 API Key,识别模型在本地宿主端推理。
9
9
 
@@ -15,15 +15,13 @@ DeepSeek Harness 语音双工对话模式:会话内一键进入 → 边说边
15
15
 
16
16
  ![语音模式真实录制:流式转写 → 自动发送 → 按句朗读 + 实时字幕](https://raw.githubusercontent.com/qishuilalala/dsh-voice-mode/HEAD/plugin/dsh-voice-mode/assets/demo-voice-flow.gif)
17
17
 
18
- ![全双工对话闭环:声音 → 文字 → 声音](https://raw.githubusercontent.com/qishuilalala/dsh-voice-mode/HEAD/plugin/dsh-voice-mode/assets/duplex-banner.png)
19
-
20
- > **运行时变更(最近一批:v0.7.17 ~ v0.7.19,2026-10-02)**:① **设置面全版本打通**——dsh 0.1.7+ 上设置页与持久化修复(Settings → 语音模式 专属页、写入与重启保留);② **国际化重做**——界面语言跟随 dsh 官方语言设置,中/英文完整一致、切换无需刷新;③ **修复 npm/pnpm 全新安装失败与 dsh ≥0.1.7 已安装形态「failed to import」**(0.7.17 及更早版本受影响,请升级到 ≥0.7.18);④ **官方桌面端(Electron)下本地 Kokoro 修复**——需系统 PATH 上有 Node.js ≥18(见下文「桌面端提示」)。此前批次(v0.7.10:输出链路静默丢音根治等)与完整历史见 [`CHANGELOG.md`](https://github.com/qishuilalala/dsh-voice-mode/blob/main/CHANGELOG.md)。
18
+ > **运行时变更(最近:v0.7.18 ~ v0.7.24)**:① **设置面全版本打通**——dsh 0.1.7+ 上设置页与持久化修复(Settings → 语音模式 专属页、写入与重启保留);② **国际化重做**——界面语言跟随 dsh 官方语言设置,中/英文完整一致、切换无需刷新;③ **修复 npm/pnpm 全新安装失败与 dsh ≥0.1.7 已安装形态「failed to import」**(0.7.17 及更早版本受影响,请升级到 ≥0.7.18);④ **官方桌面端(Electron)下本地 Kokoro 修复**——需系统 PATH 上有 Node.js ≥18(或设 `DSHVM_NODE`);⑤ **v0.7.24:恢复 Edge 云端朗读**——微软服务端自 2026-10-15 起拒绝旧版握手(v0.7.23 及更早的默认 Edge 朗读无声,本地 VITS / Kokoro 不受影响),内联的 msedge-tts 升到 2.1.0;朗读**连续失败时**会提示切换本地引擎;另有 host 加固(`/models/retry` 仅同源 POST、模型树路径校验、错误原文不下行)。兼容 dsh 至 0.2.1-alpha.3(其设置入口移入侧栏「More」菜单,本插件两处入口仍有效)。
21
19
 
22
20
  ---
23
21
 
24
22
  ## 🤝 Fork 增强(本仓库新增)
25
23
 
26
- 本仓库在上游 [haoku123/dsh-voice](https://github.com/haoku123/dsh-voice) 基础上加入了大量增强,核心如下(完整清单见 git 历史与 [docs/rules/STATE.md](../../docs/rules/STATE.md)):
24
+ 本仓库在上游 [haoku123/dsh-voice](https://github.com/haoku123/dsh-voice) 基础上加入了大量增强,核心如下(完整清单见 git 历史与 [docs/rules/STATE.md](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/rules/STATE.md)):
27
25
 
28
26
  - **朗读默认 Edge 云端;本地 TTS 可选(隐私优先)**:选本地则回复文本不出本机——
29
27
  - 本地 VITS(`sherpa-onnx-vits-zh-ll`,纯中文,5 说话人);
@@ -47,15 +45,15 @@ DeepSeek Harness 语音双工对话模式:会话内一键进入 → 边说边
47
45
  - `toggle`(默认)持续聆听:RMS VAD 分段 → zipformer2 流式识别(边说边出字,实时字幕预览)→ 静音约 1500 毫秒断句进草稿,连续多段拼成一条消息,再静音约 1500 毫秒(合计约 3 秒)自动发送;按住 `Ctrl` 强制立即发送
48
46
  - `hold` 按住说话:短按进入/退出,**按住麦克风按钮说话、松手即发**(滑出取消、`Esc`/失焦放弃本段);按住期间停顿不断句(上限 10 分钟);`Ctrl` 按住即录、松开即发
49
47
  - **唤醒词(可选,默认关)**:设置 `wakeWord` 后进入待机态,说出唤醒词才开始识别(如「你好小D」)。**可直接与命令连说**(「你好小D,帮我查天气」)——唤醒词会在定稿/字幕里自动剥掉、不进消息;匹配带容错(同音字替换「小莫→小墨」、首字错、前置语气词「呃/喂/我说」),建议 3-4 字;待机态状态条实时显示「说『x』开始 · 它听到的转写」,唤醒成败可自查。边界(重要):**仅 `toggle` 模式生效**(`hold` / 手动打断下唤醒词静默失效);**说完整一句后回到待机态需重说唤醒词**(只喊唤醒词、还没说命令时保持聆听,可停顿想好再说);**朗读期说唤醒词不触发**(打断由 VAD 开口即触发,与唤醒词无关)
50
- - **字幕档位**(批 3):`captionFontSize` 4 档(0=12px / 1=14px / 2=18px / 3=24px)+ `captionMaxWidth` 3 档(0=50vw / 1=70vw / 2=90vw),窄屏自适应
51
- - **让位语义**(批 5 / ADR-0008):`backchannelYield` 默认开(I10 豁免)—— 朗读期用户插话「嗯/对」自动让位 1.5s,真要说走硬打断;让 LLM 主动让出话轮(人格层让位);关掉恢复改造前行为
48
+ - **字幕档位**:`captionFontSize` 4 档(0=12px / 1=14px / 2=18px / 3=24px)+ `captionMaxWidth` 3 档(0=50vw / 1=70vw / 2=90vw),窄屏自适应
49
+ - **让位语义**(ADR-0008):`backchannelYield` 默认开—— 朗读期用户插话「嗯/对」自动让位 1.5s,真要说走硬打断;让 LLM 主动让出话轮(人格层让位);关掉恢复改造前行为
52
50
  - **输出链路**:只朗读最终答复的 `text-delta`(reasoning/工具调用不读),按句流式朗读(默认 Edge 云端;可切本地 VITS/Kokoro,中英混读选 Kokoro)+ 右下角实时字幕浮层;工具调用触发提示音;全文照常写入聊天记录;口语化提示词(设置 `spokenFormat`,默认开)让回复为自然短句、不带 Markdown 排版符号
53
51
  - **开口打断(barge-in)**:服务端 Silero VAD 帧级检测 + 回声门控(echoGateDb)三档灵敏度 → 本地静音 + host 合成队列作废 + 正在运行的回合取消(保留半截并自然续入新消息);朗读中自动切超灵敏档。开启唤醒词后打断**仍是开口即打断**(打断门控是 VAD,不是唤醒词;打断后回待机态)
54
52
  - **模型懒加载与进度**:首次使用自动下载识别/合成模型(`.part` 断点续传),状态条实时显示进度;可用 `npm run prefetch` 预下载
55
53
  - **设置**:入口随 dsh 版本而不同(见下方「设置」),可调朗读引擎/音色/语速/打断灵敏度/静音停顿/空闲超时/模型镜像/自动发送/交互模式/唤醒词/口语化提示词/字幕档位/让位语义;**音色可试听**(按当前音色+语速即时合成预览,自定义 ShortName 亦可)
56
54
  - **界面语言**:跟随 dsh 的语言设置(设置 → 通用 → 语言),**切换即时生效、无需刷新**——设置页、语音状态条、字幕、音色名称/性别/口音、错误提示全部随之变化;LLM 口语化提示词也按界面语言选中/英文版。插件词典注册在 dsh 官方 locale 服务的 `voice-mode` 命名空间,社区语言包可据此补充其它语言,缺失的语言回落英文。插件名称与描述在「插件」页同样按语言显示。
57
55
  - **容错**:麦克风被拒红点提示、模型下载失败可见提示、TTS 连接失败状态条提示(自动退避重试)、提交失败文字留在草稿、SSE 断线自动重连
58
- - **空闲退出**:5 分钟无活动自动退出并释放麦克风(**正在朗读计为活动**,长朗读不会中途下线;批 J 已微调默认 10→5)
56
+ - **空闲退出**:5 分钟无活动自动退出并释放麦克风(**正在朗读计为活动**,长朗读不会中途下线)
59
57
 
60
58
  ---
61
59
 
@@ -104,12 +102,12 @@ bundle 插件安装后需重启 dsh 生效(Linux:`systemctl restart dsh`;
104
102
  | `ttsEngine` | `edge` | 朗读引擎:`edge` 微软云端(默认,快)/ `vits` 本地中文 / `kokoro` 本地中英;**即时生效** |
105
103
  | `kokoroModel` | `int8` | Kokoro 模型精度:`int8`(默认,109MB,纯 CPU/低带宽推荐)/ `fp32`(311MB,音质更好,独显/大内存推荐);两档共用 103 音色,**即时生效** |
106
104
  | `voice` | 按引擎 | 音色:VITS 五说话人;Kokoro 103 个(下拉+◀▶,62 深沉/68 浑厚/75 清亮/76 磁性置顶);Edge 进入时自动加载全量 322 个。行内「试听」可即时预览 |
107
- | `rate` | `1.1` | 朗读语速倍率(0.5 慢速 ~ 2.0 快速),**即时生效**(批 J 1.0→1.1) |
105
+ | `rate` | `1.1` | 朗读语速倍率(0.5 慢速 ~ 2.0 快速),**即时生效** |
108
106
  | `interruptLevel` | `0` | 发声打断灵敏度(服务端 VAD 帧级检测 + 回声门控):0 高门槛(3 帧)/ 1 中(2 帧)/ 2 低(1 帧) |
109
107
  | `bargeInMode` | `detect` | 打断方式:`detect` 自动探测本机原生回声消除状态(默认;未生效时切为长按打断)/ `auto` 强制开口即打断(耳机、安静环境推荐)/ `manual` 长按打断(外放推荐)。批 7O 默认,I10 豁免(ADR-0006) |
110
108
  | `echoGateDb` | `6` | 回声门控阈值(dB):自动打断要求残差高于回声地板此值。**原生 AEC 生效时此门控闲置**(Safari / 耳机等无原生 AEC 环境才兜底生效);打不断降 3-4,噪音误打断升 8-10。**不要为「打不断」调它**(详见 ADR-0006) |
111
109
  | `silenceMs` | `1500` | 说完整一句的静音停顿毫秒数 |
112
- | `idleTimeoutMinutes` | `5` | 无活动自动退出语音模式的分钟数(朗读计为活动;批 J 10→5) |
110
+ | `idleTimeoutMinutes` | `5` | 无活动自动退出语音模式的分钟数(朗读计为活动) |
113
111
  | `modelHost` | 默认源 | 模型下载源(国内网络填 `https://hf-mirror.com`) |
114
112
  | `autoSend` | `true` | 静音到点自动发送(连续多段拼成一条消息);关闭则只进草稿(按住 `Ctrl` / hold 松手仍会发送) |
115
113
  | `autoResume` | `false` | 切回上次语音会话时自动恢复语音模式(默认关)。开启后:下次进入语音会话即自动进入语音模式 + 恢复上次会话;关闭则需手动按 `Ctrl+Shift+V` 重新进入 |
@@ -118,11 +116,11 @@ bundle 插件安装后需重启 dsh 生效(Linux:`systemctl restart dsh`;
118
116
  | `wakeWord` | 空(关) | 唤醒词(如「你好小D」):进入后先说唤醒词激活,避免误触;空 = 关闭。**可与命令连说**,词头自动剥掉不进消息;匹配带容错(编辑距离 ≤1 + 前 3 字符前导窗口,吸收同音字/语气词);**建议 3-4 字**——单字词无容错、2 字词的容错会连带吸收所有同首字的 2 字词(如「小莫」也会唤醒「小张」),介意误唤醒用 3 字以上;每句断句或打断后回待机需重说;**仅 toggle 模式生效**(hold / 手动打断下不生效);朗读期说唤醒词不触发 |
119
117
  | `toolBeep` | `false` | 工具调用提示音(默认关):开启后 AI 调用工具时「滴」一声;关闭则全程静默 |
120
118
  | `spokenFormat` | `true` | 语音会话注入口语化提示词:开启后**仅当前语音会话**的回复被注入「口语化短句、不用 Markdown 排版符号」提示词(朗读更顺),**即时生效** |
121
- | `senseITN` | `true` | 批 2 P0:SenseVoice 逆文本归一化(数字/日期/货币规范化;默认开) |
119
+ | `senseITN` | `true` | SenseVoice 逆文本归一化(数字/日期/货币规范化;默认开) |
122
120
  | `senseVoice` | `true` | 定稿是否用 SenseVoice 重译(带标点 + 数字归一化,更准;默认开)。**关闭可省 ~228MB 模型**,只走流式识别(更快、精度下降) |
123
- | `captionFontSize` | `0` | 批 3 P0:字幕字号档位 0=12px / 1=14px / 2=18px / 3=24px(默认 0 与现状字节等价) |
124
- | `captionMaxWidth` | `1` | 批 3 P0:字幕宽度档位 0=50vw / 1=70vw / 2=90vw(视口 <686px 接近 480px,>686px 宽于 480px) |
125
- | `backchannelYield` | `true` | 批 5 P1:让位语义(ADR-0008);朗读期说「嗯/对」自动让位 1.5s + 真要说走硬打断。I10 豁免(默认开是产品决策);关 = 行为等同改造前 |
121
+ | `captionFontSize` | `0` | 字幕字号档位 0=12px / 1=14px / 2=18px / 3=24px(默认 0 与现状字节等价) |
122
+ | `captionMaxWidth` | `1` | 字幕宽度档位 0=50vw / 1=70vw / 2=90vw(视口 <686px 接近 480px,>686px 宽于 480px) |
123
+ | `backchannelYield` | `true` | 让位语义(ADR-0008);朗读期说「嗯/对」自动让位 1.5s + 真要说走硬打断;关 = 行为等同改造前 |
126
124
  | `yieldMs` | `1500` | 让位窗口时长(ms,500-3000):`backchannelYield` 命中后 TTS 丢帧持续时长;窗口内用户真要说则由原 `hardBreak` 接管,窗口到点自动恢复播放 |
127
125
 
128
126
  生效范围:`voice`/`rate`/`ttsEngine`/`kokoroModel`/`spokenFormat` **立即生效**;其余设置下次进入语音模式时生效。设置项默认值由插件配置(`base` 层)提供。
@@ -163,10 +161,10 @@ bundle 插件安装后需重启 dsh 生效(Linux:`systemctl restart dsh`;
163
161
  cacheDir: ~/.cache/dsh-voice-mode/models # 可覆盖;否则用平台默认
164
162
  # 以下为设置项播种的默认值(设置面板优先级更高,面板是权威源):
165
163
  voice: zh-CN-XiaoxiaoNeural
166
- rate: 1.1 # 批 J 1.0→1.1
164
+ rate: 1.1
167
165
  interruptLevel: 0
168
166
  silenceMs: 1500
169
- idleTimeoutMinutes: 5 # 批 J 10→5
167
+ idleTimeoutMinutes: 5
170
168
  modelHost: https://huggingface.co
171
169
  ```
172
170
 
@@ -243,7 +241,7 @@ flowchart LR
243
241
  - 朗读默认 **Edge 云端**;本地 VITS 纯中文 / Kokoro 原生中英(跑在独立子进程、崩溃自愈)可选(隐私优先);
244
242
  - 同一时间仅一个会话处于语音模式(全局单活);LLM 流被无损观察(不阻塞)。
245
243
 
246
- 详细架构决策:见 [`docs/adr/`](../../docs/adr/README.md) 8 个 ADR。
244
+ 详细架构决策:见 [`docs/adr/`](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/adr/README.md) 11 个 ADR。
247
245
 
248
246
  ---
249
247
 
@@ -255,10 +253,9 @@ flowchart LR
255
253
  | 多语种 | 英文为主 | **SenseVoice 自动识别(zh/en/ja/ko/yue)+ ITN** |
256
254
  | 朗读引擎 | 云端 TTS | **Edge 云端 + 本地 VITS/Kokoro** 三选一 |
257
255
  | 打断检测 | 基础 VAD | **三档灵敏度 + 回声门控 + 让位语义** |
258
- | 热词偏置 | 无 | 无(已移除,详见 v0.7.7 文档说明) |
259
256
  | 字幕 a11y | 无 | **4 档字号 + 3 档宽度 + 主题跟随** |
260
257
  | 唤醒词 | 无 | **轻量流式匹配 + 前缀语气词白名单** |
261
- | 兼容 dsh | — | **0.1.1-rc.2 起全版本(含 0.2.1-alpha.1)** |
258
+ | 兼容 dsh | — | **0.1.1-rc.2 起全版本(含 0.2.1-alpha.3)** |
262
259
 
263
260
  ---
264
261
 
@@ -275,12 +272,19 @@ flowchart LR
275
272
 
276
273
  补充:调试用的真机录制(fixture)默认**关闭**;插件不上传遥测。完整威胁模型与漏洞报告方式见仓库根目录 [`SECURITY.md`](https://github.com/qishuilalala/dsh-voice-mode/blob/main/SECURITY.md)。
277
274
 
275
+ ### 第三方模型与服务说明
276
+
277
+ - **本地模型不随包分发**:ASR(zipformer 流式、SenseVoice 重译)、VAD、本地 TTS(VITS / Kokoro)的模型由插件**首次使用时从 Hugging Face(或你配置的镜像)下载**到本机缓存,来源为 [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx) 生态的导出仓库(`csukuangfj/*`)。各模型的许可由其**原作者**决定,本插件的 MIT 许可**不覆盖**这些模型;用于商业场景前请自行核对上游许可(模型清单见下文「模型与缓存」,对应常量在 `src/asr-host.ts` / `src/tts-local.ts`)。
278
+ - **Edge 云端朗读是第三方在线服务**:默认引擎经 [`msedge-tts`](https://github.com/Migushthe2nd/MsEdgeTTS) 使用微软 Edge 浏览器「大声朗读」的在线接口——这不是微软官方提供的稳定 API,**可用性、速率与条款均由微软决定**,可能随时变化。对稳定性/合规有要求的场景请改用本地 VITS / Kokoro(离线)。
279
+ - 被内联进发布包的第三方代码(`msedge-tts` 及其依赖)的许可见 [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md);已用 `pnpm audit` 保证发布时无已知高危漏洞(CI `audit` job 持续监测)。
280
+
278
281
  ### 兼容声明(插件市场的版本筛选依据)
279
282
 
280
- `package.json` 声明 `engines.dsh = ">=0.1.1-rc.2"`(插件市场据此在「按宿主版本筛选」时判定兼容)。已实测范围 **0.1.1-rc.2 → 0.2.1-alpha.1**(含官方桌面端等价的 Electron 宿主);上限开放,由每周 CI 巡检上游新版本并复验,出现未覆盖版本会自动开 issue。`peerDependencies` 仅声明 `@deepseek-ai/cordis` 与 `react`(宿主提供)。
283
+ `package.json` 声明 `engines.dsh = ">=0.1.1-rc.2"`(插件市场据此在「按宿主版本筛选」时判定兼容)。已实测范围 **0.1.1-rc.2 → 0.2.1-alpha.3**(含官方桌面端等价的 Electron 宿主);上限开放,由每周 CI 巡检上游新版本并复验,出现未覆盖版本会自动开 issue。`peerDependencies` 仅声明 `@deepseek-ai/cordis` 与 `react`(宿主提供)。
281
284
 
282
285
  ## 🚧 已知限制
283
286
 
287
+ - **云端朗读(Edge)依赖微软在线服务**:服务端可能随时调整握手/限流(2026-10-15 即发生过,见 CHANGELOG 0.7.24);若连续多句朗读失败,状态条/弹出提示会建议切换本地 VITS / Kokoro,设置面板可一键切换
284
288
  - 发声打断依赖浏览器回声消除(`echoCancellation`);扬声器音量过大时可能漏声到麦克风
285
289
  - `Ctrl+Shift+V` 会覆盖浏览器「粘贴纯文本」快捷键(普通粘贴仍可用 `Ctrl+V`)
286
290
  - 识别质量受环境噪声影响;zipformer2 中文流式 + SenseVoice 多语(中英日韩粤)定稿
@@ -304,7 +308,7 @@ flowchart LR
304
308
  | --- | --- |
305
309
  | 点麦克风无反应,状态条红字 | 浏览器拒绝麦克风:地址栏(iOS 为 设置 → Safari → 麦克风)开启后重试 |
306
310
  | 状态条「正在加载模型… x%」卡住 | 检查网络;模型较大可先 `npm run prefetch`;国内网络 `modelHost` 配 `https://hf-mirror.com` |
307
- | 朗读无声音/无字幕 | 本地引擎首次合成需加载模型;若持续失败查看状态条提示(自动退避重试);确认页面前台且未静音 |
311
+ | 朗读无声音/无字幕 | **默认 Edge 云端朗读依赖微软在线服务**:连续多句失败会提示「云端朗读暂不可用」,到设置把朗读引擎切到本地 VITS / Kokoro;v0.7.23 及更早版本在 2026-10-15 起整体无声,请升级到 ≥0.7.24。 本地引擎首次合成需加载模型;若持续失败查看状态条提示(自动退避重试);确认页面前台且未静音 |
308
312
  | AI 回复**偶尔不朗读**(某句没声/整条没声) | 已定位三类原因并修(v0.7.10):① 云端 TTS 偶发超时——单句自动重试 3 次,仍失败会**跳过该句并在状态条提示**「有一句朗读失败,已跳过」(此前是静默丢句);② 浏览器挂起 AudioContext(切到后台标签页/长时间静音后回来)——播放被调度但无声、UI 却显示朗读中;现在每次入队与**任意点击/按键**都会自动恢复;③ SSE 断线丢帧导致整句不完整——按设计丢弃该句(避免播坏音频),可开 `localStorage['dsh-voice-mode.telemetry']='1'` 看 `tts-drop-sentence` 诊断 |
309
313
  | 语音模式进不去 | 检查插件 `enabled`;多标签页时确认当前会话为活动会话 |
310
314
  | 识别到但不是我要说的 | 环境噪声或唤醒词误判:降低音量、提高 `interruptLevel`(高门槛)或启用 `wakeWord` |
@@ -323,7 +327,7 @@ flowchart LR
323
327
 
324
328
  ## 🛣️ 路线图(Roadmap)
325
329
 
326
- 完整 backlog(43 项 P0-P3)见 [`docs/competitive/backlog.md`](../../docs/competitive/backlog.md)。
330
+ 完整 backlog(43 项 P0-P3)见 [`docs/competitive/backlog.md`](https://github.com/qishuilalala/dsh-voice-mode/blob/main/docs/competitive/backlog.md)。
327
331
 
328
332
  - ✅ **已完成(v0.7.7)**:11 批次周全修复(字幕档位 / 让位语义 / 模型预热 / 默认值微调 / 死代码清理等)
329
333
  - 🚧 **P0(近期)**:ADR-0003 VAD 下沉 / ADR-0006 第一级探测接通 manual / F1 emotion DSL 全量上线
@@ -337,7 +341,7 @@ flowchart LR
337
341
 
338
342
  ```sh
339
343
  pnpm install && pnpm build # esbuild:lib/index.js(host)+ lib/client.js(browser)
340
- pnpm test # segmenter/wakeword 单测 + 发布前自检(无需网络)
344
+ pnpm test # 34 个测试文件串联:单测 + 台架(假浏览器驱动真引擎)+ 结构守卫 + 发布前自检(无需网络)
341
345
  systemctl restart dsh # 本机加载新 host 代码;其他平台重启 dsh 进程
342
346
  ```
343
347
 
@@ -350,7 +354,9 @@ src/models.ts host:模型下载/校验(SHA256 固定 + 域名白名
350
354
  src/security.ts host:限流器与安全守卫
351
355
  src/tts-local.ts host:本地 TTS 引擎(VITS WASM / Kokoro 原生 addon,子进程管理)
352
356
  src/tts-vits-worker.ts 子进程:合成执行(base64 IPC,空文本静音守卫)
353
- src/tts-queue.ts host:逐会话 TTS 队列 + epoch 打断机制
357
+ src/tts-queue.ts host:逐会话 TTS 队列 + epoch 打断 + 连续失败计数(云端整体不可用时给出可行动提示)
358
+ src/tts-runtime.ts host:Electron 宿主下 Kokoro 子进程的真 Node 选择
359
+ src/settings-store.ts / settings-http-scope.ts host:≥0.1.7 设置自持久化(覆盖层文件 + 端点,ADR-0009)
354
360
  src/segmenter.ts host:句子切分 + 文本消毒(markdown 剥离 + 噪声字符剔除)
355
361
  src/asr.ts client:音频采集、VAD 分段、增量识别、唤醒词、按住说门控
356
362
  src/client.tsx client:麦克风按钮 + 模式切换按钮 + 状态条 + 字幕浮层 + 打断
@@ -365,6 +371,6 @@ src/prompts.ts host:LLM 口语化提示词(中/英)与试听例句
365
371
 
366
372
  ## 📄 License
367
373
 
368
- [MIT](../../LICENSE)
374
+ [MIT](./LICENSE)
369
375
 
370
376
  > 部分实现借鉴 [haoku123/dsh-voice](https://github.com/haoku123/dsh-voice)(派生声明见子包 LICENSE)。
@@ -7,7 +7,7 @@ comment in `build.mjs` for why). Their licenses are reproduced below. Generated
7
7
  | --- | --- | --- |
8
8
  | agent-base | 6.0.0 | MIT |
9
9
  | asynckit | 0.4.0 | MIT |
10
- | axios | 1.19.0 | MIT |
10
+ | axios | 1.20.0 | MIT |
11
11
  | base64-js | 1.5.1 | MIT |
12
12
  | buffer | 6.0.3 | MIT |
13
13
  | call-bind-apply-helpers | 1.0.2 | MIT |
@@ -35,7 +35,7 @@ comment in `build.mjs` for why). Their licenses are reproduced below. Generated
35
35
  | mime-db | 1.52.0 | MIT |
36
36
  | mime-types | 2.1.35 | MIT |
37
37
  | ms | 2.1.3 | MIT |
38
- | msedge-tts | 2.0.7 | MIT |
38
+ | msedge-tts | 2.1.0 | MIT |
39
39
  | ws | 8.21.3 | MIT |
40
40
 
41
41
  ## agent-base 6.0.0
@@ -76,7 +76,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
76
76
  SOFTWARE.
77
77
  ```
78
78
 
79
- ## axios 1.19.0
79
+ ## axios 1.20.0
80
80
 
81
81
  - License: MIT
82
82
  - Source: https://github.com/axios/axios.git
@@ -835,7 +835,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
835
835
  SOFTWARE.
836
836
  ```
837
837
 
838
- ## msedge-tts 2.0.7
838
+ ## msedge-tts 2.1.0
839
839
 
840
840
  - License: MIT
841
841
  - Source: https://github.com/Migushthe2nd/MsEdgeTTS.git
@@ -1 +1,35 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" font-family="Segoe UI, system-ui, sans-serif" font-size="14" viewBox="0 0 960 640"><defs><marker id="arr" markerHeight="8" markerWidth="8" orient="auto" refX="7" refY="4"><path fill="#8b949e" d="M0,0 L8,4 L0,8 z"/></marker><marker id="arrR" markerHeight="8" markerWidth="8" orient="auto" refX="7" refY="4"><path fill="#f85149" d="M0,0 L8,4 L0,8 z"/></marker></defs><rect width="960" height="640" fill="#0d1117"/><text x="480" y="30" fill="#e6edf3" font-size="20" font-weight="700" text-anchor="middle">dsh-voice-mode — 语音双工数据流</text><rect width="200" height="56" x="30" y="70" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/><text x="130" y="92" fill="#58a6ff" font-weight="700" text-anchor="middle">麦克风 Mic</text><text x="130" y="112" fill="#8b949e" font-size="12" text-anchor="middle">16kHz 单声道 · AEC 回声消除</text><rect width="200" height="70" x="30" y="165" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/><text x="130" y="189" fill="#58a6ff" font-weight="700" text-anchor="middle">浏览器 VAD 分段</text><text x="130" y="209" fill="#8b949e" font-size="12" text-anchor="middle">静音 700ms 断句 / 按住说门控</text><text x="130" y="227" fill="#8b949e" font-size="12" text-anchor="middle">增量传输(每 0.9s 只传新增)</text><rect width="200" height="56" x="30" y="285" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/><text x="130" y="309" fill="#3fb950" font-weight="700" text-anchor="middle">草稿 → 自动发送</text><text x="130" y="329" fill="#8b949e" font-size="12" text-anchor="middle">autoSend / 按住说松手发送</text><rect width="200" height="70" x="30" y="405" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/><text x="130" y="429" fill="#3fb950" font-weight="700" text-anchor="middle">播放 + 字幕浮层</text><text x="130" y="449" fill="#8b949e" font-size="12" text-anchor="middle">SSE 音频帧(WAV/MP3)</text><text x="130" y="467" fill="#8b949e" font-size="12" text-anchor="middle">逐段顺序 · 世代链防重播</text><rect width="290" height="60" x="330" y="70" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/><text x="475" y="94" fill="#58a6ff" font-weight="700" text-anchor="middle">zipformer2 流式识别</text><text x="475" y="114" fill="#8b949e" font-size="12" text-anchor="middle">host 本地 WASM · 启动预热 · SHA256 校验</text><rect width="290" height="56" x="330" y="165" fill="#161b22" stroke="#d29922" stroke-width="1.5" rx="10"/><text x="475" y="189" fill="#d29922" font-weight="700" text-anchor="middle">SenseVoice 定稿</text><text x="475" y="207" fill="#8b949e" font-size="12" text-anchor="middle">带标点 · 数字归一化</text><rect width="290" height="56" x="330" y="255" fill="#161b22" stroke="#a371f7" stroke-width="1.5" rx="10"/><text x="475" y="279" fill="#a371f7" font-weight="700" text-anchor="middle">llm/stream 无损 tap → 分句</text><text x="475" y="297" fill="#8b949e" font-size="12" text-anchor="middle">text-delta 过滤 · markdown 剥离</text><rect width="290" height="56" x="330" y="345" fill="#161b22" stroke="#a371f7" stroke-width="1.5" rx="10"/><text x="475" y="369" fill="#a371f7" font-weight="700" text-anchor="middle">TTS 队列(epoch 打断)</text><text x="475" y="387" fill="#8b949e" font-size="12" text-anchor="middle">打断即杀在途合成 · 积压作废</text><rect width="290" height="100" x="330" y="435" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/><text x="475" y="459" fill="#3fb950" font-weight="700" text-anchor="middle">朗读引擎 TTS</text><text x="475" y="481" fill="#8b949e" font-size="12" text-anchor="middle">Edge 云端(默认,322 音色)</text><text x="475" y="501" fill="#8b949e" font-size="12" text-anchor="middle">VITS 本地 · 纯中文(WASM)</text><text x="475" y="521" fill="#8b949e" font-size="12" text-anchor="middle">Kokoro 本地 · 中英(int8 109MB / fp32 311MB)</text><rect width="240" height="200" x="690" y="70" fill="#161b22" stroke="#30363d" stroke-width="1" rx="10"/><text x="810" y="98" fill="#e6edf3" font-weight="700" text-anchor="middle">安全面(四层)</text><text x="710" y="126" fill="#8b949e" font-size="12">① 会话存在性校验</text><text x="710" y="146" fill="#8b949e" font-size="12">② 回环 + Origin 校验</text><text x="710" y="166" fill="#8b949e" font-size="12">③ 全端点限流</text><text x="710" y="186" fill="#8b949e" font-size="12">④ 模型 SHA256 + 域名白名单</text><text x="710" y="214" fill="#8b949e" font-size="12">打断:VAD 帧级检测 + 回声门控</text><text x="710" y="234" fill="#8b949e" font-size="12">模式:持续聆听 ⇄ 按住说</text><text x="710" y="254" fill="#8b949e" font-size="12">空闲:朗读计为活动</text><line x1="130" x2="130" y1="126" y2="163" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="230" x2="326" y1="190" y2="100" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="475" x2="475" y1="130" y2="163" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="330" x2="232" y1="193" y2="313" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="230" x2="326" y1="313" y2="283" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="475" x2="475" y1="311" y2="343" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="475" x2="475" y1="401" y2="433" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="330" x2="232" y1="485" y2="440" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><path fill="none" stroke="#f85149" stroke-width="1.5" marker-end="url(#arrR)" d="M130,475 L130,600 L475,600 L475,403"/><text x="300" y="592" fill="#f85149" font-size="12" text-anchor="middle">说话打断:本地静音 + 队列作废 + 回合取消</text></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" font-family="Noto Sans CJK SC, PingFang SC, Microsoft YaHei, Segoe UI, system-ui, sans-serif" viewBox="0 0 1110 700" width="1110" height="700">
2
+ <defs><marker id="a7d8590" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="#7d8590"/></marker><marker id="af85149" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="#f85149"/></marker></defs>
3
+ <rect width="1110" height="700" fill="#0d1117"/>
4
+ <text x="555" y="40" text-anchor="middle" font-size="24" font-weight="700" fill="#e6edf3">dsh-voice-mode · 语音双工数据流</text>
5
+ <text x="185.0" y="92" text-anchor="middle" font-size="15" font-weight="700" fill="#58a6ff" opacity="0.9">浏览器侧</text>
6
+ <line x1="40" y1="100" x2="330" y2="100" stroke="#58a6ff" stroke-width="2" opacity="0.5"/>
7
+ <text x="555.0" y="92" text-anchor="middle" font-size="15" font-weight="700" fill="#3fb950" opacity="0.9">host 侧(本地推理)</text>
8
+ <line x1="410" y1="100" x2="700" y2="100" stroke="#3fb950" stroke-width="2" opacity="0.5"/>
9
+ <text x="925.0" y="92" text-anchor="middle" font-size="15" font-weight="700" fill="#a371f7" opacity="0.9">朗读输出</text>
10
+ <line x1="780" y1="100" x2="1070" y2="100" stroke="#a371f7" stroke-width="2" opacity="0.5"/>
11
+ <rect x="40" y="120" width="290" height="92" rx="12" fill="#161b22" stroke="#58a6ff" stroke-width="2"/><text x="185.0" y="152" text-anchor="middle" font-size="17" font-weight="700" fill="#58a6ff">麦克风 Mic</text><text x="185.0" y="177" text-anchor="middle" font-size="13" fill="#9aa5b1">16kHz 单声道</text><text x="185.0" y="196" text-anchor="middle" font-size="13" fill="#9aa5b1">浏览器原生回声消除(AEC)</text>
12
+ <rect x="40" y="260" width="290" height="92" rx="12" fill="#161b22" stroke="#58a6ff" stroke-width="2"/><text x="185.0" y="292" text-anchor="middle" font-size="17" font-weight="700" fill="#58a6ff">浏览器 VAD 分段</text><text x="185.0" y="317" text-anchor="middle" font-size="13" fill="#9aa5b1">停顿 1500ms 断句(silenceMs 可调)</text><text x="185.0" y="336" text-anchor="middle" font-size="13" fill="#9aa5b1">增量上传(每 0.9s 只传新增)</text>
13
+ <rect x="40" y="400" width="290" height="92" rx="12" fill="#161b22" stroke="#58a6ff" stroke-width="2"/><text x="185.0" y="432" text-anchor="middle" font-size="17" font-weight="700" fill="#58a6ff">草稿 → 自动发送</text><text x="185.0" y="457" text-anchor="middle" font-size="13" fill="#9aa5b1">静音到点自动发送</text><text x="185.0" y="476" text-anchor="middle" font-size="13" fill="#9aa5b1">按住说:松手发送</text>
14
+ <rect x="410" y="120" width="290" height="92" rx="12" fill="#161b22" stroke="#3fb950" stroke-width="2"/><text x="555.0" y="152" text-anchor="middle" font-size="17" font-weight="700" fill="#3fb950">zipformer2 流式识别</text><text x="555.0" y="177" text-anchor="middle" font-size="13" fill="#9aa5b1">host 本地 · 边说边出字</text><text x="555.0" y="196" text-anchor="middle" font-size="13" fill="#9aa5b1">启动预热 · 模型 SHA256 校验</text>
15
+ <rect x="410" y="260" width="290" height="92" rx="12" fill="#161b22" stroke="#e3b341" stroke-width="2"/><text x="555.0" y="292" text-anchor="middle" font-size="17" font-weight="700" fill="#e3b341">SenseVoice 定稿</text><text x="555.0" y="317" text-anchor="middle" font-size="13" fill="#9aa5b1">带标点 · 数字/日期归一化(ITN)</text>
16
+ <rect x="410" y="400" width="290" height="92" rx="12" fill="#161b22" stroke="#a371f7" stroke-width="2"/><text x="555.0" y="432" text-anchor="middle" font-size="17" font-weight="700" fill="#a371f7">LLM 文本流 → 分句</text><text x="555.0" y="457" text-anchor="middle" font-size="13" fill="#9aa5b1">llm/stream 无损 tap</text><text x="555.0" y="476" text-anchor="middle" font-size="13" fill="#9aa5b1">text-delta 过滤 · markdown 剥离</text>
17
+ <rect x="780" y="120" width="290" height="92" rx="12" fill="#161b22" stroke="#a371f7" stroke-width="2"/><text x="925.0" y="152" text-anchor="middle" font-size="17" font-weight="700" fill="#a371f7">TTS 队列</text><text x="925.0" y="177" text-anchor="middle" font-size="13" fill="#9aa5b1">逐句合成 · epoch 打断</text><text x="925.0" y="196" text-anchor="middle" font-size="13" fill="#9aa5b1">打断即杀在途合成 · 积压作废</text>
18
+ <rect x="780" y="260" width="290" height="92" rx="12" fill="#161b22" stroke="#3fb950" stroke-width="2"/><text x="925.0" y="292" text-anchor="middle" font-size="17" font-weight="700" fill="#3fb950">朗读引擎</text><text x="925.0" y="317" text-anchor="middle" font-size="13" fill="#9aa5b1">Edge 云端(默认)</text><text x="925.0" y="336" text-anchor="middle" font-size="13" fill="#9aa5b1">本地 VITS(纯中文)/ Kokoro(中英)</text>
19
+ <rect x="780" y="400" width="290" height="92" rx="12" fill="#161b22" stroke="#58a6ff" stroke-width="2"/><text x="925.0" y="432" text-anchor="middle" font-size="17" font-weight="700" fill="#58a6ff">播放 + 实时字幕</text><text x="925.0" y="457" text-anchor="middle" font-size="13" fill="#9aa5b1">SSE 音频帧 · 逐句顺序播放</text><text x="925.0" y="476" text-anchor="middle" font-size="13" fill="#9aa5b1">世代链防重播</text>
20
+ <path d="M185.0,212 L185.0,260" fill="none" stroke="#7d8590" stroke-width="2" marker-end="url(#a7d8590)"/>
21
+ <path d="M330,286 L365,286 L365,166 L410,166" fill="none" stroke="#7d8590" stroke-width="2" marker-end="url(#a7d8590)"/>
22
+ <path d="M555.0,212 L555.0,260" fill="none" stroke="#7d8590" stroke-width="2" marker-end="url(#a7d8590)"/>
23
+ <path d="M410,326 L350,326 L350,430 L330,430" fill="none" stroke="#7d8590" stroke-width="2" marker-end="url(#a7d8590)"/>
24
+ <path d="M330,466 L410,466" fill="none" stroke="#7d8590" stroke-width="2" marker-end="url(#a7d8590)"/>
25
+ <path d="M700,446.0 L740,446.0 L740,166.0 L780,166.0" fill="none" stroke="#7d8590" stroke-width="2" marker-end="url(#a7d8590)"/>
26
+ <path d="M925.0,212 L925.0,260" fill="none" stroke="#7d8590" stroke-width="2" marker-end="url(#a7d8590)"/>
27
+ <path d="M925.0,352 L925.0,400" fill="none" stroke="#7d8590" stroke-width="2" marker-end="url(#a7d8590)"/>
28
+ <rect x="330" y="560" width="450" height="64" rx="12" fill="#161b22" stroke="#f85149" stroke-width="2"/>
29
+ <text x="555.0" y="586" text-anchor="middle" font-size="17" font-weight="700" fill="#f85149">开口即打断(barge-in)</text>
30
+ <text x="555.0" y="608" text-anchor="middle" font-size="13" fill="#9aa5b1">VAD 帧级检测 + 回声门控 → 取消回合 · 作废队列</text>
31
+ <path d="M40,306.0 L22,306.0 L22,592.0 L330,592.0" fill="none" stroke="#f85149" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#af85149)"/>
32
+ <path d="M780,592.0 L1076,592.0 L1076,166.0 L1070,166.0" fill="none" stroke="#f85149" stroke-width="2" stroke-dasharray="7 5" marker-end="url(#af85149)"/>
33
+ <text x="555" y="662" text-anchor="middle" font-size="13" fill="#7d8590">安全面:会话存在性校验 · 回环 + Origin 校验 · 全端点限流 · 模型 SHA256 固定 + 下载域名白名单</text>
34
+ <text x="555" y="684" text-anchor="middle" font-size="12" fill="#6e7681">空闲计时:朗读计为活动 · 模式:持续聆听 ⇄ 按住说</text>
35
+ </svg>