@ds-hu/dsh-better-voice-input 0.1.0 → 0.2.0

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
@@ -3,7 +3,8 @@
3
3
  [中文 →](README.md)
4
4
 
5
5
  **21 speech-recognition services for the DeepSeek Harness Web GUI, plus a DeepSeek-App-style
6
- hold-to-talk composer.**
6
+ hold-to-talk composer with live streaming text, a fly-to-composer animation and a configurable
7
+ keyboard shortcut.**
7
8
 
8
9
  ![Hold the composer to talk: blue recording overlay and red cancel overlay](https://raw.githubusercontent.com/ds-hu/dsh-better-voice-input/main/docs/preview-en.svg)
9
10
 
@@ -16,9 +17,20 @@ hold-to-talk composer.**
16
17
  you like.
17
18
  - **Hold the composer to talk.** Desktop and touch share one hold detector: hold the input box to
18
19
  get a full-screen recording overlay with a live waveform; slide up into the cancel zone and
19
- release to discard, release anywhere else to transcribe.
20
+ release to discard, release anywhere else to transcribe. With a streaming model (X-ASR) the
21
+ transcript appears live above the overlay while you speak and flies into the composer on release.
22
+ - **Configurable shortcut.** Record a key combination (for example `Ctrl+Shift+Space`) in the
23
+ settings and hold it to dictate from anywhere in a conversation; `Esc` cancels, releasing
24
+ inserts.
25
+ - **Never fights the keyboard.** On phones, holding the composer while the caret is in the input
26
+ and the virtual keyboard is open no longer starts recording (which used to push the keyboard
27
+ away and shift the overlay). Dismiss the keyboard and hold to talk; live text can be switched
28
+ off in settings.
20
29
  - **Your choice on release.** The transcript is inserted into the draft by default; a setting makes
21
30
  release send the message instead.
31
+ - **Self-hosted friendly.** The OpenAI-compatible entry takes any base URL and model name and lets
32
+ the API key stay empty, so a local X-ASR model exposed as an OpenAI
33
+ `/v1/audio/transcriptions` endpoint just works.
22
34
  - **Offline local models.** The 7 local families run entirely on this machine once downloaded —
23
35
  audio never leaves it, and no GPU is required.
24
36
  - **Keys stay on the host.** API keys entered in the settings page are written to the local config
@@ -26,13 +38,16 @@ hold-to-talk composer.**
26
38
 
27
39
  ## Settings
28
40
 
29
- ![Settings page: pick a speech service, download a local model, choose the release behavior](https://raw.githubusercontent.com/ds-hu/dsh-better-voice-input/main/docs/preview-settings.svg)
41
+ ![Settings page: pick a speech service, download a local model, choose the release behavior](https://raw.githubusercontent.com/ds-hu/dsh-better-voice-input/main/docs/preview-settings-en.svg)
30
42
 
31
43
  1. After installing, enable this plugin in **Plugins** and open its detail page → **Settings**.
32
- 2. Pick a cloud service and paste its API key (environment variables work as a fallback), or
33
- download a local model.
34
- 3. Optionally change *on release* from **insert draft** to **send**.
35
- 4. Back in a conversation, put the caret where the text should go and hold the composer.
44
+ 2. Both lists are master-detail: pick a model first, then only that model's form appears, so a
45
+ phone never scrolls through every field at once.
46
+ 3. Pick a cloud service and paste its API key (environment variables work as a fallback; the
47
+ OpenAI-compatible self-hosted entry may stay empty), or download a local model. Under
48
+ *Interaction* you can turn live text off; under *Shortcut* you can record a key combination.
49
+ 4. Back in a conversation, put the caret where the text should go and hold the composer (or hold
50
+ the shortcut).
36
51
 
37
52
  ## Cloud services
38
53
 
@@ -41,7 +56,7 @@ hold-to-talk composer.**
41
56
  | SiliconFlow | `FunAudioLLM/SenseVoiceSmall` | `SILICONFLOW_API_KEY` |
42
57
  | Volcengine | `bigmodel` (flash) | `VOLCENGINE_API_KEY` |
43
58
  | ElevenLabs | `scribe_v3` | `ELEVENLABS_API_KEY` |
44
- | OpenAI | `gpt-transcribe` | `OPENAI_API_KEY` |
59
+ | OpenAI / OpenAI-compatible | `gpt-transcribe` (editable) | `OPENAI_API_KEY` (optional) |
45
60
  | OpenRouter | `qwen/qwen3-asr-1.7b` | `OPENROUTER_API_KEY` |
46
61
  | DashScope (Alibaba Cloud) | `qwen-audio-3.1-asr-flash` | `DASHSCOPE_API_KEY` |
47
62
  | DeepSeek | service default | `DEEPSEEK_API_KEY` |
@@ -53,8 +68,9 @@ hold-to-talk composer.**
53
68
  | Zhipu GLM | `glm-asr-2512` | `ZHIPU_API_KEY` |
54
69
  | Cohere | `cohere-transcribe-03-2026` | `COHERE_API_KEY` |
55
70
 
56
- Every service accepts a custom base URL (proxies, regional endpoints) and its documented model,
57
- language-hint and hotword options.
71
+ Most services accept a custom base URL (proxies, regional endpoints) and their documented model
72
+ and language-hint options. The OpenAI-compatible entry can point at a fully self-hosted gateway
73
+ (for example a local X-ASR model exposed through an OpenAI endpoint) with no API key at all.
58
74
 
59
75
  ## Local models
60
76
 
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [English →](README.en.md)
4
4
 
5
5
  为 DeepSeek Harness 的 Web GUI 增加 **21 个语音识别服务**,并把输入框变成 DeepSeek App 那样
6
- **按住说话**的录音入口。
6
+ **按住说话**的录音入口:支持实时流式转写、浮层文字落位动画,以及可自定义的快捷键长按。
7
7
 
8
8
  ![按住输入框说话:蓝色录音浮层与上滑取消的红色浮层](https://raw.githubusercontent.com/ds-hu/dsh-better-voice-input/main/docs/preview.svg)
9
9
 
@@ -14,8 +14,15 @@
14
14
  DeepSeek),加上 7 个在本机运行的模型系列(SenseVoice、FunASR Nano、Qwen3-ASR、Parakeet、
15
15
  GigaAM、FireRedASR、X-ASR)。在插件面板里选中即用,随时切换。
16
16
  - **按住输入框说话。** 桌面与触屏共用同一套长按判定:按住输入框出现全屏录音浮层与实时波形,
17
- 上滑离开取消区、松手取消,其他位置松手开始转写。
17
+ 上滑离开取消区、松手取消,其他位置松手开始转写。挑中支持流式的模型(X-ASR)时,转写文字会
18
+ 在录音过程中实时出现在浮层上方,松手后从屏幕中间平滑飞入输入框。
19
+ - **自定义快捷键。** 除按住输入框外,还可以在设置里录一个组合键(例如 `Ctrl+Shift+Space`),
20
+ 长按它随时开始语音输入;`Esc` 取消,松手插入。桌面、移动端行为一致。
21
+ - **不打扰输入法。** 手机点开键盘、光标在输入框里时,长按输入框不会再触发录音(避免键盘被推走、
22
+ 浮层错位);收起键盘后按住即可录音。提供开关可实时显示识别文字。
18
23
  - **松手之后由你决定。** 默认把识别结果插入草稿光标处,也可以在设置里改成松手直接发送。
24
+ - **自部署也能用。** OpenAI 兼容服务可填任意 base URL 与模型名,API Key 允许留空,直接把本地
25
+ X-ASR 之类以 OpenAI `/v1/audio/transcriptions` 暴露的模型接进来。
19
26
  - **本地模型可离线。** 7 个本地系列下载后完全在本机推理,音频不出机器;不需要 GPU。
20
27
  - **密钥留在本机。** 设置页里填写的 API Key 只写到本机配置文件,界面始终只显示掩码。
21
28
 
@@ -24,9 +31,11 @@
24
31
  ![设置页:选择语音服务、下载本地模型、选择松手行为](https://raw.githubusercontent.com/ds-hu/dsh-better-voice-input/main/docs/preview-settings.svg)
25
32
 
26
33
  1. 安装后在 **Plugins** 面板启用本插件,打开详情页 → **设置**。
27
- 2. 选择云端服务并填写 API Key(也支持环境变量兜底),或下载一个本地模型。
28
- 3. 需要的话,把「松手之后」从 **插入草稿** 改为 **直接发送**。
29
- 4. 回到对话,把光标放到要插入文字的位置,按住输入框说话。
34
+ 2. 云端/本地两个列表都是「先选模型、再显示设置」:点选一个模型后才展开它自己的表单,
35
+ 移动端不必在几十个输入框之间找。
36
+ 3. 选择云端服务并填写 API Key(也支持环境变量兜底;OpenAI 兼容的自部署服务可留空),
37
+ 或下载一个本地模型;在「交互」里可以关闭实时文字、在「快捷键」里录一个组合键。
38
+ 4. 回到对话,把光标放到要插入文字的位置,按住输入框(或长按快捷键)说话。
30
39
 
31
40
  ## 云端服务
32
41
 
@@ -35,7 +44,7 @@
35
44
  | SiliconFlow 硅基流动 | `FunAudioLLM/SenseVoiceSmall` | `SILICONFLOW_API_KEY` |
36
45
  | 火山引擎 | `bigmodel`(flash) | `VOLCENGINE_API_KEY` |
37
46
  | ElevenLabs | `scribe_v3` | `ELEVENLABS_API_KEY` |
38
- | OpenAI | `gpt-transcribe` | `OPENAI_API_KEY` |
47
+ | OpenAI / OpenAI 兼容 | `gpt-transcribe`(可自定义) | `OPENAI_API_KEY`(可留空) |
39
48
  | OpenRouter | `qwen/qwen3-asr-1.7b` | `OPENROUTER_API_KEY` |
40
49
  | 阿里云百炼 | `qwen-audio-3.1-asr-flash` | `DASHSCOPE_API_KEY` |
41
50
  | DeepSeek | 服务默认 | `DEEPSEEK_API_KEY` |
@@ -47,7 +56,8 @@
47
56
  | 智谱 GLM | `glm-asr-2512` | `ZHIPU_API_KEY` |
48
57
  | Cohere | `cohere-transcribe-03-2026` | `COHERE_API_KEY` |
49
58
 
50
- 所有服务都支持自定义 base URL(代理、区域端点),以及各家文档化的 model、语言提示、热词等选项。
59
+ 多数服务支持自定义 base URL(代理、区域端点)与文档化的 model、语言提示等选项;OpenAI 兼容
60
+ 一项可以完整指向自建网关(例如把本地 X-ASR 模型以 OpenAI 接口暴露),无需 API Key。
51
61
 
52
62
  ## 本地模型
53
63
 
@@ -81,7 +91,8 @@ dsh plugin --profile <profile> add @ds-hu/dsh-better-voice-input
81
91
  ## 环境要求
82
92
 
83
93
  - DeepSeek Harness **>= 0.2.2-rc.5 < 0.3.0**,Node.js **>= 20.19**。
84
- - 使用按住说话需要支持 `getUserMedia` 的浏览器(DSH Web GUI)。
94
+ - 使用按住说话需要支持 `getUserMedia` 的浏览器(DSH Web GUI);流式实时文字还需要
95
+ `AudioWorklet`,不支持时自动退回整段识别,功能不受影响。
85
96
  - 本地模型需要磁盘空间(视变体约几百 MB 到 2 GB)与 CPU,无需 GPU。
86
97
 
87
98
  ## 隐私
@@ -94,6 +94,10 @@ settings page reports the missing official dependency.
94
94
  provider-specific container/base64 handling live in the request builder of each adapter.
95
95
  Providers that need a different container get an adapter-specific conversion path documented
96
96
  in `docs/research/cloud-providers.md`.
97
+ - Credentials are optional per field: `bvi-cloud-openai` doubles as the OpenAI-compatible
98
+ self-hosted entry (editable `baseURL`/`model`, empty `apiKey` → no `Authorization` header), so a
99
+ local X-ASR gateway exposed as an OpenAI `/v1/audio/transcriptions` server can be selected
100
+ directly.
97
101
  - Failures throw `Error` messages that the service relays to the UI (no secrets, bounded length).
98
102
 
99
103
  ### 3.4 Local providers (`local`)
@@ -114,6 +118,11 @@ settings page reports the missing official dependency.
114
118
  handshake, a serial decode queue, inference/idle timeouts, crash restart and termination on
115
119
  plugin unload or variant switch. Switching variants stops the old worker before starting the new
116
120
  one; only the selected family is resident at a time.
121
+ - Streaming (v0.2): X-ASR's `OnlineRecognizer` is also served incrementally. The worker gains
122
+ four authenticated loopback routes (`/stream/start|chunk|finish|cancel`, PCM16LE 16 kHz);
123
+ `worker/runtime.js` forwards them and `provider.js` exposes the optional `bviStreaming`
124
+ extension described in `docs/CONTRACTS.md`. The recognizer configuration is unchanged — the
125
+ streaming path reuses the exact X-ASR config. Other families stay batch-only.
117
126
  - VAD: the shared Silero VAD asset is downloaded alongside the model and used to cut long
118
127
  recordings into 15–24 s segments for the families that truncate long inputs (FunASR Nano,
119
128
  Qwen3-ASR); the others decode the whole utterance. Exact per-family configuration, language
@@ -125,7 +134,7 @@ settings page reports the missing official dependency.
125
134
 
126
135
  ### 3.5 Service HTTP API (`service`)
127
136
 
128
- Registered as seven exact Fetch routes through `ctx.connection.fetch.register({ path, methods,
137
+ Registered as eleven exact Fetch routes through `ctx.connection.fetch.register({ path, methods,
129
138
  requestBody: 'buffered', fetch })` (`inject = ['connection']`), each under
130
139
  `/api/better-voice-input/`. The connection layer owns the Host/Origin fence and browser
131
140
  authentication (owner Peer only), so the handlers carry no hand-written same-origin check; the
@@ -140,9 +149,15 @@ a 4xx/5xx with `{ ok: false, code, message }`.
140
149
  | `POST /prepare` | `{ providerId, downloadSource? }` — `ctx.speechToText.prepare(...)` |
141
150
  | `POST /cancel-preparation` | `{ providerId }` |
142
151
  | `POST /transcribe?language=auto` | raw `audio/wav` body (≤ `limits.maxAudioBytes`) — canonical WAV validation then `ctx.speechToText.transcribe`, returns `{ ok: true, text, audioSeconds, inferenceSeconds }` |
143
- | `POST /preferences` | `{ releaseAction?, holdDelayMs?, cancelDistancePx?, hintDismissed?, composerHint? }` |
144
-
145
- A JSON `{ audioBase64 }` body is also accepted on `/transcribe` for tests and as a fallback
152
+ | `POST /preferences` | partial preferences (`releaseAction`, `holdDelayMs`, `cancelDistancePx`, `hintDismissed`, `composerHint`, `streaming`, `shortcut`) |
153
+ | `POST /stream/start` | `{ providerId?, language? }` — open a live session for a `streaming` provider |
154
+ | `POST /stream/chunk?session=…` | raw PCM16LE mono 16 kHz, ≤ 1 MiB — `{ partial }` |
155
+ | `POST /stream/finish?session=…` | final `{ text, audioSeconds, inferenceSeconds }` |
156
+ | `POST /stream/cancel?session=…` | abort + dispose |
157
+
158
+ Streaming sessions are held in memory by the `api` closure (max four, 120 s idle TTL, disposed
159
+ on row unload), so no browser state outlives a recording and no Host file is written. A JSON
160
+ `{ audioBase64 }` body is also accepted on `/transcribe` for tests and as a fallback
146
161
  carrier; base64 is decoded and validated the same way. `GET /state` is polled by the settings page
147
162
  (1.5 s) while a preparation is running and once on open. It is cheap: in-memory snapshot + one
148
163
  small file read.
@@ -153,14 +168,19 @@ Registered into `plugins.bundle.config` keyed by `@ds-hu/dsh-better-voice-input`
153
168
  official `VoicePreparation` page pattern. Sections:
154
169
 
155
170
  1. **依赖状态** — official speech-to-text service present? selected provider + language.
156
- 2. **云端服务** — one card per vendor: configured/unconfigured badge, API key (write-only +
157
- masked display), base URL, model, vendor-specific fields, env fallback hint, docs link.
158
- 3. **本地模型** — one card per family: variant selector, download / cancel / progress, runtime
159
- readiness, languages and disk/memory estimate.
171
+ 2. **云端服务** — master-detail: a compact provider list (name + configured badge) plus the
172
+ detail card of the **selected** provider only (API key write-only + masked, base URL, model,
173
+ vendor fields, env hint, docs link, save). Nothing is flattened all at once, so a phone only
174
+ scrolls through the list it is choosing from.
175
+ 3. **本地模型** — same master-detail pattern: model list (name, variant, install badge) and a
176
+ detail pane with variant selector, download / cancel / retry, progress, languages and
177
+ disk/memory estimate.
160
178
  4. **交互** — release action (insert draft / send, default insert), hold delay, slide-up cancel
161
- distance, composer placeholder hint (`composerHint`, default on: “发消息或按住说话”), first-run
162
- hint reset.
163
- 5. **说明** — audio destination per provider (cloud upload vs local), dependency on the
179
+ distance, composer placeholder hint (`composerHint`, default on: “发消息或按住说话”), live
180
+ streaming display toggle (`streaming`, default on), first-run hint reset.
181
+ 5. **快捷键** — enable/disable, record a long-press combination, show its label (e.g.
182
+ `Ctrl+Shift+Space`); validation rejects bare letters/space.
183
+ 6. **说明** — audio destination per provider (cloud upload vs local), dependency on the
164
184
  official plugin, where data is written.
165
185
 
166
186
  Only theme tokens (`--dsw-*`) are used; controls are written locally (no Harness client imports).
@@ -186,6 +206,12 @@ slot contract). The slot id is stable, so re-registration on graph updates is id
186
206
  - Start conditions: primary button only; not inside an interactive control (`button`, `a`,
187
207
  `input`, `select`, `[role=button]`, `[contenteditable=false]`); composer editable and not
188
208
  disabled; no active session; not while a transcript is being inserted.
209
+ - **Focused-editor guard (v0.2)**: on touch/pen the hold never starts when the composer editor
210
+ has focus or the virtual keyboard is open (`visualViewport` height materially shorter than
211
+ `innerHeight`). The keyboard would otherwise be pushed away mid-gesture, moving the overlay
212
+ and losing the user's cursor. Desktop mouse users keep the gesture while the editor is focused
213
+ (no software keyboard). A first tap focuses the editor as usual; the user dismisses the
214
+ keyboard (tap outside / back) and then holds to speak.
189
215
  - Hold window: default 280 ms (`preferences.holdDelayMs`), movement <= 8 px, pointer not
190
216
  released/cancelled, window not blurred.
191
217
  - On hold commit: suppress `contextmenu`/`selectstart`, clear the text selection, add a
@@ -196,6 +222,12 @@ slot contract). The slot id is stable, so re-registration on graph updates is id
196
222
  Escape, window blur and tab hide cancel. Page scroll is prevented during the session.
197
223
  - Desktop and mobile share this exact state machine; the only platform-specific inputs are the
198
224
  pointer events themselves and optional `navigator.vibrate(10)`.
225
+ - **Keyboard shortcut (v0.2)**: `preferences.shortcut` (e.g. hold `Ctrl+Shift+Space`) starts the
226
+ same hold flow from a `keydown` (`event.code` + modifiers, no repeat) and releases on `keyup`;
227
+ Escape cancels. It only fires while a composer exists and the active element is the composer,
228
+ its card or `document.body` — settings inputs and other forms keep typing normally. The
229
+ shortcut hold duration is the same `holdDelayMs`. Because the pipeline is shared, insert/send,
230
+ cancel, streaming and toasts behave identically for pointer and keyboard triggers.
199
231
 
200
232
  ### 4.3 Overlay states (DeepSeek App replication)
201
233
 
@@ -207,6 +239,8 @@ Full-screen (100dvh, safe-area aware), portal to body:
207
239
  | recording | deep navy -> electric blue gradient | `松手插入,上滑取消` (or `松手发送,…`) | live waveform bars |
208
240
  | cancel-armed | deep maroon -> red gradient | `松手取消` | waveform bars in red |
209
241
  | transcribing | last gradient | `正在识别…` | soft pulsing dots |
242
+ | streaming | recording gradient | `松手插入,上滑取消` | live cumulative transcript above the waveform, updating as chunks arrive |
243
+ | settling | recording gradient fading | — | final line cloned into a `.bvi-flight` element and flown to the composer input (~360 ms), then inserted |
210
244
  | error | last gradient | failure sentence | dismiss on tap/release |
211
245
 
212
246
  Motion: 160 ms fade in, 200 ms gradient crossfade, waveform driven by a 60 fps meter from the
@@ -219,6 +253,11 @@ reference; text is centered around 38 % of the viewport height, waveform band ar
219
253
  autoGainControl: true } })`; AudioContext kept alive (unlocked from the initial pointer gesture
220
254
  so iOS/desktop autoplay policies are satisfied), AudioWorklet (inline blob module) captures
221
255
  Float32 frames and posts RMS/peak meter values at ~30 Hz.
256
+ - Two capture modes share one microphone: **batch** keeps `MediaRecorder` and produces the
257
+ canonical WAV at release; **streaming** (v0.2, selected provider declares `streaming`) taps the
258
+ AudioWorklet Float32 frames, downsamples to 16 kHz, chunks every ~200 ms and POSTs them to
259
+ `/stream/chunk`. If `AudioWorklet` is unavailable the recording transparently falls back to
260
+ batch. The waveform meter works in both modes.
222
261
  - Stop: disconnect tracks, resample to 16 kHz linear interpolation, encode canonical mono PCM16
223
262
  WAV (44-byte header), enforce `limits.maxAudioBytes`/`maxDurationSeconds`.
224
263
  - The recording limit auto-finishes the take instead of dropping it.
@@ -227,6 +266,9 @@ reference; text is centered around 38 % of the viewport height, waveform band ar
227
266
 
228
267
  ### 4.5 Result handling
229
268
 
269
+ - Streaming: `finish` returns the final transcript; a DOM flight clone animates the last live
270
+ line into the composer, then the normal insertion runs (reduced-motion skips the animation).
271
+ Slide-up cancel or Escape calls `/stream/cancel` and inserts nothing.
230
272
  - `insert` (default): `inputActions.insertText(text, inputActions.captureInsertion())`; if the
231
273
  draft moved concurrently, fall back to `setDraft(current + text)`; empty/whitespace -> notice.
232
274
  - `send`: insert with the same guards, then `inputActions.submit()` on the next microtask.
@@ -251,19 +293,25 @@ reference; text is centered around 38 % of the viewport height, waveform band ar
251
293
  request/response adapters against a local mock HTTP server, service API/host against a fake
252
294
  `speechToText` service, local catalog/provision/worker protocol and recognizer-config builders
253
295
  (no native load), both browser entries loaded in a `vm` harness (factory contract, placement,
254
- gesture state machine, WAV encoder, preference handling), and one cross-component test that
255
- holds the 21-provider and release/documentation contracts together.
296
+ gesture state machine, WAV encoder, preference handling), streaming session relays and the
297
+ optional-credential path, and one cross-component test that holds the 21-provider and
298
+ release/documentation contracts together.
256
299
  - `npm run lint` is part of `npm run check`; CI (`.github/workflows/ci.yml`) is the only place
257
300
  these run, on Node 20 and 22.
258
301
  - `.github/workflows/release.yml` publishes core -> service/cloud/local/input -> bundle on a `v*`
259
302
  tag, then creates the GitHub release.
260
- - Optional `workflow_dispatch` smoke workflow (`local-models-smoke.yml`) downloads a pinned model
261
- (or every family, one dispatch at a time) and runs one real transcription; it never runs on PRs.
262
- Evidence for every catalog variant is recorded in `docs/VERIFICATION.md`.
263
-
264
- ## 7. Non-goals for v0.1
265
-
266
- - Streaming/partial transcripts (the reference app also shows no partial text).
303
+ - Optional `workflow_dispatch` smoke workflows: `local-models-smoke.yml` downloads a pinned model
304
+ (or every family, one dispatch at a time) and runs one real transcription;
305
+ `openai-compat-smoke.yml` downloads the pinned X-ASR model, serves it through a local
306
+ OpenAI-compatible `/v1/audio/transcriptions` endpoint, drives the real `bvi-cloud-openai`
307
+ adapter with an **empty API key**, and asserts the transcript plus the absence of an
308
+ authorization header. Neither runs on PRs. Evidence is recorded in `docs/VERIFICATION.md`.
309
+
310
+ ## 7. Non-goals for v0.2
311
+
312
+ - Cloud-side streaming: only providers with a native incremental recognizer stream live (currently
313
+ local X-ASR); cloud vendors stay batch because their streaming transports are WebSocket
314
+ protocols that deserve their own adapters.
267
315
  - Selecting a browser microphone device (system default only).
268
316
  - Downloading models in the browser; all model I/O stays on the host.
269
317
  - Replacing the official recording component (both can coexist; keep the official bundle's
package/docs/CONTRACTS.md CHANGED
@@ -1,4 +1,4 @@
1
- # Module contracts (v0.1)
1
+ # Module contracts (v0.2)
2
2
 
3
3
  Implementation contract between the five packages. Names are exact: the same identifiers are
4
4
  imported across packages and asserted by tests. Plain ESM, JSDoc only.
@@ -30,7 +30,9 @@ One JSON document per data root (`<dataRoot>/config.json`):
30
30
  providers: { 'bvi-cloud-openai': { apiKey: '…', baseURL: '…', model: '…' } },
31
31
  local: { 'bvi-local-sensevoice': { variant: 'small-int8' } },
32
32
  preferences: { releaseAction: 'insert', holdDelayMs: 280, cancelDistancePx: 72,
33
- hintDismissed: false, composerHint: true },
33
+ hintDismissed: false, composerHint: true, streaming: true,
34
+ shortcut: { enabled: false, code: 'Space', ctrl: true, alt: false,
35
+ shift: true, meta: false } },
34
36
  }
35
37
  ```
36
38
 
@@ -39,8 +41,10 @@ One JSON document per data root (`<dataRoot>/config.json`):
39
41
  `ConfigError('missing-data-root')`. The service row resolves the root before calling it
40
42
  (`config.dataRoot`, else `ctx.get('dshHomePath')('better-voice-input')`).
41
43
  - `defaultConfig()` — `{ version: 1, providers: {}, local: {}, preferences: defaultPreferences() }`.
42
- - `defaultPreferences()` — the five keys above; `composerHint` defaults to `true` (the composer
43
- shows the “发消息或按住说话” hint until the user hides it in the settings page).
44
+ - `defaultPreferences()` — the keys above; `composerHint` defaults to `true` (the composer
45
+ shows the “发消息或按住说话” hint until the user hides it in the settings page); `streaming`
46
+ defaults to `true` (streaming-capable providers show live text while recording); `shortcut`
47
+ defaults to disabled with `Ctrl+Shift+Space` as the suggested combination.
44
48
  - `readConfig(dataRoot)` — missing file → default config; unknown keys are dropped; each invalid
45
49
  preference falls back to its default (tolerant read). A structurally corrupt document throws
46
50
  `ConfigError` with code `invalid-json`, `invalid-config`, `unsupported-version` or
@@ -52,8 +56,15 @@ One JSON document per data root (`<dataRoot>/config.json`):
52
56
  returns the next document. A rejected mutation does not break the queue.
53
57
  - `sanitizePreferences(patch, base)` — strict validation for the HTTP path: known keys only,
54
58
  `releaseAction ∈ {'insert','send'}`, `holdDelayMs ∈ [150, 1000]`, `cancelDistancePx ∈ [40, 200]`,
55
- `hintDismissed`/`composerHint` booleans; invalid known values throw
59
+ `hintDismissed`/`composerHint`/`streaming` booleans; invalid known values throw
56
60
  `ConfigError('invalid-preferences')`.
61
+ - `shortcut` is `{ enabled: boolean, code: string, ctrl, alt, shift, meta: boolean }`. `code` is
62
+ a `KeyboardEvent.code` value (`Space`, `KeyV`, `F2`, …) of 1–32 `[A-Za-z0-9]` characters and
63
+ cannot be a bare modifier (`ShiftLeft`, `ControlRight`, …). A shortcut must carry at least one
64
+ of `ctrl`/`alt`/`meta`, or be a function key (`F1`–`F12`), so a plain letter/space can never
65
+ hijack typing. `holdDelayMs` is the hold duration for both pointer and keyboard triggers.
66
+ A partial `shortcut` patch is merged over the current value (for example `{ enabled: true }`
67
+ toggles the stored combination); unknown keys are dropped and an invalid result throws.
57
68
  - `maskSecret(value)` — `''` for an empty value, `'…'` for short ones, otherwise
58
69
  `first3…last4`; never returns the full value.
59
70
 
@@ -110,6 +121,10 @@ object from a **runtime descriptor** (metadata + one of `buildRequest`/`parseRes
110
121
  (the user's saved value wins; an empty string counts as “not set” and falls back to the
111
122
  environment again). Returns `{ settings, missing }` where `missing` lists required keys as
112
123
  `{ key, env? }`. Saved keys without a field descriptor are kept for the adapter.
124
+ - Optional credentials: a field with `required: false` may stay empty; `bearerHeaders('')`
125
+ returns `{}` so an OpenAI-compatible self-hosted gateway receives no `Authorization` header
126
+ (the vendor answers 401 if it actually needs one). All required fields are still enforced by
127
+ `readProviderSettings` before any request is built.
113
128
  - The factory trims the transcript text, falls back to the WAV header for `audioSeconds` and to
114
129
  the elapsed wall time for `inferenceSeconds`, and maps unexpected adapter errors to
115
130
  `ProviderError('parse'|'unsupported')`; `ProviderError`s and caller aborts pass through
@@ -128,13 +143,13 @@ cloud package and is joined with these records there:
128
143
  ```js
129
144
  {
130
145
  id: 'bvi-cloud-openai', vendor: 'openai', location: 'cloud',
131
- name: { zh: 'OpenAI 语音识别', en: 'OpenAI speech recognition' },
146
+ name: { zh: 'OpenAI / OpenAI 兼容服务', en: 'OpenAI / OpenAI-compatible' },
132
147
  languages: ['auto', 'zh', 'en', ...],
133
148
  docs: 'https://platform.openai.com/docs/guides/speech-to-text',
134
149
  env: ['OPENAI_API_KEY'],
135
150
  fields: [
136
- { key: 'apiKey', type: 'secret', required: true, env: 'OPENAI_API_KEY',
137
- label: { zh: 'API Key', en: 'API key' } },
151
+ { key: 'apiKey', type: 'secret', env: 'OPENAI_API_KEY',
152
+ label: { zh: 'API Key(自部署服务可留空)', en: 'API key (blank for self-hosted)' } },
138
153
  { key: 'baseURL', type: 'url', default: 'https://api.openai.com/v1', label: {...} },
139
154
  { key: 'model', type: 'text', default: 'gpt-4o-transcribe', label: {...} },
140
155
  { key: 'mode', type: 'select', default: 'fast', label: {...},
@@ -164,6 +179,7 @@ sherpa-onnx configuration inside its worker:
164
179
  docs: 'https://…',
165
180
  downloadSources: ['https://huggingface.co', 'https://hf-mirror.com'],
166
181
  defaultVariant: 'small-int8',
182
+ streaming: false, // optional; exactly X-ASR sets true (native online recognizer)
167
183
  runtime: { kind: 'offline' | 'online', threads, vad, segmentation },
168
184
  setupEstimate: { recommendedDiskBytes, expectedMemoryBytes, minimumMinutes, maximumMinutes },
169
185
  variants: [{
@@ -190,7 +206,7 @@ input bundle is disabled.
190
206
  `apply(ctx, config)` resolves the data root (`config.dataRoot`, else
191
207
  `ctx.get('dshHomePath')('better-voice-input')`; both go through `resolveDataRoot`), loads the two
192
208
  catalogs tolerantly (`import.meta.resolve` + `existsSync`; a missing component package means an
193
- empty list, a present-but-broken catalog rejects the row), then registers **seven exact Fetch
209
+ empty list, a present-but-broken catalog rejects the row), then registers **eleven exact Fetch
194
210
  routes** with `ctx.connection.fetch.register({ path, methods, requestBody: 'buffered', fetch })`
195
211
  inside `ctx.effect`. The Connection layer owns the Host/Origin fence and browser authentication
196
212
  (the owner Peer), so the handlers contain no hand-written same-origin check.
@@ -204,16 +220,31 @@ inside `ctx.effect`. The Connection layer owns the Host/Origin fence and browser
204
220
  | `POST /api/better-voice-input/cancel-preparation` | `{ providerId }` | `ctx.speechToText.cancelPreparation(id)` |
205
221
  | `POST /api/better-voice-input/transcribe?language=…` | raw `audio/wav` (≤ 8 MiB) | validate canonical WAV, `ctx.speechToText.transcribe`, `{ ok: true, text, audioSeconds, inferenceSeconds }` |
206
222
  | `POST /api/better-voice-input/preferences` | partial preferences | validate with `sanitizePreferences` and persist |
223
+ | `POST /api/better-voice-input/stream/start` | `{ providerId?, language? }` | open a live streaming session for a streaming-capable provider → `{ ok:true, sessionId, sampleRate:16000, providerId }` |
224
+ | `POST /api/better-voice-input/stream/chunk?session=…` | raw `application/octet-stream` PCM16LE mono 16 kHz (≤ 1 MiB) | push one live audio chunk → `{ ok:true, partial, bytes }` |
225
+ | `POST /api/better-voice-input/stream/finish?session=…` | — | close the session and return the final transcript `{ ok:true, text, audioSeconds, inferenceSeconds }` |
226
+ | `POST /api/better-voice-input/stream/cancel?session=…` | — | abort and dispose the session (idempotent) |
207
227
 
208
228
  Body limits: JSON mutations 64 KiB (`MAX_JSON_BODY_BYTES`), transcribe 8 MiB
209
229
  (`MAX_TRANSCRIBE_BODY_BYTES`), audio then capped by `limits.maxAudioBytes` after the WAV header is
210
- checked. `/transcribe` also accepts the JSON compatibility form `{ audioBase64, language?,
211
- providerId? }` for tests and non-browser callers.
230
+ checked; streaming chunks are capped at 1 MiB each and the session total at
231
+ `limits.maxAudioBytes`. A `/stream/chunk` body must be `application/octet-stream`
232
+ (`unsupported-media-type`, 415), non-empty (`stream-chunk-empty`, 400), even-length PCM16
233
+ (`invalid-body`, 400) and within the caps (`body-too-large`, 413). Unknown or idle-expired
234
+ session ids answer `stream-unknown` (404); a fifth concurrent session answers `stream-limit`
235
+ (429); a provider without `bviStreaming` answers `streaming-unavailable` (409); a provider handle
236
+ that misbehaves during start answers `streaming-failed` (502). `/transcribe` also accepts the JSON
237
+ compatibility form `{ audioBase64, language?, providerId? }` for tests and non-browser callers.
238
+
239
+ Streaming sessions live in the service's `api` closure (never in the browser): at most four
240
+ concurrent sessions, 120 s idle TTL with a `.unref()`ed timer, one provider handle each; `finish`,
241
+ `cancel` and expiry dispose the handle, and the row's `ctx.effect` cleanup disposes every live
242
+ session when the plugin unloads. Session ids come from `crypto.randomUUID()`.
212
243
 
213
244
  Success is HTTP 2xx with `{ ok: true, ... }`; failure is a non-2xx with
214
245
  `{ ok: false, code, message }`, where the code is stable (`audio-*`, `provider-*`,
215
- `invalid-*`, `config-error`, `dependency-missing`, `unknown-provider`, `body-too-large`,
216
- `unsupported-media-type`, `cancelled`, `internal`, …).
246
+ `invalid-*`, `stream-*`, `config-error`, `dependency-missing`, `unknown-provider`,
247
+ `body-too-large`, `unsupported-media-type`, `cancelled`, `internal`, …).
217
248
 
218
249
  `GET /state` document (frozen; the settings page and the input component rely on it):
219
250
 
@@ -223,17 +254,22 @@ Success is HTTP 2xx with `{ ok: true, ... }`; failure is a non-2xx with
223
254
  "dependency": { "speechToText": true },
224
255
  "providers": [{ "id": "bvi-cloud-openai", "name": "…", "location": "cloud",
225
256
  "languages": ["auto", "zh"],
226
- "preparation": { "phase": "ready" } }],
257
+ "preparation": { "phase": "ready" },
258
+ "streaming": false }],
227
259
  "selection": { "providerId": "bvi-cloud-openai", "language": "zh" },
228
260
  "config": { "bvi-cloud-openai": { "configured": true,
229
261
  "fields": { "apiKey": "sk-…4f2a", "baseURL": "…" } } },
230
262
  "cloud": [{ "id": "bvi-cloud-openai", "name": { "zh": "…", "en": "…" },
231
- "languages": [], "env": [], "fields": [], "docs": "…", "configured": true }],
263
+ "languages": [], "env": [], "fields": [], "docs": "…", "configured": true,
264
+ "streaming": false }],
232
265
  "local": [{ "id": "bvi-local-sensevoice", "name": { "zh": "…", "en": "…" },
233
266
  "languages": [], "variants": [], "defaultVariant": "…", "variant": "…",
234
- "downloadSources": [], "install": { "phase": "unprepared" } }],
267
+ "downloadSources": [], "streaming": false,
268
+ "install": { "phase": "unprepared" } }],
235
269
  "preferences": { "releaseAction": "insert", "holdDelayMs": 280, "cancelDistancePx": 72,
236
- "hintDismissed": false, "composerHint": true },
270
+ "hintDismissed": false, "composerHint": true, "streaming": true,
271
+ "shortcut": { "enabled": false, "code": "Space", "ctrl": true,
272
+ "alt": false, "shift": true, "meta": false } },
237
273
  "limits": { "maxAudioBytes": 4194304, "maxDurationSeconds": 120 }
238
274
  }
239
275
  ```
@@ -246,8 +282,9 @@ uses the same normalization for the local provider's official preparation state
246
282
  (`{ phase: 'unprepared' }` while the row is not registered). Secrets only ever appear masked.
247
283
 
248
284
  `lib/api.js` is the testable half: `createApi({ store, catalogs, getSpeech, env, logger, limits })`
249
- returns `state`, `saveConfig`, `select`, `prepare`, `cancelPreparation`, `transcribe` and
250
- `savePreferences`; `toErrorPayload(error)` maps `ApiError` / `WavError` / `ProviderError` /
285
+ returns `state`, `saveConfig`, `select`, `prepare`, `cancelPreparation`, `transcribe`,
286
+ `savePreferences`, `startStream`, `pushStream`, `finishStream`, `cancelStream` and `dispose`
287
+ (plus an optional `sessionIdleTimeoutMs` test seam, default 120 s); `toErrorPayload(error)` maps `ApiError` / `WavError` / `ProviderError` /
251
288
  `ConfigError` / aborts to the HTTP status and envelope above. `lib/store.js` wraps the data root
252
289
  in `read()`/`update()`.
253
290
 
@@ -266,11 +303,12 @@ ctx.slots.inject('plugins.bundle.config', () =>
266
303
 
267
304
  The owner passes `{ view: 'summary' | 'page' }` and no `form`, so the page draws its own form and
268
305
  persists through the HTTP API above (`GET /state` once on open, then polls every 1.5 s while a
269
- local model is preparing). Sections: dependency status, default provider/language, cloud vendor
270
- cards (write-only + masked secrets, env fallback hint, docs link), local model cards (variant,
271
- download/cancel/progress, estimate), composer preferences (`releaseAction`, `holdDelayMs`,
272
- `cancelDistancePx`, `composerHint`, first-run hint reset) and a notes card. The summary view shows
273
- the configured cloud/local counts.
306
+ local model is preparing). Sections: dependency status, default provider/language, the
307
+ **master-detail** cloud and local lists (only the selected entry renders its card: write-only +
308
+ masked secrets, env fallback hint, docs link; variant, download/cancel/progress, estimate),
309
+ composer preferences (`releaseAction`, `holdDelayMs`, `cancelDistancePx`, `composerHint`,
310
+ `streaming`, first-run hint reset), the keyboard-shortcut recorder and a notes card. The summary
311
+ view shows the configured cloud/local counts.
274
312
 
275
313
  ## `@ds-hu/dsh-bvi-input` (client)
276
314
 
@@ -280,6 +318,105 @@ the configured cloud/local counts.
280
318
  `POST /api/better-voice-input/transcribe?language=…`). Gesture, overlay and audio rules:
281
319
  `docs/ARCHITECTURE.md` §4.
282
320
 
321
+ ## Streaming extension (v0.2, our providers only)
322
+
323
+ The official speech seam has no streaming API, so live transcripts use a **service-owned relay**
324
+ plus an optional extension object on our own registered providers. Nothing official is modified.
325
+
326
+ ### `provider.bviStreaming` (cloud/local packages → service)
327
+
328
+ ```js
329
+ provider.bviStreaming = {
330
+ /**
331
+ * @param {{ language?: string }} options - selected language, already validated by the caller.
332
+ * @returns {Promise<{
333
+ * push(pcm: Uint8Array): Promise<{ partial: string }>, // PCM16LE, mono, 16 kHz
334
+ * finish(): Promise<{ text: string, audioSeconds: number, inferenceSeconds: number }>,
335
+ * cancel(): Promise<void>,
336
+ * }>}
337
+ */
338
+ async start(options) { … },
339
+ }
340
+ ```
341
+
342
+ - Records omit `streaming` (or keep `false`) unless the family has a native incremental
343
+ recognizer; absence means `false`. Only a provider whose catalog record declares
344
+ `streaming: true` may implement the extension; the service
345
+ marks those entries in `/state` (`providers[].streaming`) and refuses `/stream/start` for any
346
+ other provider (`streaming-unavailable`, HTTP 409).
347
+ - The service obtains the provider object with `ctx.speechToText.resolve({ audio: new
348
+ Uint8Array(0), language, providerId })` and checks `provider.bviStreaming` at request time.
349
+ The pinned provider lifetime is the session lifetime; `/stream/finish|cancel` release it.
350
+ - `partial` is the **cumulative** transcript so far (the browser replaces the live line). Empty
351
+ strings are valid. `finish()` settles exactly once; `cancel()` is idempotent and must release
352
+ the worker stream.
353
+ - `bviStreaming` is the only non-official property we add to a provider object; official
354
+ consumers ignore it.
355
+
356
+ ### Worker private protocol (`packages/local`, X-ASR only)
357
+
358
+ `sherpa-onnx-node`'s `OnlineRecognizer` provides incremental results. The worker child exposes
359
+ four authenticated loopback routes (bearer token, `127.0.0.1`, ephemeral port — same transport as
360
+ `/transcribe`):
361
+
362
+ | Method + path | Body | Answer |
363
+ | --- | --- | --- |
364
+ | `POST /stream/start?language=…` | — | `{ streamId }` (one live stream per worker) |
365
+ | `POST /stream/chunk?stream=…` | raw PCM16LE mono 16 kHz | `{ partial, bytes }` |
366
+ | `POST /stream/finish?stream=…` | — | `{ text, audioSeconds }` |
367
+ | `POST /stream/cancel?stream=…` | — | `{ ok: true }` |
368
+
369
+ The final decode uses the same drain protocol as the batch path (drain → two 480 ms silence
370
+ chunks → `inputFinished()` → drain) and the same `adapter.sanitize` text policy. Model
371
+ configuration literals are **unchanged** — streaming reuses the existing X-ASR
372
+ `OnlineRecognizer` config. The parent runtime exposes `startStream/pushStream/finishStream/
373
+ cancelStream` and measures `inferenceSeconds` on the parent side.
374
+
375
+ ### Browser contract (`packages/input`)
376
+
377
+ - Trigger rules: the pointer hold only starts when the composer editor is **not** focused on a
378
+ touch device and the virtual keyboard is closed (see ARCHITECTURE §4.2). The optional keyboard
379
+ shortcut follows the `preferences.shortcut` object.
380
+ - Streaming path is selected per recording: `preferences.streaming === true` **and**
381
+ `state.providers[selected].streaming === true` **and** `AudioWorklet` (or `ScriptProcessor`)
382
+ capture is available. Otherwise the existing whole-WAV `MediaRecorder` path runs unchanged.
383
+ - Audio: Float32 frames → 16 kHz PCM16LE; a `POST /stream/chunk` runs every ~200 ms (no
384
+ overlapping requests); overlay shows `partial` live above the waveform.
385
+ - Release: `POST /stream/finish` → final text → flight animation → `insertText`/`setDraft` as in
386
+ the batch path (`send` action and the conflict fallbacks are shared). Slide-up cancel and
387
+ Escape call `POST /stream/cancel` and insert nothing. If open/chunk fails mid-recording the
388
+ relay is abandoned and the take is transcribed as one WAV from the buffered PCM at release
389
+ (the overlay tells the user), so a relay fault never loses the recording.
390
+ - Keyboard shortcut: a configured `code`+modifier combination starts the same hold flow; keyup
391
+ releases, Escape cancels. It only fires while the composer exists and focus is not inside a
392
+ different input/textarea (so settings forms keep typing normally).
393
+ - The flight animation is DOM-only: a `.bvi-flight` clone of the final line is pinned over the
394
+ overlay, transformed to the composer input's `getBoundingClientRect()` (~360 ms
395
+ `cubic-bezier(.2,.8,.2,1)`, opacity/scale), then the real insertion happens. `prefers-reduced-
396
+ motion` skips the animation.
397
+
398
+ ### Settings page layout (v0.2)
399
+
400
+ Cloud and local sections are **master-detail**: a compact list of providers/models (name,
401
+ configured/install badge, chevron) and only the selected entry renders its detail card (fields,
402
+ env hint, docs, save; variant, estimate, download/cancel/progress). Selecting a row is local
403
+ component state; the first selection defaults to the current `selection.providerId` (cloud) and
404
+ the first installed local model (local); an empty catalog shows a hint instead of a card. The
405
+ summary view stays a flat two-line overview. No API change is needed for this layout.
406
+
407
+ ### OpenAI-compatible endpoints and optional credentials
408
+
409
+ `bvi-cloud-openai` is the OpenAI **and** OpenAI-compatible entry: `baseURL` and `model` are
410
+ editable and `apiKey` is optional, so a self-hosted gateway (for example an X-ASR model exposed
411
+ through an OpenAI-compatible `/v1/audio/transcriptions` server) works with an empty key. The
412
+ adapter omits the `Authorization` header when the key is empty. In `/state`, `configured` means
413
+ "every required field is filled" for vendors with required fields; a vendor with no required
414
+ field (OpenAI-compatible) is configured once any effective value exists, so a key-less
415
+ self-hosted setup is not reported as unconfigured. CI proves this end-to-end with
416
+ the `openai-compat-smoke` workflow: it downloads the pinned X-ASR model, serves it through a
417
+ local OpenAI-compatible endpoint, runs the real cloud adapter with `apiKey: ''`, and asserts the
418
+ transcript (and that no authorization header was sent).
419
+
283
420
  ## Testing seams
