dsh-voice:给 DeepSeek Harness 增加全双工语音模式

前言

DSH 的理念是「一切皆插件」。这里提到的社区目录是独立站点,不与 DeepSeek / 幻方构成官方从属关系。

对 DSH 的 web 客户端来说,文字输入之外还有一个具体需求:说话时能看到实时字幕,助手回复时也能被打断。haoku123/dsh-voice 提供的就是这种语音模式。

这是什么

haoku123/dsh-voicehaoku123 维护,许可证为 MIT。它的定位是 DeepSeek Harness 的全双工语音模式:streamed ASR → LLM → TTS with barge-in

浏览器侧负责录制并发送 raw little-endian f32 PCM,host 侧运行 ASR 和 TTS。DSH 的 web client 会注入:

  • @deepseek-ai/dsh-client-runtime
  • @deepseek-ai/dsh-client-ui-slots

核心功能

下面介绍几个和实际使用最相关的点。

语音链路

先做采集,再做识别,然后提交模型,最后把回复读出来:

  1. 浏览器录制语音,得到 raw little-endian f32 PCM。
  2. 识别交给 host 侧的 SenseVoice,通过 sherpa-onnx 运行;输出包含 native simplified-Chinese output、punctuation 和 inverse text normalization(ITN)。
  3. 模型响应经过 llm/stream tap。这个 tap 是 lossless 的:chunks yielded unchanged,sentence segmenter 只观察。
  4. TTS 使用 msedge-tts,以 SSE audio frames 和 caption text 的形式流式回传。

三种说话方式

插件提供三种 dictation gestures:

手势 行为
tap the mic continuous dictation;VAD segments on trailing silence
hold the send key(or the mic) records until release;slide up to discard
hold Ctrl(可配置 asr.hotkey press-to-talk without leaving the keyboard;Esc discards

如果走 press-to-talk,它 bypasses VAD;短于 250ms 的 capture 会被当作 mis-taps 丢弃。

实时字幕

按住麦克风或 send key 时,overlay 显示 live caption:interim transcript preview,并保留 spinner until final transcript lands。

这里有一个边界:SenseVoice 不是 streaming model。live caption 的 interims 只是 previews only,超过 12s 音频会停止,并且如果 interim 在释放后才落地,会被丢弃,避免覆盖 final transcript。

Barge-in 与回声抵消

barge-in 由 leading speech edge 触发。触发后:

  • stops local playback;
  • drops queued and in-flight host TTS synthesis;
  • cancels running turn。

回声抵消使用 NLMS acoustic echo canceller,以 page TTS playback 作为 echo reference。

端点检测与模型缓存

端点检测使用 RMS endpoint detection:16kHz getUserMedia,2s trailing-silence cutoff,max 30s segment,并带 pre/post padding。

模型文件通过 cache-through HF model proxy 获取,支持从 partial .part files resume。可以用 npm run prefetch 做一次 warm-up。

modelHost 接受任意 HF-compatible mirror,例如:

https://hf-mirror.com

安装与启用

先确认环境满足要求:需要 Node ≥ 22.19 或 ≥ 24,因为用到 node:zlib 的 zstd APIs。

然后按插件安装命令启用:

dsh plugin --profile web add <repo-url-or-path>
dsh --profile web

上面的 <repo-url-or-path> 是占位符,需要按仓库实际提供的安装参数替换。

与本文相关的主要配置项示例:

asr:
  hotkey: Control
  modelHost: https://hf-mirror.com

peer dependencies 包括:

  • @deepseek-ai/cordis ^4.0.1
  • @deepseek-ai/dsh-web ^0.1.0-rc.6
  • react ^18.2.0

典型用法

先预热模型缓存:

npm run prefetch

该命令默认使用:

http://127.0.0.1:3080

然后按场景选择输入方式:

  1. tap the mic:continuous dictation,VAD 按 trailing silence 分段。
  2. hold the send key 或 hold the mic:录制到松开为止;slide up 可以丢弃。
  3. hold Ctrl:不离开键盘做 press-to-talk;按 Esc 丢弃。

经过上面的步骤,语音会被识别、提交,并作为带 caption 的音频回复流式播放。

适用场景与注意

适合在 DSH web 客户端中使用语音输入,尤其是需要中文识别输出、实时字幕、流式 TTS,以及希望助手播放过程中可以被打断的场景。

使用注意:

  • SenseVoice 不是 streaming model;live caption 的 interim 只是预览,不能视为最终识别稿。
  • live caption 超过 12s 音频会停止;release 后到达的 interim 会被丢弃。
  • press-to-talk 不走 VAD;短于 250ms 的 capture 会被丢弃。
  • RMS endpoint detection 有 16kHz、2s trailing-silence cutoff 和 max 30s segment 这些参数。
  • 插件需要 Node ≥ 22.19 或 ≥ 24。
  • 插件以当前 dsh 进程权限运行;安装前应检查源码与 MIT 许可证。

链接

  • GitHub:https://github.com/haoku123/dsh-voice
  • 目录页(来源为插件线索):https://www.skillhub.cn/plugins/haoku123/dsh-voice
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye