@fslong/dsh-voice
v0.1.1
Published
DSH 语音插件(参考 vokie):点击🎤或按 F2 口喷→ASR 识别→口语润色→识别文本实时入聊天框,确认后发送。双引擎:浏览器 Web Speech API(默认)/ 本地 faster-whisper(离线质量优,状态条可切)。
Maintainers
Readme
dsh-voice
dsh(DeepSeek Harness)语音插件——语音指挥 AI 干活。参考 vokie:说话是最自然的表达,想说就说,直接喷给 Agent。
功能
双操作(行为一致):
- 点击 🎤 / 按 F2:第一次按下开始录音,再按一次停止——识别全程实时写入聊天输入框(所见即所得),停止后润色定型,检查后回车发送。手机、键盘皆可。
双引擎识别:
- 浏览器 Web Speech API(默认):零安装、零后端、Chrome/Edge 即用,流式实时。
- 本地 faster-whisper(可选):离线、隐私、中文质量高;在状态条切换。整句后出(非流式),长音频转写较慢。
实时反馈:录音中状态条计时(聆听中 Ns)+ 识别文本实时入聊天框,用户随时可见"在运行"。
口语润色:去口癖(嗯/呃/那个/就是说)、去重字、标点规整、句末补齐——保守整理,尊重语义。
识别回读(可选):localStorage['dsh-voice.readback']='1' 开启后,注入前本地语音合成回读确认。
实时状态条:composer 下方显示聆听计时/识别中/已填入状态与引擎切换。
安装
已发布:npm 安装
# 1. 装进 web profile(自动加依赖 + 应用包内 patch)
cd ~/.dsh/profiles/web
dsh plugin --profile web add @fslong/dsh-voice
# 或手动:pnpm add @fslong/dsh-voice,并 package.json 的 dsh.profile.bundles 加 "@fslong/dsh-voice"
# 2. 重启 dsh web,刷新页面本地开发:file: 链接
cd ~/.dsh/profiles/web
# package.json dependencies 加一行:
# "@fslong/dsh-voice": "file:/home/fslong/Documents/vdsh/dsh-voice"
pnpm install
# cordis.patch.yml 加一行:
# - insert:
# - id: dsh-voice
# name: '@fslong/dsh-voice'
# 重启 dsh web,刷新页面发布(维护者)
cd ~/Documents/vdsh/dsh-voice
npm login # 首次(npmjs.com 注册)
npm publish # prepublishOnly 自动构建 client bundle可选:本地 ASR(paraformer 推荐 / whisper)
# 推荐:FunASR Paraformer——中文识别业界领先、CPU 快、自带 VAD+标点(默认引擎)
python3 -m pip install --user --break-system-packages funasr
# 首次使用自动下载 paraformer-zh + fsmn-vad + ct-punc(ModelScope,国内可达)
# 备选:faster-whisper(多语言通用;whisper 模型经 hf-mirror 镜像)
python3 -m pip install --user --break-system-packages faster-whisperASR 由插件 node 端懒启动子进程(whisper/whisper_server.py,双引擎)。
浏览器录音上传 /api/voice/asr 转写。
环境变量
| 变量 | 默认 | 作用 |
|------|------|------|
| DSH_VOICE_DISABLE | 未设 | 1 关闭本地 ASR,仅 Web Speech API |
| DSH_VOICE_ENGINE | paraformer | 本地引擎:paraformer(FunASR,中文推荐)/ whisper(faster-whisper) |
| DSH_VOICE_MODEL | small | whisper 模型(tiny/base/small/medium/large-v3) |
| DSH_VOICE_WHISPER_PY | 自动 | python3 解释器路径 |
开发
cd dsh-voice
pnpm install # esbuild
node build.mjs # 构建 client bundle → lib/client.js文件为 file: 硬链接进 profile,改源即同步;改 src/client.tsx 后 node build.mjs 重新构建即可。
架构
- node 端(
lib/index.js):whisper 子进程管理 +/api/voice/status、/api/voice/asr路由。 - 浏览器端(
src/client.tsx→lib/client.js):麦克风按钮(conversation.input.left)+ 状态条(conversation.composer.dock);ASR 双引擎;润色;经 frameworkinputActions.setDraft()注入 composer 草稿,确认后由标准发送流程送出。
已知限制
- Web Speech API 仅 Chromium 内核浏览器可用,识别经云端。
- whisper 首启需下载模型;CPU 无 GPU 时 small 实时率约 1–2×(非流式,停后出文)。