284
421
 
285
422
  Every module is testable without native dependencies and without a host process:
package/docs/DETAIL.md CHANGED
@@ -15,7 +15,9 @@ The official bundle ships one host-local model. This bundle registers **21 servi
15
15
  - **14 cloud providers** — SiliconFlow, Volcengine, ElevenLabs, OpenAI, OpenRouter, DashScope,
16
16
  DeepSeek, Gemini, Xiaomi MiMo, Tencent Cloud, Soniox, StepAudio, Zhipu and Cohere. Each has its
17
17
  own form for API key, base URL, model and vendor options; environment variables work as a
18
- read-only fallback.
18
+ read-only fallback. The OpenAI entry doubles as an **OpenAI-compatible** endpoint (any base URL
19
+ and model name, and an empty API key), so a self-hosted model exposed through
20
+ `/v1/audio/transcriptions` can be selected directly.
19
21
  - **7 local model families** — SenseVoice, FunASR Nano, Qwen3-ASR, Parakeet, GigaAM, FireRedASR
20
22
  and X-ASR, each with selectable variants. They run on this machine through `sherpa-onnx-node`,
21
23
  downloaded on first use into `$DSH_HOME/better-voice-input/models` and verified file by file
@@ -34,19 +36,36 @@ The official voice UI is click-to-record. This bundle reproduces the DeepSeek Ap
34
36
  - **Slide up to cancel.** The overlay turns from blue to red once you pass the cancel distance;
