前言¶
DSH 的理念是「一切皆插件」。這裏提到的社區目錄是獨立站點,不與 DeepSeek / 幻方構成官方從屬關係。
對 DSH 的 web 客戶端來說,文字輸入之外還有一個具體需求:說話時能看到即時字幕,助手回覆時也能被打斷。haoku123/dsh-voice 提供的就是這種語音模式。
這是什麼¶
haoku123/dsh-voice 由 haoku123 維護,許可證爲 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
核心功能¶
下面介紹幾個和實際使用最相關的點。
語音鏈路¶
先做採集,再做識別,然後提交模型,最後把回覆讀出來:
- 瀏覽器錄製語音,得到 raw little-endian f32 PCM。
- 識別交給 host 側的
SenseVoice,通過sherpa-onnx運行;輸出包含 native simplified-Chinese output、punctuation 和 inverse text normalization(ITN)。 - 模型響應經過
llm/streamtap。這個 tap 是 lossless 的:chunks yielded unchanged,sentence segmenter 只觀察。 - 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.6react ^18.2.0
典型用法¶
先預熱模型緩存:
npm run prefetch
該命令默認使用:
http://127.0.0.1:3080
然後按場景選擇輸入方式:
- tap the mic:continuous dictation,VAD 按 trailing silence 分段。
- hold the send key 或 hold the mic:錄製到鬆開爲止;slide up 可以丟棄。
- 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