前言¶
DeepSeek Harness(DSH)把识别器放在 speechToText 服务(@deepseek-ai/dsh-experimental-speech-to-text)后面:这是一个命名提供者注册表,由频道在转录前解析。dsh-speech-gate 把一个或多个提供者注册到这个服务,让宿主可以在托管模型、本地 whisper 服务器与本地命令之间选择,而频道不需要知道这些细节。
是什么¶
dsh-speech-gate 是一个 DSH 插件,为 DeepSeek Harness 提供可配置的语音转文本提供者。它支持三种后端:api(OpenAI 兼容接口)、exec(执行本地命令)与 configured-model(复用宿主已有的模型连接器)。插件本身不转码音频:频道已经提供 16 kHz 单声道 PCM16 WAV,这是所有 speechToText 提供者都接受的格式。
核心功能¶
后端类型¶
api:调用POST {baseUrl}/audio/transcriptions(OpenAI 兼容 multipart)。适合托管模型、whisper.cpp --server、faster-whisper-server、whisper-asr-webservice。exec:执行命令,把转录结果输出到 stdout。适合同一台机器上的whisper-cli或faster-whisper。configured-model:调用api,但端点和密钥来自宿主已配置的模型连接器,避免重复输入密钥。适用于已经配置过 OpenAI/Mistral 的宿主。
提供者解析¶
插件通过宿主报告的 llm.listProviders() 决定使用哪个提供者(每次转录一次解析):
- 条目中显式指定
provider; - 否则根据模型族自动推断:
voxtral-*→ mistral,whisper-large-v3*→ groq,gpt-4o*/gpt-4*/whisper*→ openai; - 否则,当宿主只配置了一个已知提供者时,使用该提供者;
- 否则,转录失败并返回候选列表。插件不会猜测,以避免错误地调用错误的凭证。
配置复用¶
configured-model 后端使用以下映射(端点与凭证名称):
| provider | endpoint | credential |
|---|---|---|
openai |
https://api.openai.com/v1 |
OPENAI_API_KEY |
mistral |
https://api.mistral.ai/v1 |
MISTRAL_API_KEY |
groq |
https://api.groq.com/openai/v1 |
GROQ_API_KEY |
配置字段(来自 README)¶
| 字段 | backend | 含义 |
|---|---|---|
id |
两者 | 提供者身份,用于默认提供者与 UI 选择 |
name |
两者 | 可读标签 |
location |
两者 | cloud 或 host-local |
languages |
两者 | 接受的语言提示(默认 [ru, en]) |
language |
两者 | 调用方未指定时使用的语言 |
baseUrl |
api | OpenAI 兼容根地址,不带尾部斜杠 |
model |
api, exec | 模型名称({model} 可在 args 中使用) |
apiKeyRef |
api | 通过 ctx.credentials 解析的凭证引用 |
apiKeyEnv |
api | 包含密钥的环境变量 |
apiKeyFile |
api | 包含密钥的文件路径 |
安装与启用¶
安装方式¶
从 npm 安装(推荐):
dsh plugin --profile <profile> add @dr-co/dsh-speech-gate
dsh plugin --profile <profile> add @dr-co/dsh-speech-gate@0.1.0
从 GitHub 安装(当前 main 分支):
dsh plugin --profile <profile> add github:unera/dsh-speech-gate
dsh plugin --profile <profile> add github:unera/dsh-speech-gate#v0.1.0
dsh plugin --profile <profile> add github:unera/dsh-speech-gate#206fb1e
从本地检出安装(开发迭代):
git clone https://github.com/unera/dsh-speech-gate
dsh plugin --profile <profile> add file:$PWD/dsh-speech-gate
安装后,插件不会生成 dsh.bundle,dsh plugin add 会将其作为普通依赖安装,实际挂载在配置的 patch 中。
挂载与启用¶
在宿主的配置 patch 中挂载插件(示例片段):
- id: speech-to-text
config:
defaultProvider: openai-compatible
language: ru
- insert:
- id: speech-provider
name: '@dr-co/dsh-speech-gate'
config:
providers:
- id: openai-compatible
backend: configured-model
name: OpenAI gpt-4o-mini-transcribe
location: cloud
languages: [ru, en]
language: ru
model: gpt-4o-mini-transcribe
- id: mistral-voxtral
backend: configured-model
name: Mistral Voxtral
location: cloud
languages: [ru, en]
language: ru
model: voxtral-mini-latest
- id: whisper-local
backend: api
name: Local whisper server
location: host-local
languages: [ru, en]
baseUrl: http://127.0.0.1:8080/v1
model: whisper-1
- id: whisper-exec
backend: exec
name: Local whisper command
location: host-local
languages: [ru, en]
command: whisper-cli
args: ['-f', '{input}', '-l', '{language}', '-nt']
将 defaultProvider 设置为其中一个 id。如果 @deepseek-ai/dsh-experimental-voice-input-bundle 已启用,这些提供者与语言会在 Web UI 的“Plugins → Voice Input”中显示。
典型用法¶
复用宿主 OpenAI 连接器¶
- id: openai-transcribe
backend: configured-model
model: gpt-4o-transcribe
- id: openai-mini
backend: configured-model
model: gpt-4o-mini-transcribe
本地 whisper 服务器(api 后端)¶
- id: whisper-local
backend: api
name: Local whisper server
location: host-local
languages: [ru, en]
baseUrl: http://127.0.0.1:8080/v1
model: whisper-1
本地 whisper 命令(exec 后端)¶
- id: whisper-exec
backend: exec
name: Local whisper command
location: host-local
languages: [ru, en]
command: whisper-cli
args: ['-f', '{input}', '-l', '{language}', '-nt']
适用场景与注意¶
适合需要同时使用托管转录服务与本地推理的用户:例如在云端使用 gpt-4o-mini-transcribe,同时在本地运行 whisper server 或 whisper-cli。
注意:
- DSH 版本要求 0.2.1-rc.2 或更高,Node.js 22+;
- 必须在宿主 profile 中挂载
@deepseek-ai/dsh-experimental-speech-to-text服务; - 使用
configured-model后端时,宿主需已配置对应的模型连接器; - 使用
exec后端时,宿主需能执行命令行工具(如whisper-cli); - 插件以当前 DSH 进程的权限运行,安装前应检查源码与许可证;
- 插件不转码音频,请确保输入音频为 16 kHz 单声道 PCM16 WAV。
小结¶
dsh-speech-gate 让 DeepSeek Harness 能够在一个插件中管理多种语音转文本提供者,同时避免重复输入密钥。通过 api、exec 与 configured-model 三种后端,可以在云端托管与本地推理之间灵活切换。
- 插件主页:https://www.skillhub.cn/plugins/unera/dsh-speech-gate
- 源码仓库:https://github.com/unera/dsh-speech-gate