35
37
  release there to discard the recording. Release anywhere else to transcribe. A small dead band
36
38
  prevents accidental cancel/send toggling.
39
+ - **Live streaming text.** With a streaming model (local X-ASR) the cumulative transcript appears
40
+ above the overlay while you speak, then a smooth fly-to-composer animation moves the final line
41
+ into the input. The live display can be turned off in settings; providers without streaming keep
42
+ the batch behavior. Requires `AudioWorklet`; the plugin quietly falls back to whole-recording
43
+ recognition otherwise.
37
44
  - **Release behavior is yours.** By default the transcript is inserted into the draft at the
38
45
  caret; a setting switches release to *send*.
39
46
  - **The composer hint reads “发消息或按住说话”** when the draft is empty, and the overlay wording
40
47
  follows the release behavior (“松手插入,上滑取消” / “松手发送,上滑取消”).
48
+ - **Keyboard shortcut.** Record a hold-to-talk combination (for example `Ctrl+Shift+Space`) in the
49
+ settings and hold it from the conversation; releasing inserts, `Escape` cancels. It never fires
50
+ while the focus is in another form, so settings inputs keep typing normally.
51
+ - **No keyboard fight on phones.** On touch devices the hold does not start while the caret is in
52
+ the input box and the virtual keyboard is open — previously that pushed the keyboard away and
53
+ shifted the overlay. Dismiss the keyboard and hold to dictate.
41
54
  - Escape, a hidden tab or a lost focus cancels the recording — the microphone never stays open in
