dsh-voice 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.7.0 (2026-11-18)
4
+
5
+ - 稳定性与协议加固(P0):严格校验 Edge TTS `Path:audio` 音频帧头与 `turn.end` 截断保护;HTTP 403 自动读取响应 `Date` 校准时钟偏差;剔除 XML 1.0 非法控制字符并转义 SSML 属性;扩展方言、多语种及 HD 音色校验与筛选;支持配置 `timeoutMs` 热更新读取与动态 `isConcurrencySafe`;`voice_health` 新增 `ttsReady`/`sttReady`、`scope` 影响面、韵律参数检查及本机免密钥 Whisper 探测。
6
+ - P0 hardening: validate Edge TTS `Path:audio` binary frame headers and enforce strict `turn.end` truncation guards; auto-calibrate clock skew from HTTP 403 `Date` headers; strip illegal XML 1.0 control chars and escape SSML attributes; expand dialect, multilingual, and HD voice validation/filtering; resolve `timeoutMs` dynamically with live `isConcurrencySafe`; and enrich `voice_health` with `ttsReady`/`sttReady`, `scope`, prosody validation, and keyless loopback Whisper probing.
7
+ - 核心能力升级(P1):`voice_tts` 新增 `inputFile` 文档直读、Markdown 清理与 10 万字符长文本自动分段合成,支持多角色 `segments` 播客合成及原生 MP3 静音帧拼接;`voice_tts` 与 `voice_stt` 均支持导出 `.srt`/`.vtt` 字幕(`subtitleOutput`);`voice_stt` 采用 `openAsBlob` 零拷贝上传,并支持 `autoCompress` 对超 25MB 音频调用 FFmpeg 转码或分段识别。
8
+ - P1 core upgrades: add `inputFile` reading, Markdown cleanup, and 100k-char auto-chunking to `voice_tts`, plus multi-speaker `segments` podcast synthesis with native MP3 silence frames; support `.srt`/`.vtt` `subtitleOutput` in both `voice_tts` and `voice_stt`; switch `voice_stt` to zero-copy `openAsBlob` uploads and add `autoCompress` FFmpeg transcode/segmentation for >25MB audio.
9
+ - 生态扩展与交互增强(P2):新增 `ttsEngine` 对 OpenAI / SiliconFlow / 自定义网关的支持与 `siliconflow` ASR/TTS 预设;内置零外部依赖的 `socks5://` 与 `socks5h://` 代理隧道;`voice_preview` 生成可视化 `index.html` 音色试听卡片;新增内置工作流技能 `skills/voice-workflow/SKILL.md`。
10
+ - P2 ecosystem & UX: add `ttsEngine` support for OpenAI, SiliconFlow, and custom endpoints with `siliconflow` ASR/TTS presets; add zero-dependency `socks5://`/`socks5h://` proxy tunneling; generate a visual `index.html` audition card in `voice_preview`; and bundle `skills/voice-workflow/SKILL.md`.
11
+
12
+ ## 0.6.1 (2026-11-18)
13
+
14
+ - 同步 `@stardustlc/dsh-updates` 0.2.3:侧边栏工作台平时默认隐藏底部更新栏(零高度占用),仅在检测到兼容新版本或执行更新时浮现单行精简提示条;完整更新设置与检查入口统一保留在 DSH「插件」详情页底部。
15
+ - Sync `@stardustlc/dsh-updates` 0.2.3: keep the sidebar workbench update footer hidden by default when up-to-date, surfacing a single-line compact strip only for actionable updates or active jobs while retaining full controls in native Plugin Details.
16
+
3
17
  ## 0.6.0 (2026-11-18)
4
18
 
5
19
  - 新增零外部依赖的宿主原生 `Config` 设置表单声明(`asrApiKey` 与 `proxyUrl` 自动脱敏并支持热更新生效),明确配音免密钥开箱即用与转写配置指引,并补齐日常配音/会议纪要使用流程。
package/README.en.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **Turn text into natural speech and recordings into clean transcripts.**
6
6
 
