tangbut1/dsh-plugin-voice-input ↗★ 0
dsh-plugin-voice-input
DeepSeek Harness Web 语音输入插件:按住说话的麦克风按钮 + 本机离线 sherpa-onnx SenseVoice ASR
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:tangbut1/dsh-plugin-voice-input说明文档
阅读完整 README ↗dsh-plugin-voice-input
DeepSeek Harness Web 语音输入插件:在输入框发送键同一行、靠发送键左侧加一个「按住说话」麦克风按钮。松手后语音在本机离线转成文字并追加到当前草稿,不自动发送。模型免费、离线,中文/英文/中英夹杂(以及日/韩/粤)均可识别。
Voice input plugin for the DeepSeek Harness Web UI: hold the mic button next to the send key to talk; on release the audio is transcribed by a local offline ASR engine and appended to the draft. It never auto-sends. Free, offline, zh/en mixed supported.
架构
双端插件(一个包,两个半边):
| 半边 | 位置 | 职责 |
|---|---|---|
| 主机 half | src/index.ts → lib/index.js | 极简 HTTP 服务,只监听 127.0.0.1:18765;sherpa-onnx + SenseVoice-Small INT8 离线识别;模型缺失时自动下载 |
| 浏览器 half | src/client/index.ts → lib/client.js | 麦克风按钮(官方 slot conversation.input.right);MediaRecorder 16 kHz 单声道录音;WAV 编码后 POST 到本机 ASR;用官方事件把文本追加进草稿 |
- 按钮挂在官方 slot
conversation.input.right(发送键左侧同一行),不替换 composer、不动发送键。 - 识别结果通过官方 scoped 事件
slash/input-insert-text(payload{ text, span },span 带draftRevCAS)追加到草稿末尾;草稿非空时前面补一个空格。 - 不调用未公开的 setDraft、不改 textarea DOM、不自动发送。
- ASR 引擎:
sherpa-onnx-node(npm 包,含 Windows x64 预编译二进制)+ 模型sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2024-07-17(INT8,model.int8.onnx≈ 228 MB,压缩包 ≈ 229 MB)。 - 不用 Web Speech API(会上传音频且国内不稳定);音频只发到本机回环地址。
安装与构建
cd D:\dsh\dsh-plugin-voice-input
npm install # 安装 sherpa-onnx-node 原生扩展 + 构建工具(一次性)
npm run build # 产出 lib/index.js(主机半边)和 lib/client.js(浏览器半边)
npm run typecheck # 可选
启动方式
方式 A:--patch(只验证主机半边 ASR 服务)
浏览器半边需要行名是可解析的包名(client-modules 会读 /package.json),--patch 里放文件路径只能加载主机半边:
dsh web --patch D:\dsh\dsh-plugin-voice-input\cordis.dev.yml
# 验证服务:
Invoke-RestMethod http://127.0.0.1:18765/health
方式 B:dsh plugin add(完整 UI,推荐)
dsh plugin --profile web add D:\dsh\dsh-plugin-voice-input
# 重启 dsh web(插件集在启动时读取)
dsh web --port 3080
打开 http://127.0.0.1:3080,发送键旁应出现麦克风按钮。卸载:
dsh plugin --profile web remove dsh-plugin-voice-input