42
55
  the background.
43
56
 
57
+ The settings page is master-detail: pick a cloud service or a local model first, and only that
58
+ entry's form appears, so a phone never flattens every field into one long scroll. The interaction
59
+ section decides release behavior, hold delay, cancel distance, the composer hint and live text;
60
+ the shortcut section records the keyboard combination.
61
+
44
62
  Component: **更好的语音输入**.
45
63
 
46
64
  ## Requirements
47
65
 
48
- DeepSeek Harness **>= 0.2.2-rc.5 < 0.3.0** and Node.js **>= 20.19**. The official **Voice input**
49
- bundle must stay enabled — it provides the speech-to-text registry this bundle extends; its own
66
+ DeepSeek Harness **>= 0.2.2-rc.5 < 0.3.0** and Node.js **>= 20.19**. Live streaming needs
67
+ `AudioWorklet` (falls back to batch recognition otherwise); a plain `getUserMedia` browser is
68
+ enough for hold-to-talk. The official **Voice input** bundle must stay enabled — it provides the speech-to-text registry this bundle extends; its own
50
69
  mic UI may be disabled. Cloud providers need the vendor's API key; local models need disk space
51
70
  and a CPU (no GPU required).
52
71
 
package/docs/DETAIL.zh.md CHANGED
@@ -14,7 +14,9 @@
14
14
 