7
- Voice plugin for DeepSeek Harness (`>=0.2.2-rc.3`): provides zero-key Edge neural text-to-speech (TTS), batch voice previews, native live Settings forms with secret masking, and OpenAI/Groq-compatible speech-to-text (STT) strictly scoped to your session workspace.
7
+ Voice plugin for DeepSeek Harness (`>=0.2.2-rc.3`): provides zero-key Edge neural text-to-speech (TTS) with OpenAI/SiliconFlow-compatible fallback engines, direct file synthesis with Markdown cleanup, multi-speaker podcast segments, synchronized `.srt`/`.vtt` subtitle export, interactive browser voice previews, and Groq/OpenAI/SiliconFlow/local Whisper speech-to-text (STT) strictly scoped to your session workspace.
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/dsh-voice)](https://www.npmjs.com/package/dsh-voice) [![downloads](https://raw.githubusercontent.com/STARDUSTLC666/dsh-suite/npm-downloads/assets/dsh-voice-downloads.svg)](https://www.npmjs.com/package/dsh-voice) [![total downloads](https://raw.githubusercontent.com/STARDUSTLC666/dsh-suite/npm-downloads/assets/dsh-voice-total-downloads.svg)](https://www.npmjs.com/package/dsh-voice)
10
10
 
@@ -17,6 +17,13 @@ Voice plugin for DeepSeek Harness (`>=0.2.2-rc.3`): provides zero-key Edge neura
17
17
  <img src="https://raw.githubusercontent.com/STARDUSTLC666/dsh-voice/master/docs/assets/intro/workflow-en-light.svg" alt="Turn text into speech and recordings into text. · workflow illustration" width="100%">
18
18
  </picture>
19
19
 
20
+ ## Highlights
21
+
22
+ - **Long-form File Synthesis & Markdown Cleanup**: Pass workspace `.md`/`.txt` files directly via `inputFile`; strips code fences, URLs, and formatting automatically and auto-chunks texts over 5,000 characters (up to 100k chars) on sentence boundaries into one seamless MP3.
23
+ - **Multi-Speaker Podcasts & Zero-Cost Subtitles**: Compose multi-host dialogues with `segments` and configurable `pauseMs` silences, and export synchronized `.srt`/`.vtt` subtitles alongside either TTS or STT outputs.
24
+ - **Voice Filtering & Interactive Audition Page**: Filter voices by `locale`, `gender`, or `tag` (including flagship Multilingual voices), and audition samples in the auto-generated `voice_previews/index.html` page with playback-speed controls and one-click ID copy.
25
+ - **Flexible Engines, Oversize Audio & Proxy Support**: Includes `openai`, `siliconflow`, and `custom` TTS/ASR presets (plus keyless local loopback Whisper), `autoCompress: true` for >25 MB recordings via local `ffmpeg` with zero-copy upload, and `http://`, `https://`, `socks5://`, `socks5h://` proxy support (applied live on save).
26
+
20
27
  ## Install
21
28
 
22
29
  Open **Plugins** in the DSH desktop app and install `dsh-voice`, or use the CLI:
@@ -25,32 +32,32 @@ Open **Plugins** in the DSH desktop app and install `dsh-voice`, or use the CLI:
25
32
  dsh plugin --profile desktop add dsh-voice
26
33
  ```
27
34
 
28
- For the web profile, replace `desktop` with `web`. Restart DSH once after installing. Requires DSH `>=0.2.2-rc.3`.
35
+ For the web profile, replace `desktop` with `web`. Restart DSH once after installing. Requires DSH `>=0.2.2-rc.3`. The plugin bundles the `voice-workflow` skill so your assistant automatically follows best practices for narration, podcasts, subtitles, and transcription.
29
36
 
30
37
  <a id="start-using-it"></a>
31
38
  ## Get Started in 3 Steps
32
39
 
33
- 1. **Read-aloud works out of the box (zero API keys)**: Open a DSH session in your target workspace and ask the assistant to preview voices or turn any script into an MP3 immediately.
34
- 2. **Add an ASR key when you need transcription (applies live)**: Open **DSH Settings → Plugins → Voice (`dsh-voice`)** and enter your Groq or OpenAI-compatible `asrApiKey` (masked and applied immediately without restarting; `DSH_VOICE_ASR_KEY` env var is also supported).
35
- 3. **Preview, synthesize, or transcribe inside your workspace**: Place recordings inside your session workspace; generated MP3s and `.txt` transcripts stay safely inside the workspace and auto-number instead of overwriting existing files.
40
+ 1. **Read-aloud works out of the box (zero API keys)**: Open a DSH session in your target workspace and ask the assistant to audition voices, narrate long Markdown files, produce two-host podcasts, or export `.srt`/`.vtt` subtitles immediately.
41
+ 2. **Add an ASR key when you need cloud transcription (loopback Whisper is keyless)**: Open **DSH Settings → Plugins → Voice (`dsh-voice`)**, pick `asrEngine` (`groq`, `openai`, `siliconflow`, or `custom`), and enter `asrApiKey` (masked and applied live without restarting; `DSH_VOICE_ASR_KEY` env var is also supported). A `custom` endpoint on `127.0.0.1`/`localhost` works with no API key.
42
+ 3. **Preview, synthesize, or transcribe inside your workspace**: Keep input scripts and recordings inside your session workspace; generated MP3s, `.txt` transcripts, `.srt`/`.vtt` subtitles, and preview pages stay safely inside the workspace and auto-number instead of overwriting existing files.
36
43
 
37
44
  ## Copy-Ready Prompts for Everyday Work
38
45
 
39
- - **Audition 3 voices first, then synthesize the full audio (zero config)**
40
- > Generate short voice preview samples for 3 natural narration voices so I can listen first, then synthesize the full MP3 once I pick one.
41
- - **Turn a written briefing into a ready-to-play MP3**
42
- > Condense today's notes into a 2-minute spoken script and generate `morning-brief.mp3` at `+10%` speed.
43
- - **Transcribe a meeting recording & extract action items**
44
- > Transcribe `meeting.m4a` in this workspace, save the full transcript to `meeting.txt`, and list the action items.
46
+ - **Filter podcast voices and audition them in a browser page**
47
+ > Filter voices tagged `podcast` and generate short previews with `voice_previews/index.html` so I can listen first, then render the full MP3 once I pick one.
48
+ - **Turn a Markdown report into a two-host podcast with subtitles**
49
+ > Read `weekly-report.md` in this workspace and turn it into a two-host dialogue (`zh-CN-XiaoxiaoMultilingualNeural` and `zh-CN-YunyiMultilingualNeural`), saving `podcast.mp3` and `podcast.srt`.
50
+ - **Transcribe a large meeting recording with subtitles & action items**
51
+ > Transcribe `meeting.m4a` in this workspace (auto-compress if over 25 MB), save `meeting.txt` and `meeting.srt`, and list the action items.
45
52
 
46
53
  ## Quick Troubleshooting Checklist
47
54
 
48
55
  | Symptom | Likely Cause | Fix |
49
56
  | :--- | :--- | :--- |
50
- | Health check says `asrApiKey` is missing, but you only want TTS | ASR key is only needed for audio-to-text transcription | **Keep using TTS directly** — no key is required for speech synthesis or previews |
51
- | "Must stay inside the session workspace" error | Recording or output path points outside the workspace folder | Copy the audio file into the current DSH workspace folder first |
52
- | Network / connection error | Corporate firewall or proxy required to reach Edge TTS / ASR | Set `proxyUrl` (e.g. `http://127.0.0.1:7890`) in **DSH Settings → Plugins → Voice** (applies live) |
53
- | Audio exceeds 25 MB limit | Standard Whisper/ASR upload limit is 25 MB | Compress or split the audio with `dsh-ffmpeg` first, then transcribe |
57
+ | Health check says `asrApiKey` is missing, but you only want TTS | ASR key is only needed for audio-to-text transcription | **Keep using TTS directly** — health check reports `ttsReady` / `sttReady` separately and supports `scope: "tts"` |
58
+ | "Must stay inside the session workspace" error | Script, recording, or output path points outside the workspace folder | Copy the file into the current DSH workspace folder first |
59
+ | Network / connection error | Corporate firewall or proxy required to reach Edge TTS / ASR | Set `proxyUrl` (`http://`, `https://`, `socks5://`, or `socks5h://`) in **DSH Settings → Plugins → Voice** (applies live) |
60
+ | Audio exceeds 25 MB limit | Standard Whisper/ASR upload limit is 25 MB | Ask the assistant to enable `autoCompress: true` (uses local `ffmpeg`) or pre-process with `dsh-ffmpeg` |
54
61
 
55
62
  ## Plugin updates
56
63
 
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **把文字变成自然人声,把会议录音转成干净文字。**
6
6
 
7
- DeepSeek Harness(`>=0.2.2-rc.3`)语音插件:内置零密钥 Edge 神经网络语音合成(TTS)与短试听音色挑选,支持原生设置表单与热生效、OpenAI / Groq 兼容语音转文字(STT),并严格将读写限制在当前会话工作区内。
7
+ DeepSeek Harness(`>=0.2.2-rc.3`)语音插件:内置零密钥 Edge 神经网络语音合成(TTS)与 OpenAI / SiliconFlow 兼容备用引擎,支持长文直读与 Markdown 口播清理、多角色播客拼接、同步 `.srt` / `.vtt` 字幕导出、浏览器交互式试听页,以及 Groq / OpenAI / SiliconFlow / 本地 Whisper 语音转文字(STT),并严格将读写限制在当前会话工作区内。
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/dsh-voice)](https://www.npmjs.com/package/dsh-voice) [![downloads](https://raw.githubusercontent.com/STARDUSTLC666/dsh-suite/npm-downloads/assets/dsh-voice-downloads.svg)](https://www.npmjs.com/package/dsh-voice) [![total downloads](https://raw.githubusercontent.com/STARDUSTLC666/dsh-suite/npm-downloads/assets/dsh-voice-total-downloads.svg)](https://www.npmjs.com/package/dsh-voice)
10
10
 
@@ -17,6 +17,13 @@ DeepSeek Harness(`>=0.2.2-rc.3`)语音插件:内置零密钥 Edge 神经
17
17
  <img src="https://raw.githubusercontent.com/STARDUSTLC666/dsh-voice/master/docs/assets/intro/workflow-zh-light.svg" alt="把文字变成声音,把录音变成文字。 · 流程示意" width="100%">
18
18
  </picture>
19
19
 
20
+ ## 核心亮点
21
+
22
+ - **长文直读与口播清理**:支持 `inputFile` 直接读取工作区 `.md` / `.txt` 文稿,自动剥离代码块/链接等 Markdown 语法,超过 5,000 字自动按句断句合成并无缝拼接(最高 10 万字)。
23
+ - **多角色播客与零成本字幕**:单次合成即可通过 `segments` 编排多主持人对话与停顿(`pauseMs`),并支持零额外开销同步导出 `.srt` / `.vtt` 字幕(TTS 与 STT 均支持)。
24
+ - **音色筛选与浏览器试听页**:支持按语种、性别、标签(如 `podcast`、`multilingual`)筛选并内置多语种旗舰音色;批量试听自动生成 `voice_previews/index.html` 交互试听页(支持倍速试听与一键复制音色 ID)。
25
+ - **灵活引擎、大文件转写与代理**:除零密钥 Edge TTS 外,支持 `openai` / `siliconflow` / `custom` TTS 与 ASR 预设及本地回环免密 Whisper;>25MB 录音可开启 `autoCompress` 调用本机 `ffmpeg` 自动压缩/切片并零拷贝流式上传;代理原生支持 `http://`、`https://`、`socks5://` 与 `socks5h://`(设置保存即生效)。
26
+
20
27
  ## 安装
21
28
 
22
29
  在 DSH 桌面版「插件」面板搜索安装 `dsh-voice`,或使用命令行:
@@ -25,32 +32,32 @@ DeepSeek Harness(`>=0.2.2-rc.3`)语音插件:内置零密钥 Edge 神经
25
32
  dsh plugin --profile desktop add dsh-voice
26
33
  ```
27
34
 
28
- 网页版把 `desktop` 改为 `web`;安装后重启一次 DSH。宿主要求 `>=0.2.2-rc.3`。
35
+ 网页版把 `desktop` 改为 `web`;安装后重启一次 DSH。宿主要求 `>=0.2.2-rc.3`。插件附带 `voice-workflow` 技能包,会在语音合成、播客与转写任务中自动指引助手采用最佳实践。
29
36
 
30
37
  <a id="开始使用"></a>
31
38
  ## 最快 3 步用起来
32
39
 
33
- 1. **文字转语音开箱即用(零 API 密钥)**:装好插件后无需填任何密钥,直接在工作区新建会话,就能让助手试听多种音色并把文章、播客稿或早报合成 MP3。
34
- 2. **录音转文字按需填密钥(保存即生效)**:需要把录音转文字时,打开 DSH「**设置 → 插件 → 语音(dsh-voice)**」填入 Groq 或 OpenAI 兼容的 `asrApiKey`(自动脱敏、保存即生效;也支持环境变量 `DSH_VOICE_ASR_KEY`)。
35
- 3. **试听选声 → 合成或转写交付**:把待转写录音放到当前会话工作区,合成出的 MP3 或 `.txt` 纪要也会安全落在工作区且同名自动编号不误盖。
40
+ 1. **文字转语音开箱即用(零 API 密钥)**:装好插件后无需填任何密钥,直接在工作区新建会话,就能试听音色、直接朗读 Markdown 长文、编排双人播客并顺带导出 `.srt` / `.vtt` 字幕。
41
+ 2. **录音转文字按需填密钥(本地回环免密)**:需要转写录音时,打开 DSH「**设置 → 插件 → 语音(dsh-voice)**」选择 `asrEngine`(`groq` / `openai` / `siliconflow` / `custom`)并填入 `asrApiKey`(自动脱敏、保存即生效;也支持 `DSH_VOICE_ASR_KEY`)。若 `custom` 指向 `127.0.0.1` / `localhost` 的本地 Whisper 服务,无需密钥即可直接转写。
42
+ 3. **试听选声 → 合成或转写交付**:把待转写录音或文稿放到当前会话工作区,生成的 MP3、`.txt` 纪要、`.srt` / `.vtt` 字幕与试听页面都会安全落在工作区,默认同名自动编号不误盖。
36
43
 
37
44
  ## 平时怎么对助手说(可直接复制的自然语言示例)
38
45
 
39
- - **先生成短试听挑音色,再合成完整配音(零配置)**
40
- > 挑 3 个适合播客的中英文音色给我生成短试听样例,等我选好后再把这篇早报稿合成完整 MP3。
41
- - **一步把总结变成可带走听的语音早报**
42
- > 把今天的重点文档浓缩成 300 字口播稿,用温和自然的中文男声(语速 +10%)生成 `morning-brief.mp3`。
43
- - **把工作区里的会议录音转成文字并提炼纪要**
44
- > 把当前目录里的 `meeting.m4a` 转写成中文,原稿存到 `meeting.txt`,再帮我整理一份待办事项清单。
46
+ - **筛选播客音色并在浏览器试听页里对比**
47
+ > 按 `podcast` 标签筛选几个中英文音色生成短试听,用生成的 `voice_previews/index.html` 让我试听挑选,再把这篇早报合成完整 MP3。
48
+ - **直接把 Markdown 长文变成双人播客 + 字幕**
49
+ > 直接读取工作区里的 `weekly-report.md`,整理成双人对话播客(女声用 `zh-CN-XiaoxiaoMultilingualNeural`,男声用 `zh-CN-YunyiMultilingualNeural`),输出 `podcast.mp3` 和 `podcast.srt`。
50
+ - **把大体积会议录音转成文字、字幕与纪要**
51
+ > 把当前目录里的 `meeting.m4a` 转写成中文(如果超过 25MB 就自动压缩分段),同时输出 `meeting.txt` 和 `meeting.srt`,再提炼待办事项清单。
45
52
 
46
53
  ## 常见卡点自检
47
54
 
48
55
  | 遇到的现象 | 10 秒定位原因 | 怎么修 |
49
56
  | :--- | :--- | :--- |
50
- | 自检提示「缺 ASR 密钥」但只想做朗读配音 | ASR 密钥仅录音转文字需要,不影响朗读 | **直接正常合成语音即可**;日后需要转写录音再去「设置 → 插件 → 语音」补填 `asrApiKey` |
51
- | 提示「必须位于会话工作区内」 | 录音或输出路径指到了工作区文件夹外面 | 先把音频复制进当前会话工作区文件夹再让助手转写 |
52
- | 合成或转写报网络连接失败 | 受限网络无法直连在线语音 / ASR 服务 | 在 DSH「设置 → 插件 → 语音」填入本地 HTTP 代理 `proxyUrl`(如 `http://127.0.0.1:7890`,保存即生效) |
53
- | 音频超过 25MB 无法转写 | 在线 ASR 接口单文件体积上限为 25MB | 先让助手用 `dsh-ffmpeg` 压缩码率或按时间切段后再转写 |
57
+ | 自检提示「缺 ASR 密钥」但只想做朗读配音 | ASR 密钥仅录音转文字需要,不影响朗读 | **直接正常合成语音即可**(自检可按 `tts` 范围单独查看 `ttsReady`) |
58
+ | 提示「必须位于会话工作区内」 | 文稿、录音或输出路径指到了工作区文件夹外面 | 先把文件复制进当前会话工作区文件夹再让助手处理 |
59
+ | 合成或转写报网络连接失败 | 受限网络无法直连在线语音 / ASR 服务 | 在 DSH「设置 → 插件 → 语音」填入本地代理 `proxyUrl`(支持 `http://` / `https://` / `socks5://` / `socks5h://`,保存即生效) |
60
+ | 音频超过 25MB 无法转写 | 在线 ASR 接口单文件体积上限为 25MB | 让助手开启 `autoCompress: true`(需本机有 `ffmpeg`)自动压缩/切片转写,或先用 `dsh-ffmpeg` 处理 |
54
61
 
55
62
  ## 插件更新
56
63
 
package/docs/USAGE.en.md CHANGED
@@ -4,61 +4,67 @@
4
4
 
5
5
  ## Get Started in 3 Steps
6
6
 
7
- ### Step 1: Know What Works Out of the Box vs. Optional ASR Setup
7
+ ### Step 1: Know What Works Out of the Box vs. Optional TTS / ASR Setup
8
8
 
9
- - **Text-to-speech (`voice_tts`, `voice_list`, `voice_preview`) works with zero config**: No API keys needed — install the plugin and synthesize speech or audition voices right away.
10
- - **Speech-to-text (`voice_stt`) needs an ASR key when you want transcription**:
11
- - **Recommended**: Open **DSH → Settings → Plugins → Voice (`dsh-voice`)**, pick `asrEngine` (`groq` by default, `openai`, or `custom`), and paste `asrApiKey` (masked and **applied live on save without restarting**);
12
- - **CLI / Environment variable**: Set `DSH_VOICE_ASR_KEY` or configure `cordis.patch.yml`:
9
+ - **Text-to-speech (`voice_tts`, `voice_list`, `voice_preview`) works with zero config**: Uses Edge neural voices by default with zero API keys — browse and filter voices, generate an interactive browser audition page, narrate long workspace files, compose multi-speaker podcasts, and export `.srt`/`.vtt` subtitles. You can optionally switch `ttsEngine` to `openai`, `siliconflow`, or `custom` in Settings.
10
+ - **Speech-to-text (`voice_stt`) needs an ASR key for cloud endpoints (loopback Whisper is keyless)**:
11
+ - **Recommended**: Open **DSH → Settings → Plugins → Voice (`dsh-voice`)**, pick `asrEngine` (`groq` by default, `openai`, `siliconflow`, or `custom`), and paste `asrApiKey` (masked and **applied live on save without restarting**; when `custom` points to `127.0.0.1` or `localhost`, no key is required);
12
+ - **CLI / Environment variable**: Set `DSH_VOICE_ASR_KEY` (and optionally `DSH_VOICE_TTS_KEY`) or configure `cordis.patch.yml`:
13
13
 
14
14
  ```yaml
15
15
  - id: voice
16
16
  name: 'dsh-voice'
17
17
  config:
18
+ ttsEngine: edge # edge | openai | siliconflow | custom
18
19
  ttsVoice: zh-CN-XiaoxiaoNeural # default voice (applies live)
19
20
  ttsRate: '+0%' # default speech rate, e.g. +15% or -10%
20
21
  ttsPitch: '+0Hz' # default pitch, e.g. +2Hz or -1Hz
21
- asrEngine: groq # groq | openai | custom
22
+ # ttsBaseUrl: https://api.siliconflow.cn/v1 # optional for non-edge engines
23
+ # ttsModel: FunAudioLLM/CosyVoice2-0.5B
24
+ # ttsApiKey: sk-... # prefer DSH Settings or DSH_VOICE_TTS_KEY
25
+ asrEngine: groq # groq | openai | siliconflow | custom
22
26
  asrModel: whisper-large-v3-turbo # optional; defaults to engine preset
23
- # asrApiKey: gsk_... # prefer DSH Settings or env var DSH_VOICE_ASR_KEY
24
- # proxyUrl: http://127.0.0.1:7890 # optional HTTP(S) proxy URL
27
+ # asrApiKey: gsk_... # prefer DSH Settings or DSH_VOICE_ASR_KEY (optional for loopback custom)
28
+ # proxyUrl: socks5://127.0.0.1:1080 # supports http://, https://, socks5://, socks5h://
25
29
  ```
26
30
 
27
- ### Step 2: Keep Audio & Outputs Inside Your Session Workspace
31
+ ### Step 2: Keep Scripts, Audio & Outputs Inside Your Session Workspace
28
32
 
29
- All input audio and output MP3 / `.txt` files must resolve under the active DSH session workspace (`session.header.cwd`) to protect host files. Copy outside recordings into the workspace first.
33
+ All `voice_tts` input files (`inputFile`), input audio (`audio`), and generated MP3 / `.txt` / `.srt` / `.vtt` / preview files must resolve under the active DSH session workspace (`session.header.cwd`) to protect host files. Copy outside files into the workspace first.
30
34
 
31
35
  ### Step 3: Audition Voices, Then Synthesize or Transcribe
32
36
 
33
- Unsure which voice fits best? Ask the assistant to generate short preview samples in parallel before rendering your full script.
37
+ Unsure which voice fits best? Filter voices with `voice_list`, then call `voice_preview` to render short samples plus an interactive `voice_previews/index.html` page. The plugin also ships `skills/voice-workflow/SKILL.md` so the assistant automatically uses `inputFile`, Markdown cleanup, `segments` podcast composition, and subtitle export.
34
38
 
35
39
  ---
36
40
 
37
41
  ## Copy-Ready Prompts for Everyday Work
38
42
 
39
- - **Audition voices before committing to a full render**
40
- > List the built-in voices and generate short preview MP3s for 4 distinct voices so I can choose my favorite.
41
- - **Render a polished voiceover MP3**
42
- > Synthesize this release summary into `release-note.mp3` using `en-US-AriaNeural` at `+10%` speed.
43
- - **Transcribe a recording with domain terminology hints**
44
- > Transcribe `interview.mp3` in this workspace (prompt hint: DeepSeek Harness, Cordis), save the full text to `interview.txt`, and list the 5 key takeaways.
45
- - **Offline configuration self-check**
46
- > Run a voice health check to verify my default TTS voice, proxy, and ASR key status.
43
+ - **Filter voices and audition via the interactive HTML page**
44
+ > List voices with tag `podcast` and generate short previews with `voice_previews/index.html` so I can listen and pick my favorite.
45
+ - **Narrate a Markdown file directly with synchronized subtitles**
46
+ > Synthesize `guide.md` in this workspace using `en-US-AvaMultilingualNeural` into `guide.mp3` and export `guide.srt`.
47
+ - **Create a two-host podcast MP3**
48
+ > Turn this release note into a two-host podcast using `zh-CN-XiaoxiaoMultilingualNeural` and `zh-CN-YunyiMultilingualNeural`, saving `episode.mp3` and `episode.srt`.
49
+ - **Transcribe a large recording with auto-compression and subtitles**
50
+ > Transcribe `interview.m4a` in this workspace (enable `autoCompress` if over 25 MB; prompt hint: DeepSeek Harness, Cordis), and save `interview.txt` and `interview.srt`.
51
+ - **Scoped offline configuration self-check**
52
+ > Run a voice health check to verify `ttsReady`, `sttReady`, prosody settings, proxy, and ASR key status.
47
53
 
48
54
  ---
49
55
 
50
56
  ## Quick Troubleshooting Checklist
51
57
 
52
- Run `voice_health` first (offline check with zero network traffic that clearly separates `voice_stt`-only issues from TTS):
58
+ Run `voice_health` first (offline check with zero network traffic; supports `scope: "tts" | "stt" | "all"` and reports `ttsReady` and `sttReady` separately):
53
59
 
54
60
  | Symptom | Usual Cause | Quick Fix |
55
61
  | :--- | :--- | :--- |
56
- | Health check says `asrApiKey` is missing | `asrApiKey` and `DSH_VOICE_ASR_KEY` are both empty | Safe to ignore if you only need TTS (`voice_tts` needs no key); for transcription, fill `asrApiKey` in **DSH Settings → Plugins → Voice** (applies live) |
57
- | Invalid voice ID error | `ttsVoice` does not match Edge neural voice format | Run `voice_list` to pick a valid ID (e.g. `zh-CN-XiaoxiaoNeural`) and update `ttsVoice` in Settings |
58
- | Network error on TTS or STT | Direct connection blocked by corporate network | Enter an HTTP(S) `proxyUrl` (e.g. `http://127.0.0.1:7890`) in **DSH Settings → Plugins → Voice** (applies live) |
59
- | Path outside session workspace error | Audio or output path resolves outside workspace | Copy the recording into the current session workspace folder first |
60
- | Audio exceeds 25 MB limit | Standard Whisper / ASR multipart cap is 25 MB | Compress or split the recording with `dsh-ffmpeg` before transcribing |
61
- | ASR refuses a 3xx redirect | Redirects are blocked so audio/keys never leak to another host | Set `asrBaseUrl` directly to the final non-redirecting `/v1` endpoint |
62
+ | Health check says `asrApiKey` is missing | `asrApiKey` and `DSH_VOICE_ASR_KEY` are both empty | Safe to ignore if you only need TTS (`ttsReady` is `true`), or pass `scope: "tts"`; for local Whisper, set `asrEngine: custom` with `127.0.0.1`/`localhost` (no key needed) |
63
+ | Invalid voice ID, rate, or pitch error | `ttsVoice` or `ttsRate`/`ttsPitch` format is invalid | Run `voice_list` to pick a valid ID and fix `ttsVoice` / `ttsRate` / `ttsPitch` in Settings |
64
+ | Network error on TTS or STT | Direct connection blocked by corporate network | Enter `proxyUrl` (`http://`, `https://`, `socks5://`, or `socks5h://`) in **DSH Settings → Plugins → Voice** (applies live) |
65
+ | Path outside session workspace error | Script, audio, or output path resolves outside workspace | Copy the file into the current session workspace folder first |
66
+ | Audio exceeds 25 MB limit | Standard Whisper / ASR multipart cap is 25 MB | Pass `autoCompress: true` to `voice_stt` (uses local `ffmpeg` to compress/segment automatically) or pre-process with `dsh-ffmpeg` |
67
+ | ASR or TTS refuses a 3xx redirect | Redirects are blocked so audio/keys never leak to another host | Set `asrBaseUrl` / `ttsBaseUrl` directly to the final non-redirecting `/v1` endpoint |
62
68
  | Existing output file was not overwritten | `overwrite: false` (default) suffixes `_1`, `_2` safely | Use the exact path returned by the tool, or enable `overwrite` in Settings |
63
69
 
64
70
  ---
@@ -69,17 +75,20 @@ Run `voice_health` first (offline check with zero network traffic that clearly s
69
75
 
70
76
  | Tool | Purpose | Key Parameters & Notes |
71
77
  | :--- | :--- | :--- |
72
- | `voice_tts` | Synthesize MP3 from text (keyless Edge neural TTS) | `text` required (≤5000 chars); optional `voice`, `rate`, `pitch`, `output` |
73
- | `voice_stt` | Transcribe audio to text (Groq / OpenAI / custom) | `audio` required (≤25 MB); optional `model`, `language`, `prompt`, `output` |
74
- | `voice_list` | Browse curated multilingual & dialect voice catalog | No parameters |
75
- | `voice_preview` | Bounded-concurrency (≤3) batch voice preview MP3s | Optional `voices` (≤8), `text` (≤200 chars), `outputDir` |
76
- | `voice_health` | Offline configuration self-check | Checks TTS voice, proxy, and ASR engine/endpoint/key |
77
-
78
- ### Workspace & Credential Guardrails
79
-
80
- - **Workspace confinement & symlink protection**: All reads and writes stay under `session.header.cwd`, symlinks are never written through, new files use `O_EXCL`, and `.txt` transcripts use `0600` permissions on POSIX.
81
- - **Pinned endpoint & redirect block**: ASR requests only go to the configured `asrBaseUrl`, mismatched `engine` overrides are rejected, and `3xx` redirects abort immediately before sending audio.
82
- - **Instant cancellation**: `voice_tts`, `voice_preview`, and `voice_stt` propagate `exec.signal` to close WebSockets and abort uploads immediately on cancel.
78
+ | `voice_tts` | Synthesize MP3 & subtitles from text, files, or dialogues | Supports `text`, `inputFile` (≤100k chars auto-chunked), `cleanMarkdown` (default `true` for `.md`), `segments` (≤50 turns with `pauseMs`), `subtitleOutput` (`.srt`/`.vtt`), `voice`, `rate`, `pitch`, `output` |
79
+ | `voice_stt` | Transcribe audio to text & subtitles (zero-copy upload) | `audio` required; supports `autoCompress` (uses local `ffmpeg` for >25 MB), `timestamps`, `subtitleOutput` (`.srt`/`.vtt`), `model`, `language`, `prompt`, `output`, `engine` |
80
+ | `voice_list` | Browse & filter built-in multilingual & dialect voices | Optional `locale`, `gender` (`Female`/`Male`), `tag` (e.g. `podcast`, `multilingual`, `dialect`) |
81
+ | `voice_preview` | Bounded-concurrency (≤3) batch previews + HTML page | Optional `voices` (≤8), `text` (≤200 chars), `outputDir`, `htmlIndex` (default `true`, writes `voice_previews/index.html`) |
82
+ | `voice_health` | Offline configuration self-check | Optional `scope` (`all`/`tts`/`stt`), reports `ttsReady` / `sttReady` across engines, voice/prosody, proxy, and keys |
83
+
84
+ ### Engine Presets & Workspace Guardrails
85
+
86
+ - **Engine presets**:
87
+ - `asrEngine`: `groq` (`whisper-large-v3-turbo`), `openai` (`whisper-1`), `siliconflow` (`FunAudioLLM/SenseVoiceSmall`), `custom` (keyless when targeting loopback `127.0.0.1` / `localhost`).
88
+ - `ttsEngine`: `edge` (zero-key default), `openai` (`gpt-4o-mini-tts`), `siliconflow` (`FunAudioLLM/CosyVoice2-0.5B`), `custom` (OpenAI `/audio/speech`-compatible endpoint).
89
+ - **Workspace confinement & symlink protection**: All reads and writes stay under `session.header.cwd`, symlinks are never written through, new files use `O_EXCL`, and `.txt`/subtitle outputs use `0600` permissions on POSIX.
90
+ - **Pinned endpoint & redirect block**: Requests only go to the configured endpoint, mismatched `engine` overrides are rejected, and `3xx` redirects abort immediately.
91
+ - **Live timeouts & instant cancellation**: `timeoutMs` updates dynamically on config save; `voice_tts`, `voice_preview`, and `voice_stt` propagate `exec.signal` to close WebSockets and abort compression/uploads immediately on cancel.
83
92
 
84
93
  ## Install, Uninstall & Development
85
94
 
package/docs/USAGE.md CHANGED
@@ -4,61 +4,67 @@
4
4
 
5
5
  ## 最快 3 步用起来
6
6
 
7
- ### 第 1 步:了解零配置范围与可选 ASR 配置
7
+ ### 第 1 步:了解零配置范围与可选 TTS / ASR 配置
8
8
 
9
- - **文字转语音(`voice_tts` / `voice_list` / `voice_preview`)零配置即用**:无需申请任何 API 密钥,安装后联网即可试听音色与合成 MP3。
10
- - **录音转文字(`voice_stt`)按需填密钥**:
11
- - **推荐方式**:打开 **DSH → 设置 → 插件 → 语音(`dsh-voice`)**,选择 `asrEngine`(默认 `groq`,也可选 `openai` 或 `custom`),填入 `asrApiKey`(自动脱敏,**保存立即生效、无需重启**);
12
- - **命令行 / 环境变量方式**:设置环境变量 `DSH_VOICE_ASR_KEY`,或在 `cordis.patch.yml` 中配置:
9
+ - **文字转语音(`voice_tts` / `voice_list` / `voice_preview`)零配置即用**:默认使用 Edge 神经语音,无需任何 API 密钥即可按语种/标签筛选音色、生成网页试听页、直读长文并合成 MP3 与 `.srt`/`.vtt` 字幕;如需切换 OpenAI 兼容或 SiliconFlow TTS 作为备用引擎,可在设置中调整 `ttsEngine`。
10
+ - **录音转文字(`voice_stt`)按需填密钥(本地回环免密)**:
11
+ - **推荐方式**:打开 **DSH → 设置 → 插件 → 语音(`dsh-voice`)**,选择 `asrEngine`(默认 `groq`,可选 `openai`、`siliconflow` 或 `custom`),填入 `asrApiKey`(自动脱敏,**保存立即生效、无需重启**;当 `custom` 指向 `127.0.0.1` / `localhost` 本地 Whisper 服务时无需密钥);
12
+ - **命令行 / 环境变量方式**:设置环境变量 `DSH_VOICE_ASR_KEY`(及可选 `DSH_VOICE_TTS_KEY`),或在 `cordis.patch.yml` 中配置:
13
13
 
14
14
  ```yaml
15
15
  - id: voice
16
16
  name: 'dsh-voice'
17
17
  config:
18
+ ttsEngine: edge # edge | openai | siliconflow | custom
18
19
  ttsVoice: zh-CN-XiaoxiaoNeural # 默认朗读音色(保存即生效)
19
20
  ttsRate: '+0%' # 默认语速,如 +15% 或 -10%
20
21
  ttsPitch: '+0Hz' # 默认音调,如 +2Hz 或 -1Hz
21
- asrEngine: groq # groq | openai | custom
22
+ # ttsBaseUrl: https://api.siliconflow.cn/v1 # 非 edge 引擎时可自定义
23
+ # ttsModel: FunAudioLLM/CosyVoice2-0.5B
24
+ # ttsApiKey: sk-... # 推荐在 DSH 设置页填写或用 DSH_VOICE_TTS_KEY
25
+ asrEngine: groq # groq | openai | siliconflow | custom
22
26
  asrModel: whisper-large-v3-turbo # 可选;留空按引擎预设自动填入
23
- # asrApiKey: gsk_... # 推荐在 DSH 设置页填写或用环境变量 DSH_VOICE_ASR_KEY
24
- # proxyUrl: http://127.0.0.1:7890 # 网络需要 HTTP(S) 代理时填写
27
+ # asrApiKey: gsk_... # 推荐在 DSH 设置页填写或用 DSH_VOICE_ASR_KEY(本地回环 custom 可留空)
28
+ # proxyUrl: socks5://127.0.0.1:1080 # 支持 http://、https://、socks5://、socks5h://
25
29
  ```
26
30
 
27
31
  ### 第 2 步:在工作区内准备文稿或录音
28
32
 
29
- 为了防止路径越界读取隐私文件,所有待转写音频与生成的 MP3 / `.txt` 都严格限制在**当前会话工作区**内;外部录音请先复制进工作区目录。
33
+ 为了防止路径越界读取隐私文件,所有 `voice_tts` 直读文稿(`inputFile`)、待转写音频(`audio`)以及生成的 MP3 / `.txt` / `.srt` / `.vtt` / 试听页都严格限制在**当前会话工作区**内;外部文件请先复制进工作区目录。
30
34
 
31
- ### 第 3 步:试听选定音色,合成配音或转写纪要
35
+ ### 第 3 步:试听选定音色,合成长文/播客/字幕或转写纪要
32
36
 
33
- 不确定哪个声音好听时,先让助手生成几段 3 秒短试听样例对比,再一键合成正式音频。
37
+ 不确定哪个声音好听时,先让助手用 `voice_list` 按语种或标签筛选,再用 `voice_preview` 生成短试听样例与交互式 `voice_previews/index.html` 浏览器试听页;插件内建 `skills/voice-workflow/SKILL.md` 工作流指南,助手会自动优先使用 `inputFile`、Markdown 清理、`segments` 播客编排与字幕导出。
34
38
 
35
39
  ---
36
40
 
37
41
  ## 平时怎么对助手说(可直接复制的自然语言示例)
38
42
 
39
- - **批量短试听挑选音色(不盲猜 ID)**
40
- > 先帮我看看常用中英文音色清单,挑 4 个风格不同的音色生成一段短试听 MP3 让我选。
41
- - **把文章或报告合成可播放的语音文件**
42
- > 用 `zh-CN-YunxiNeural` 男声(语速 `+10%`)把这段产品更新说明合成到 `update-audio.mp3`。
43
- - **录音转写 + 专有名词纠偏 + 落盘存档**
44
- > 把工作区里的 `interview.mp3` 转写成中文(提示词加上专有名词:DeepSeek Harness、Cordis),完整转写存进 `interview.txt`,并总结 5 条核心结论。
45
- - **不确定代理或密钥是否就绪时先自检**
46
- > 跑一下语音插件自检,看看当前默认音色、代理和语音转文字密钥状态。
43
+ - **筛选音色并生成网页试听页对比(不盲猜 ID)**
44
+ > 按 `podcast` 标签看看中英文音色清单,挑 4 个生成短试听并打开 `voice_previews/index.html` 让我选。
45
+ - **直接朗读 Markdown 长文并导出同步字幕**
46
+ > 用 `zh-CN-XiaoxiaoMultilingualNeural` 直接读取工作区 `guide.md` 合成 `guide.mp3`,同时导出 `guide.srt`。
47
+ - **制作双人对话播客 MP3**
48
+ > 把这篇更新整理成双人播客,女声用 `zh-CN-XiaoxiaoMultilingualNeural`,男声用 `zh-CN-YunyiMultilingualNeural`,导出到 `episode.mp3` 和 `episode.srt`。
49
+ - **大体积录音转写 + 专有名词纠偏 + 字幕导出**
50
+ > 把工作区里的 `interview.m4a` 转写成中文(如果超过 25MB 自动压缩分段,提示词加上:DeepSeek Harness、Cordis),存成 `interview.txt` 和 `interview.srt`。
51
+ - **按范围执行离线配置自检**
52
+ > 跑一下语音插件自检(分别看看 `ttsReady` 和 `sttReady`),检查默认音色、语速音调格式、代理和 ASR 配置状态。
47
53
 
48
54
  ---
49
55
 
50
56
  ## 常见卡点自检
51
57
 
52
- 遇到问题先让助手执行 `voice_health`(纯本地检查,不发起网络请求,并明确区分哪些问题只影响 `voice_stt`):
58
+ 遇到问题先让助手执行 `voice_health`(纯本地检查,不发起网络请求;支持 `scope: "tts" | "stt" | "all"`,并分别返回 `ttsReady` 与 `sttReady`):
53
59
 
54
60
  | 现象 | 常见原因 | 一步修复 |
55
61
  | :--- | :--- | :--- |
56
- | 自检提示「缺 ASR 密钥」 | 尚未填写 `asrApiKey` 且未设 `DSH_VOICE_ASR_KEY` | 若只需朗读配音可忽略(`voice_tts` 不需要密钥);若需转写录音,在 **DSH「设置 → 插件 → 语音」**填入 `asrApiKey` 保存即生效 |
57
- | 提示音色 ID 不合法 | `ttsVoice` 拼写不符合 Edge 神经音色格式 | 让助手运行 `voice_list` 查看合法 ID(如 `zh-CN-XiaoxiaoNeural`),在设置页更新 `ttsVoice` |
58
- | `voice_tts` 或 `voice_stt` 报网络失败 | 当前网络无法直连 Edge 朗读服务或外网 ASR 接口 | 在 **DSH「设置 → 插件 → 语音」**填写 `proxyUrl`(如 `http://127.0.0.1:7890`,保存即生效) |
59
- | 提示文件必须位于会话工作区内 | 传入了工作区外部路径或越界符号链接 | 将录音复制到当前会话工作区文件夹内再执行 |
60
- | 音频超过 25MB 报超限 | OpenAI / Groq 兼容 ASR 单文件上限 25MB | 先用 `dsh-ffmpeg` 压低码率或分段裁剪后再转写 |
61
- | ASR 返回 3xx 重定向被拦截 | 为防音频与密钥被转发到第三方主机,插件拒绝自动跟随重定向 | 将 `asrBaseUrl` 直接改为服务商最终无跳转的 `/v1` 地址 |
62
+ | 自检提示「缺 ASR 密钥」 | 尚未填写 `asrApiKey` 且未设 `DSH_VOICE_ASR_KEY` | 若只需朗读配音可忽略(`ttsReady` 为 `true` 时 `voice_tts` 正常可用),或传 `scope: "tts"`;本地 Whisper 可设 `asrEngine: custom` 指向 `127.0.0.1` / `localhost` 免密运行 |
63
+ | 提示音色 ID、语速或音调不合法 | `ttsVoice` 不符合 Edge 格式,或 `ttsRate`/`ttsPitch` 非 `+10%`/`+2Hz` 格式 | 用 `voice_list` 查看合法 ID,在设置页修正 `ttsVoice`、`ttsRate`、`ttsPitch` |
64
+ | `voice_tts` 或 `voice_stt` 报网络失败 | 当前网络无法直连 Edge 朗读服务或外网 ASR 接口 | 在 **DSH「设置 → 插件 → 语音」**填写 `proxyUrl`(支持 `http://`、`https://`、`socks5://`、`socks5h://`,保存即生效) |
65
+ | 提示文件必须位于会话工作区内 | 传入了工作区外部路径或越界符号链接 | 将文稿或录音复制到当前会话工作区文件夹内再执行 |
66
+ | 音频超过 25MB 报超限 | OpenAI / Groq 兼容 ASR 单文件上限 25MB | 调用 `voice_stt` 时传入 `autoCompress: true`(调用本机 `ffmpeg` 自动转码压缩/分段),或先用 `dsh-ffmpeg` 处理 |
67
+ | ASR 返回 3xx 重定向被拦截 | 为防音频与密钥被转发到第三方主机,插件拒绝自动跟随重定向 | 将 `asrBaseUrl` 或 `ttsBaseUrl` 直接改为服务商最终无跳转的 `/v1` 地址 |
62
68
  | 同名文件没有覆盖旧文件 | 默认 `overwrite: false` 防误删,自动追加 `_1`、`_2` 序号 | 查看工具返回的实际落盘路径,或在设置中显式开启 `overwrite` |
63
69
 
64
70
  ---
@@ -69,17 +75,20 @@
69
75
 
70
76
  | 工具 | 作用 | 关键参数与说明 |
71
77
  | :--- | :--- | :--- |
72
- | `voice_tts` | 文字合成 MP3(零密钥 Edge 在线神经语音) | `text` 必填(≤5000 字符);`voice` / `rate` / `pitch` / `output` 可选 |
73
- | `voice_stt` | 音频转文字(Groq / OpenAI / 自定义兼容端点) | `audio` 必填(≤25MB);`model` / `language` / `prompt` / `output` 可选 |
74
- | `voice_list` | 查看内置常用多语种与方言音色目录 | 无参数 |
75
- | `voice_preview` | 有界并发(最多 3 路)批量生成短试听 MP3 | `voices`(最多 8 个)/ `text`(≤200 字)/ `outputDir` 可选 |
76
- | `voice_health` | 本地配置自检(不触网) | 逐项检查默认音色、代理、ASR 引擎/地址/密钥与影响面 |
77
-
78
- ### 安全与文件保护细节
79
-
80
- - **工作区沙箱与符号链接防护**:所有读写路径解析后必须位于 `session.header.cwd` 内;拒绝跟随符号链接覆写,新建文件使用 `O_EXCL` 防止并发竞态覆盖,转写 `.txt` 在类 Unix 系统以 `0600` 权限写入。
81
- - **防凭据串台与防重定向泄露**:ASR 请求固定发往配置的 `asrBaseUrl`,拒绝模型调用时用 `engine` 临时切到其他厂商,且遇 `3xx` 重定向立即中止上传。
82
- - **随时可取消**:`voice_tts`、`voice_preview` 与 `voice_stt` 全程透传 `exec.signal`,用户点击停止即刻关闭 WebSocket 或中止上传。
78
+ | `voice_tts` | 文字/文稿/播客合成 MP3 与字幕 | 支持 `text`、`inputFile`(≤10 万字自动分片拼接)、`cleanMarkdown`(`.md` 默认开启)、`segments`(最多 50 段多角色对话与 `pauseMs`)、`subtitleOutput`(`.srt`/`.vtt`)、`voice`、`rate`、`pitch`、`output` |
79
+ | `voice_stt` | 音频转文字与字幕(零拷贝流式上传) | `audio` 必填;支持 `autoCompress`(>25MB 用本机 `ffmpeg` 自动压缩分段)、`timestamps`、`subtitleOutput`(`.srt`/`.vtt`)、`model`、`language`、`prompt`、`output`、`engine` |
80
+ | `voice_list` | 查看并筛选内置多语种与方言音色目录 | 可选 `locale`(语种/地区子串)、`gender`(`Female`/`Male`)、`tag`(如 `podcast`/`multilingual`/`dialect`) |
81
+ | `voice_preview` | 有界并发(≤3)批量试听并生成网页试听页 | 可选 `voices`(≤8)、`text`(≤200 字)、`outputDir`、`htmlIndex`(默认 `true`,生成 `voice_previews/index.html`) |
82
+ | `voice_health` | 本地配置自检(不触网) | 可选 `scope`(`all`/`tts`/`stt`),返回 `ttsReady` / `sttReady` 并校验引擎、音色、语速音调、代理与密钥 |
83
+
84
+ ### 引擎预设与安全细节
85
+
86
+ - **引擎预设**:
87
+ - `asrEngine`:`groq`(`whisper-large-v3-turbo`)、`openai`(`whisper-1`)、`siliconflow`(`FunAudioLLM/SenseVoiceSmall`)、`custom`(支持本地回环地址免密钥)。
88
+ - `ttsEngine`:`edge`(零密钥默认)、`openai`(`gpt-4o-mini-tts`)、`siliconflow`(`FunAudioLLM/CosyVoice2-0.5B`)、`custom`(OpenAI `/audio/speech` 兼容端点)。
89
+ - **工作区沙箱与符号链接防护**:所有读写路径解析后必须位于 `session.header.cwd` 内;拒绝跟随符号链接覆写,新建文件使用 `O_EXCL` 防止并发竞态覆盖,转写 `.txt` 与字幕在类 Unix 系统以 `0600` 权限写入。
90
+ - **防凭据串台与防重定向泄露**:ASR 与 TTS 请求固定发往配置端点,拒绝模型调用时用 `engine` 临时切换厂商,遇 `3xx` 重定向立即中止请求。
91
+ - **动态超时与随时可取消**:`timeoutMs` 随设置热更新即时生效;`voice_tts`、`voice_preview` 与 `voice_stt` 全程透传 `exec.signal`,取消即关闭连接或中止压缩/上传。
83
92
 
84
93
  ## 安装、卸载与开发
85
94
 
package/lib/config.d.ts CHANGED
@@ -1,14 +1,22 @@
1
1
  /**
2
- * dsh-voice 配置解析:TTS 默认音色与语速、ASR 引擎与密钥、代理。
2
+ * dsh-voice 配置解析:TTS 引擎与默认音色语速、ASR 引擎与密钥、代理。
3
3
  *
4
4
  * @module dsh-voice/config
5
5
  */
6
+ /** TTS 引擎类型。 */
7
+ export type TtsEngine = 'edge' | 'openai' | 'siliconflow' | 'custom';
8
+ /** ASR 引擎类型。 */
9
+ export type AsrEngine = 'groq' | 'openai' | 'siliconflow' | 'custom';
6
10
  /** 插件行配置(cordis.patch.yml 里的 config 段,可缺省)。 */
7
11
  export interface VoiceConfig {
12
+ ttsEngine?: TtsEngine;
13
+ ttsBaseUrl?: string;
14
+ ttsApiKey?: string;
15
+ ttsModel?: string;
8
16
  ttsVoice?: string;
9
17
  ttsRate?: string;
10
18
  ttsPitch?: string;
11
- asrEngine?: 'groq' | 'openai' | 'custom';
19
+ asrEngine?: AsrEngine;
12
20
  asrBaseUrl?: string;
13
21
  asrApiKey?: string;
14
22
  asrModel?: string;
@@ -18,10 +26,14 @@ export interface VoiceConfig {
18
26
  }
19
27
  /** 解析后的配置。 */
20
28
  export interface ResolvedVoiceConfig {
29
+ ttsEngine: TtsEngine;
30
+ ttsBaseUrl: string;
31
+ ttsApiKey: string;
32
+ ttsModel: string;
21
33
  ttsVoice: string;
22
34
  ttsRate: string;
23
35
  ttsPitch: string;
24
- asrEngine: 'groq' | 'openai' | 'custom';
36
+ asrEngine: AsrEngine;
25
37
  asrBaseUrl: string;
26
38
  asrApiKey: string;
27
39
  asrModel: string;
@@ -29,8 +41,22 @@ export interface ResolvedVoiceConfig {
29
41
  timeoutMs: number;
30
42
  overwrite: boolean;
31
43
  }
44
+ export declare const ASR_PRESETS: Record<'groq' | 'openai' | 'siliconflow', {
45
+ baseUrl: string;
46
+ model: string;
47
+ }>;
48
+ export declare const TTS_PRESETS: Record<'openai' | 'siliconflow', {
49
+ baseUrl: string;
50
+ model: string;
51
+ }>;
52
+ /** 校验 SSML prosody 参数(语速 / 音调),如 +0%、-15%、+2Hz、-1st。 */
53
+ export declare function isValidProsody(value: string): boolean;
54
+ /** 判断 baseUrl 是否指向本机回环地址(用于允许本地无密钥服务)。 */
55
+ export declare function isLoopbackBaseUrl(url: string): boolean;
32
56
  /** ASR 密钥:配置优先,其次环境变量 DSH_VOICE_ASR_KEY。 */
33
57
  export declare function resolveAsrApiKey(config: VoiceConfig | undefined, env?: NodeJS.ProcessEnv): string;
58
+ /** TTS 密钥:配置优先,其次环境变量 DSH_VOICE_TTS_KEY。 */
59
+ export declare function resolveTtsApiKey(config: VoiceConfig | undefined, env?: NodeJS.ProcessEnv): string;
34
60
  /**
35
61
  * 解析并校验配置:非法字段逐项回退到默认值,其余字段照常生效。
36
62
  * @param onWarning 非法字段的告警回调,默认打到 console.warn。