15
15
  - **14 家云端服务** —— 硅基流动、火山引擎、ElevenLabs、OpenAI、OpenRouter、阿里云百炼、
16
16
  DeepSeek、Gemini、小米 MiMo、腾讯云、Soniox、阶跃星辰、智谱、Cohere。每家都有独立表单
17
- (API Key、base URL、model、供应商选项),环境变量可作为只读兜底。
17
+ (API Key、base URL、model、供应商选项),环境变量可作为只读兜底。OpenAI 一项同时是
18
+ **OpenAI 兼容**入口:base URL、模型名都可改,API Key 允许留空,因此把本地模型以
19
+ `/v1/audio/transcriptions` 暴露出来的自部署服务可以直接接入。
18
20
  - **7 个本地模型系列** —— SenseVoice、FunASR Nano、Qwen3-ASR、Parakeet、GigaAM、FireRedASR、
19
21
  X-ASR,每个系列可选不同变体。它们通过 `sherpa-onnx-node` 在本机运行,首次使用时下载到
20
22
  `$DSH_HOME/better-voice-input/models`,逐文件校验固定的 SHA-256;推理在子进程中运行,
@@ -30,11 +32,22 @@
30
32
  - **按住输入框说话**(鼠标、触屏、手写笔共用同一套长按判定)。短暂按住后出现全屏浮层与实时波形。
31
33
  - **上滑取消**:上滑超过取消距离后浮层由蓝变红,此时松手放弃录音;在其他位置松手则开始转写。
32
34
  一段回滞区间避免松手瞬间在「取消/发送」之间抖动。
35
+ - **流式实时文字**:选中支持流式的模型(本地 X-ASR)时,录音过程中累计转写会实时出现在浮层
36
+ 上方;松手后最终文字从屏幕中间平滑飞入输入框。实时显示可在设置里关闭;不支持流式的服务仍
37
+ 走整段识别。需要浏览器支持 `AudioWorklet`,否则自动退回整段识别,功能不受影响。
33
38
  - **松手行为可配置**:默认把识别结果插入草稿光标处;在设置里可改为松手直接发送。
34
39
  - **草稿为空时组合框提示为「发消息或按住说话」**,浮层文案跟随松手行为(
35
40
  「松手插入,上滑取消」/「松手发送,上滑取消」)。
41
+ - **快捷键长按**:在设置里录制一个组合键(例如 `Ctrl+Shift+Space`),在对话里长按它即可开始
42
+ 语音输入;松手插入,`Esc` 取消。焦点在其他表单里时不会触发,设置页输入不受影响。
43
+ - **不与输入法打架**:触屏设备上,光标在输入框且虚拟键盘弹出时,长按输入框不会启动录音
44
+ (此前会把键盘推下去、浮层错位);收起键盘后按住即可说话。
36
45
  - Esc、切到后台标签页、窗口失焦都会取消录音——麦克风不会在后台保持开启。
37
46
 
47
+ 设置页采用「先选模型、再看设置」的两栏结构:先点一个云端服务或本地模型,只展开它自己的表单,
48
+ 手机上不需要在几十个输入框之间长距离滚动。交互区决定松手行为、长按时长、取消距离、输入框提示
49
+ 与实时文字;快捷键区负责录制组合键。
50
+
38
51
  组件:**更好的语音输入**。
39
52
 
40
53
  ## 环境要求
@@ -13,10 +13,12 @@ publishing.
13
13
 
14
14
  - Latest green run on `main`: see the [CI runs](https://github.com/ds-hu/dsh-better-voice-input/actions/workflows/ci.yml).
15
15
  - Test suites: core config store / WAV / HTTP / cloud provider factory, 14 cloud wire-format
16
- adapters against recorded responses, service API and host routes against a fake speech registry,
17
- local catalog / downloads / zip extraction / provider preparation / worker protocol, both
18
- browser entries in a `vm` React harness, plus a cross-component test that holds the
19
- 21-provider, release-order and documentation contracts together.
16
+ adapters against recorded responses, service API, streaming session relay and host routes
17
+ against a fake speech registry, local catalog / downloads / zip extraction / provider
18
+ preparation / worker protocol (including the X-ASR `/stream/*` relay), both browser entries in
19
+ a `vm` React harness (gesture state machine, virtual-keyboard guard, keyboard shortcut, live
20
+ streaming client, fly-to-composer animation degradation), plus a cross-component test that
21
+ holds the 21-provider, release-order and documentation contracts together.
20
22
 
21
23
  ## Local models — real download and inference
22
24
 
@@ -39,20 +41,45 @@ passed** before `v0.1.0`:
39
41
  | firered-asr / ctc-int8 | [47617247666](https://github.com/ds-hu/dsh-better-voice-input/actions/runs/47617247666) | 开放时间早上九点至下午五点 | 2.37 s |
40
42
  | x-asr / x-asr-480ms (streaming) | [47617254289](https://github.com/ds-hu/dsh-better-voice-input/actions/runs/47617254289) | 开放时间早上九点至下午五点 | 1.17 s |
41
43
 
44
+ The X-ASR row above exercised the batch path only. For v0.2 the same workflow also pushes the
45
+ recording through `provider.bviStreaming` in 200 ms chunks (after a cancelled session) and checks
46
+ both the cumulative partial text and the final transcript:
47
+
48
+ | Check | Workflow run | Result |
49
+ | --- | --- | --- |
50
+ | X-ASR batch + live streaming | [47626928831](https://github.com/ds-hu/dsh-better-voice-input/actions/runs/47626928831) | batch “开放时间早上九点至下午五点” (0.75 s inference); streaming produced 8 partial updates and the same final text |
51
+
42
52
  Sample: the 5.59 s Chinese test clip shipped upstream with the SenseVoice model; a fresh cache
43
53
  download was verified file by file against the pinned SHA-256 digests on each run (including the
44
54
  zip-archive sources for `mlt-int8` and `qwen3-1.7b-int8`). The sensevoice run that first exercised
45
55
  the download path also caught a real provisioning bug — a missing `Content-Length` header was
46
56
  treated as zero — which is fixed and covered by a unit test.
47
57
 
58
+ ## OpenAI-compatible endpoint (v0.2)
59
+
60
+ `.github/workflows/openai-compat-smoke.yml` is a manual workflow that proves the
61
+ OpenAI-compatible / self-hosted path end to end, with no vendor account: it prepares the real
62
+ X-ASR model, serves it through a loopback `POST /v1/audio/transcriptions` endpoint, writes a
63
+ temporary config with an **empty API key** and that loopback base URL, then transcribes the sample
64
+ through the real `bvi-cloud-openai` adapter.
65
+
66
+ | Check | Workflow run | Result |
67
+ | --- | --- | --- |
68
+ | OpenAI-compatible, keyless | [47626933281](https://github.com/ds-hu/dsh-better-voice-input/actions/runs/47626933281) | cloud transcript equals the local model output (“开放时间早上九点至下午五点”); server logged `authorization=none`; exactly one request, WAV bytes forwarded unchanged |
69
+
48
70
  ## What is not verified end-to-end
49
71
 
50
72
  - **Cloud vendors** are implemented against their public HTTP APIs but were not called with real
51
- credentials (no vendor account is part of this repository). Wire formats and response parsing are
73
+ credentials (no vendor account is part of this repository). Cloud *streaming* is deliberately
74
+ out of scope: only providers with a native incremental recognizer (local X-ASR) stream live. Wire formats and response parsing are
52
75
  unit-tested against documented response shapes; a live call is the first thing to try when a
53
76
  vendor changes its API.
54
77
  - **The Web GUI integration** (slot rendering, the overlay's real-browser visuals, and the
55
78
  settings page styling) is exercised through a `vm` React harness and the official slot contract,
56
79
  not in a browser session, because this repository does not run browsers in CI.
57
- - **Real audio capture** (microphone → WAV → service) is covered by unit tests of the gesture,
58
- encoder and HTTP layers; it needs a user's browser and microphone to be observed.
80
+ - **Real audio capture** (microphone → WAV/PCM → service) is covered by unit tests of the
81
+ gesture, encoder, streaming client and HTTP layers; it needs a user's browser and microphone to
82
+ be observed. The real X-ASR worker streaming path is verified in CI (above), but the full
83
+ AudioWorklet → service relay → overlay → fly-to-composer chain still needs a GUI session.
84
+ - **Mobile virtual-keyboard behavior** (the v0.2 guard) is unit-tested against `visualViewport`
85
+ states; real iOS/Android keyboard geometry is observed by the user, not by CI.
@@ -44,6 +44,9 @@
44
44
  <rect x="460" y="80" width="360" height="640" rx="26" fill="url(#blueglow)"/>
45
45
  <rect x="460" y="80" width="360" height="640" rx="26" fill="url(#vig)"/>
46
46
  <text x="640" y="322" fill="#cfe6ff" font-size="25" text-anchor="middle" font-family="Source Serif Pro, Georgia, serif" letter-spacing="3">Release to insert · slide up to cancel</text>
47
+ <text x="640" y="356" fill="#9fc8ff" font-size="12" letter-spacing="2" text-anchor="middle" font-family="-apple-system, Segoe UI, sans-serif">LIVE TRANSCRIPT</text>
48
+ <text x="640" y="392" fill="#eef5ff" font-size="20" text-anchor="middle" font-family="Songti SC, Noto Serif SC, serif">Let's move today's meeting to 3 p.m.</text>
49
+ <text x="640" y="422" fill="#eef5ff" font-size="20" text-anchor="middle" font-family="Songti SC, Noto Serif SC, serif" opacity=".9">Bring the design doc with you.</text>
47
50
  <rect x="491.0" y="466.0" width="4" height="8.0" rx="2" fill="#dde8ff" opacity="0.55" style="filter:drop-shadow(0 0 6px #9fc8ff)"/>
48
51
  <rect x="505.0" y="463.8" width="4" height="12.3" rx="2" fill="#dde8ff" opacity="0.69" style="filter:drop-shadow(0 0 6px #9fc8ff)"/>
49
52
  <rect x="519.0" y="461.5" width="4" height="16.9" rx="2" fill="#dde8ff" opacity="0.77" style="filter:drop-shadow(0 0 6px #9fc8ff)"/>
@@ -93,5 +96,5 @@
93
96
  <rect x="1177.0" y="462.1" width="4" height="15.7" rx="2" fill="#e06770" opacity="0.77" style="filter:drop-shadow(0 0 6px #ff5f69)"/>
94
97
  <rect x="1191.0" y="462.5" width="4" height="14.9" rx="2" fill="#e06770" opacity="0.69" style="filter:drop-shadow(0 0 6px #ff5f69)"/>
95
98
  <rect x="1205.0" y="466.0" width="4" height="8.0" rx="2" fill="#e06770" opacity="0.55" style="filter:drop-shadow(0 0 6px #ff5f69)"/>
96
- <text x="640" y="770" fill="#6f7688" font-size="14" font-family="-apple-system, Segoe UI, sans-serif" text-anchor="middle">Hold the composer to talk: the overlay mirrors the DeepSeek App. Insert-draft is the default release action; send is one setting away.</text>
99
+ <text x="640" y="770" fill="#6f7688" font-size="14" font-family="-apple-system, Segoe UI, sans-serif" text-anchor="middle">Hold the composer: the transcript streams in live and flies into the input on release. Insert draft by default; send is a setting.</text>
97
100
  </svg>
@@ -0,0 +1,69 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1280" height="1000" viewBox="0 0 1280 1000">
2
+ <rect width="1280" height="1000" fill="#0e1014"/>
3
+ <text x="640" y="46" fill="#e8ecf6" font-size="24" text-anchor="middle" font-family="Songti SC, Noto Serif SC, serif">Settings · pick a model first, then edit it</text>
4
+ <text x="60" y="104" fill="#dfe4ee" font-size="19" font-family="Songti SC, Noto Serif SC, serif">Cloud services</text>
5
+ <text x="300" y="104" fill="#6f7688" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Pick one; only its settings expand</text>
6
+ <rect x="60" y="120" width="400" height="300" rx="16" fill="#16181d" stroke="#282c34"/>
7
+ <rect x="76" y="136" width="368" height="62" rx="12" fill="#182231" stroke="#4f7fd6"/>
8
+ <text x="94" y="162" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">火山引擎 Volcengine</text>
9
+ <text x="94" y="183" fill="#6fae7d" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Configured</text>
10
+ <text x="424" y="174" fill="#8fb6ff" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
11
+ <rect x="76" y="206" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
12
+ <text x="94" y="232" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">阿里云百炼 DashScope</text>
13
+ <text x="424" y="244" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
14
+ <rect x="76" y="276" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
15
+ <text x="94" y="302" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">OpenAI / OpenAI 兼容</text>
16
+ <text x="424" y="314" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
17
+ <rect x="76" y="346" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
18
+ <text x="94" y="372" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">SiliconFlow 硅基流动</text>
19
+ <text x="424" y="384" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
20
+ <rect x="484" y="120" width="736" height="300" rx="16" fill="#16181d" stroke="#4f7fd6"/>
21
+ <text x="510" y="156" fill="#eef2fb" font-size="19" font-family="Songti SC, Noto Serif SC, serif">火山引擎 Volcengine</text>
22
+ <rect x="1080" y="137" width="112" height="26" rx="13" fill="#1b2a22" stroke="#2f5d40"/><text x="1136" y="155" fill="#7fc48f" font-size="12" text-anchor="middle" font-family="-apple-system, Segoe UI, sans-serif">已配置</text>
23
+ <text x="510" y="196" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">API Key</text>
24
+ <rect x="510" y="206" width="600" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/>
25
+ <text x="526" y="230" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Stored sk-…3f2a · leave blank to keep</text>
26
+ <text x="510" y="266" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Base URL</text>
27
+ <rect x="510" y="276" width="600" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/>
28
+ <text x="526" y="300" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">https://ark.cn-beijing.volces.com/api/v3</text>
29
+ <text x="510" y="336" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">资源 ID / model</text>
30
+ <rect x="510" y="346" width="600" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/>
31
+ <text x="526" y="370" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">volc.bigasr.auc_turbo</text>
32
+ <text x="510" y="400" fill="#6f7688" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Env fallback VOLCENGINE_API_KEY (read-only; saved value wins)</text>
33
+ <a href="https://www.volcengine.com/docs/6561/1354869" target="_blank"><text x="1096" y="400" fill="#7ea6ee" font-size="12" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">API docs</text></a>
34
+ <rect x="510" y="352" width="136" height="34" rx="9" fill="#2563c9"/><text x="578" y="374" fill="#fff" font-size="13" text-anchor="middle" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Save this service</text>
35
+ <text x="60" y="466" fill="#dfe4ee" font-size="19" font-family="Songti SC, Noto Serif SC, serif">Local models</text>
36
+ <text x="300" y="466" fill="#6f7688" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Runs offline once downloaded; audio stays on this machine</text>
37
+ <rect x="60" y="482" width="400" height="236" rx="16" fill="#16181d" stroke="#282c34"/>
38
+ <rect x="76" y="498" width="368" height="62" rx="12" fill="#182231" stroke="#4f7fd6"/>
39
+ <text x="94" y="524" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">SenseVoice</text>
40
+ <text x="94" y="545" fill="#7fc48f" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">small int8 · Ready</text>
41
+ <text x="424" y="536" fill="#8fb6ff" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
42
+ <rect x="76" y="568" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
43
+ <text x="94" y="594" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Qwen3-ASR</text>
44
+ <text x="94" y="615" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">0.6B int8 · Not downloaded</text>
45
+ <text x="424" y="606" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
46
+ <rect x="76" y="638" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
47
+ <text x="94" y="664" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">X-ASR</text>
48
+ <text x="94" y="685" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">streaming 480 ms · Not downloaded</text>
49
+ <text x="424" y="676" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
50
+ <rect x="484" y="482" width="736" height="236" rx="16" fill="#16181d" stroke="#4f7fd6"/>
51
+ <text x="510" y="518" fill="#eef2fb" font-size="19" font-family="Songti SC, Noto Serif SC, serif">SenseVoice · small int8</text>
52
+ <text x="510" y="548" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">~239 MB · est. 480 MB disk / 1.2 GB memory</text>
53
+ <rect x="510" y="566" width="360" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/><text x="526" y="590" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, sans-serif">small int8 · 239 MB ▾</text>
54
+ <rect x="890" y="566" width="306" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/><text x="906" y="590" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, sans-serif">Hugging Face ▾</text>
55
+ <rect x="510" y="622" width="686" height="8" rx="4" fill="#232830"/><rect x="510" y="622" width="686" height="8" rx="4" fill="#3d8f57"/>
56
+ <text x="510" y="662" fill="#7fc48f" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Ready to use</text>
57
+ <text x="1078" y="662" fill="#7ea6ee" font-size="13" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Delete and redownload</text>
58
+ <text x="60" y="770" fill="#dfe4ee" font-size="19" font-family="Songti SC, Noto Serif SC, serif">Interaction and shortcut</text>
59
+ <rect x="60" y="786" width="1160" height="150" rx="16" fill="#16181d" stroke="#282c34"/>
60
+ <text x="90" y="824" fill="#aab2c2" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">On release [Insert draft] [Send]</text>
61
+ <text x="90" y="858" fill="#aab2c2" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Live transcript for streaming models [on]</text>
62
+ <text x="90" y="900" fill="#aab2c2" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Hold-to-talk shortcut</text>
63
+ <rect x="220" y="884" width="240" height="34" rx="9" fill="#182231" stroke="#4f7fd6"/><text x="340" y="906" fill="#cfe0ff" font-size="13" text-anchor="middle" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Ctrl + Shift + Space</text>
64
+ <rect x="474" y="884" width="96" height="34" rx="9" fill="#2563c9"/><text x="522" y="906" fill="#fff" font-size="13" text-anchor="middle" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">录制</text>
65
+ <rect x="582" y="884" width="96" height="34" rx="9" fill="#23272f"/><text x="630" y="906" fill="#aab2c2" font-size="13" text-anchor="middle" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">清除</text>
66
+ <text x="700" y="906" fill="#6f7688" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Press “Record”, then press the combination; Esc cancels</text>
67
+ <text x="60" y="968" fill="#6f7688" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Stored only in the local config.json (0600); the UI never shows a full secret.</text>
68
+ <text x="60" y="988" fill="#6f7688" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Local models are verified file by file; keep the official voice input bundle enabled.</text>
69
+ </svg>
@@ -0,0 +1,69 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1280" height="1000" viewBox="0 0 1280 1000">
2
+ <rect width="1280" height="1000" fill="#0e1014"/>
3
+ <text x="640" y="46" fill="#e8ecf6" font-size="24" text-anchor="middle" font-family="Songti SC, Noto Serif SC, serif">设置 · 先选模型,再改设置</text>
4
+ <text x="60" y="104" fill="#dfe4ee" font-size="19" font-family="Songti SC, Noto Serif SC, serif">云端识别服务</text>
5
+ <text x="300" y="104" fill="#6f7688" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">点一个服务,只展开它的设置项</text>
6
+ <rect x="60" y="120" width="400" height="300" rx="16" fill="#16181d" stroke="#282c34"/>
7
+ <rect x="76" y="136" width="368" height="62" rx="12" fill="#182231" stroke="#4f7fd6"/>
8
+ <text x="94" y="162" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">火山引擎 Volcengine</text>
9
+ <text x="94" y="183" fill="#6fae7d" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">已配置</text>
10
+ <text x="424" y="174" fill="#8fb6ff" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
11
+ <rect x="76" y="206" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
12
+ <text x="94" y="232" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">阿里云百炼 DashScope</text>
13
+ <text x="424" y="244" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
14
+ <rect x="76" y="276" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
15
+ <text x="94" y="302" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">OpenAI / OpenAI 兼容</text>
16
+ <text x="424" y="314" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
17
+ <rect x="76" y="346" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
18
+ <text x="94" y="372" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">SiliconFlow 硅基流动</text>
19
+ <text x="424" y="384" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
20
+ <rect x="484" y="120" width="736" height="300" rx="16" fill="#16181d" stroke="#4f7fd6"/>
21
+ <text x="510" y="156" fill="#eef2fb" font-size="19" font-family="Songti SC, Noto Serif SC, serif">火山引擎 Volcengine</text>
22
+ <rect x="1080" y="137" width="112" height="26" rx="13" fill="#1b2a22" stroke="#2f5d40"/><text x="1136" y="155" fill="#7fc48f" font-size="12" text-anchor="middle" font-family="-apple-system, Segoe UI, sans-serif">已配置</text>
23
+ <text x="510" y="196" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">API Key</text>
24
+ <rect x="510" y="206" width="600" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/>
25
+ <text x="526" y="230" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">已保存 sk-…3f2a · 留空则不修改</text>
26
+ <text x="510" y="266" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Base URL</text>
27
+ <rect x="510" y="276" width="600" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/>
28
+ <text x="526" y="300" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">https://ark.cn-beijing.volces.com/api/v3</text>
29
+ <text x="510" y="336" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">资源 ID / model</text>
30
+ <rect x="510" y="346" width="600" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/>
31
+ <text x="526" y="370" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">volc.bigasr.auc_turbo</text>
32
+ <text x="510" y="400" fill="#6f7688" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">也可用环境变量 VOLCENGINE_API_KEY(只读,保存值优先)</text>
33
+ <a href="https://www.volcengine.com/docs/6561/1354869" target="_blank"><text x="1096" y="400" fill="#7ea6ee" font-size="12" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">接口文档</text></a>
34
+ <rect x="510" y="352" width="136" height="34" rx="9" fill="#2563c9"/><text x="578" y="374" fill="#fff" font-size="13" text-anchor="middle" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">保存此服务</text>
35
+ <text x="60" y="466" fill="#dfe4ee" font-size="19" font-family="Songti SC, Noto Serif SC, serif">本地识别模型</text>
36
+ <text x="300" y="466" fill="#6f7688" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">下载后离线运行,音频不出本机</text>
37
+ <rect x="60" y="482" width="400" height="236" rx="16" fill="#16181d" stroke="#282c34"/>
38
+ <rect x="76" y="498" width="368" height="62" rx="12" fill="#182231" stroke="#4f7fd6"/>
39
+ <text x="94" y="524" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">SenseVoice</text>
40
+ <text x="94" y="545" fill="#7fc48f" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">small int8 · 已就绪</text>
41
+ <text x="424" y="536" fill="#8fb6ff" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
42
+ <rect x="76" y="568" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
43
+ <text x="94" y="594" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Qwen3-ASR</text>
44
+ <text x="94" y="615" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">0.6B int8 · 未下载</text>
45
+ <text x="424" y="606" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
46
+ <rect x="76" y="638" width="368" height="62" rx="12" fill="#1a1d23" stroke="#262a32"/>
47
+ <text x="94" y="664" fill="#e7ebf4" font-size="15" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">X-ASR</text>
48
+ <text x="94" y="685" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">流式 480 ms · 未下载</text>
49
+ <text x="424" y="676" fill="#555c6b" font-size="16" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">›</text>
50
+ <rect x="484" y="482" width="736" height="236" rx="16" fill="#16181d" stroke="#4f7fd6"/>
51
+ <text x="510" y="518" fill="#eef2fb" font-size="19" font-family="Songti SC, Noto Serif SC, serif">SenseVoice · small int8</text>
52
+ <text x="510" y="548" fill="#8f96a6" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">约 239 MB · 预计磁盘 480 MB / 内存 1.2 GB</text>
53
+ <rect x="510" y="566" width="360" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/><text x="526" y="590" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, sans-serif">small int8 · 239 MB ▾</text>
54
+ <rect x="890" y="566" width="306" height="38" rx="10" fill="#1d2027" stroke="#2c313a"/><text x="906" y="590" fill="#c9d1e0" font-size="13" font-family="-apple-system, Segoe UI, sans-serif">Hugging Face ▾</text>
55
+ <rect x="510" y="622" width="686" height="8" rx="4" fill="#232830"/><rect x="510" y="622" width="686" height="8" rx="4" fill="#3d8f57"/>
56
+ <text x="510" y="662" fill="#7fc48f" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">已就绪,可直接使用</text>
57
+ <text x="1078" y="662" fill="#7ea6ee" font-size="13" text-anchor="end" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">删除并重新下载</text>
58
+ <text x="60" y="770" fill="#dfe4ee" font-size="19" font-family="Songti SC, Noto Serif SC, serif">交互与快捷键</text>
59
+ <rect x="60" y="786" width="1160" height="150" rx="16" fill="#16181d" stroke="#282c34"/>
60
+ <text x="90" y="824" fill="#aab2c2" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">松手后 [插入草稿] [直接发送]</text>
61
+ <text x="90" y="858" fill="#aab2c2" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">实时显示识别文字(流式模型) [开]</text>
62
+ <text x="90" y="900" fill="#aab2c2" font-size="13" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">快捷键长按说话</text>
63
+ <rect x="220" y="884" width="240" height="34" rx="9" fill="#182231" stroke="#4f7fd6"/><text x="340" y="906" fill="#cfe0ff" font-size="13" text-anchor="middle" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">Ctrl + Shift + Space</text>
64
+ <rect x="474" y="884" width="96" height="34" rx="9" fill="#2563c9"/><text x="522" y="906" fill="#fff" font-size="13" text-anchor="middle" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">录制</text>
65
+ <rect x="582" y="884" width="96" height="34" rx="9" fill="#23272f"/><text x="630" y="906" fill="#aab2c2" font-size="13" text-anchor="middle" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">清除</text>
66
+ <text x="700" y="906" fill="#6f7688" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">点“录制”后按下组合键;Esc 取消</text>
67
+ <text x="60" y="968" fill="#6f7688" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">只保存到本机 config.json(0600),界面永远只显示掩码。</text>
68
+ <text x="60" y="988" fill="#6f7688" font-size="12" font-family="-apple-system, Segoe UI, 'Noto Sans SC', sans-serif">本地模型逐文件 sha256 校验;官方语音输入插件保持启用。</text>
69
+ </svg>
package/docs/preview.svg CHANGED
@@ -44,6 +44,9 @@
44
44
  <rect x="460" y="80" width="360" height="640" rx="26" fill="url(#blueglow)"/>
45
45
  <rect x="460" y="80" width="360" height="640" rx="26" fill="url(#vig)"/>
46
46
  <text x="640" y="322" fill="#cfe6ff" font-size="25" text-anchor="middle" font-family="Songti SC, Noto Serif SC, serif" letter-spacing="3">松手插入,上滑取消</text>
47
+ <text x="640" y="356" fill="#9fc8ff" font-size="12" letter-spacing="2" text-anchor="middle" font-family="-apple-system, Segoe UI, sans-serif">实时转写</text>
48
+ <text x="640" y="392" fill="#eef5ff" font-size="20" text-anchor="middle" font-family="Songti SC, Noto Serif SC, serif">今天的会议改到下午三点。</text>
49
+ <text x="640" y="422" fill="#eef5ff" font-size="20" text-anchor="middle" font-family="Songti SC, Noto Serif SC, serif" opacity=".9">记得带上那份设计稿。</text>
47
50
  <rect x="491.0" y="466.0" width="4" height="8.0" rx="2" fill="#dde8ff" opacity="0.55" style="filter:drop-shadow(0 0 6px #9fc8ff)"/>
48
51
  <rect x="505.0" y="463.8" width="4" height="12.3" rx="2" fill="#dde8ff" opacity="0.69" style="filter:drop-shadow(0 0 6px #9fc8ff)"/>
49
52
  <rect x="519.0" y="461.5" width="4" height="16.9" rx="2" fill="#dde8ff" opacity="0.77" style="filter:drop-shadow(0 0 6px #9fc8ff)"/>
@@ -93,5 +96,5 @@
93
96
  <rect x="1177.0" y="462.1" width="4" height="15.7" rx="2" fill="#e06770" opacity="0.77" style="filter:drop-shadow(0 0 6px #ff5f69)"/>
94
97
  <rect x="1191.0" y="462.5" width="4" height="14.9" rx="2" fill="#e06770" opacity="0.69" style="filter:drop-shadow(0 0 6px #ff5f69)"/>
95
98
  <rect x="1205.0" y="466.0" width="4" height="8.0" rx="2" fill="#e06770" opacity="0.55" style="filter:drop-shadow(0 0 6px #ff5f69)"/>
96
- <text x="640" y="770" fill="#6f7688" font-size="14" font-family="-apple-system, Segoe UI, sans-serif" text-anchor="middle">按住输入框说话:全屏浮层与 DeepSeek App 一致;默认松手插入草稿,可在设置中改为松手发送。</text>
99
+ <text x="640" y="770" fill="#6f7688" font-size="14" font-family="-apple-system, Segoe UI, sans-serif" text-anchor="middle">按住输入框说话:录音时实时显示转写,松手后文字飞入输入框;默认插入草稿,可在设置中改为发送。</text>
97
100
  </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ds-hu/dsh-better-voice-input",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Better voice input for the DeepSeek Harness Web GUI: 21 speech-recognition models on the official experimental speech-to-text seam (14 cloud APIs + 7 downloadable sherpa-onnx local models) and a DeepSeek-App-style hold-to-talk composer — long-press to talk, release to insert, slide up to cancel.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -27,11 +27,11 @@
27
27
  "dsh": ">=0.2.2-rc.5 <0.3.0"
28
28
  },
29
29
  "dependencies": {
30
- "@ds-hu/dsh-bvi-core": "0.1.0",
31
- "@ds-hu/dsh-bvi-service": "0.1.0",
32
- "@ds-hu/dsh-bvi-cloud": "0.1.0",
33
- "@ds-hu/dsh-bvi-local": "0.1.0",
34
- "@ds-hu/dsh-bvi-input": "0.1.0"
30
+ "@ds-hu/dsh-bvi-core": "0.2.0",
31
+ "@ds-hu/dsh-bvi-service": "0.2.0",
32
+ "@ds-hu/dsh-bvi-cloud": "0.2.0",
33
+ "@ds-hu/dsh-bvi-local": "0.2.0",
34
+ "@ds-hu/dsh-bvi-input": "0.2.0"
35
35
  },
36
36
  "repository": {
37
37
  "type": "git",
@@ -67,6 +67,8 @@
67
67
  "docs/VERIFICATION.md",
68
68
  "docs/preview.svg",
69
69
  "docs/preview-en.svg",
70
+ "docs/preview-settings.svg",
71
+ "docs/preview-settings-en.svg",
70
72
  "LICENSE",
71
73
  "NOTICE",
72
74
  "README.en.md"