dsh-laivox-tts 0.7.14 → 0.7.16

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/README.en.md ADDED
@@ -0,0 +1,120 @@
1
+ # Novel voices (LaiVox)
2
+
3
+ [简体中文](README.md) · **English**
4
+
5
+ An audiobook plugin for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH). Turn TXT, EPUB, and PDF novels into single-voice or multi-voice audiobooks, or have AI replies read aloud with one click. Built-in Microsoft Edge online voices work out of the box with no account required, and the workbench supports Simplified Chinese, Traditional Chinese, and English.
6
+
7
+ ![The LaiVox workbench: bookshelf, chapter text and player](assets/screenshots/listen.png)
8
+
9
+ ## What you can do
10
+
11
+ - **Turn books into audio**: Import TXT, EPUB, or PDF novels with automatic chapter detection and preview, or paste text into a new book. Pick a chapter and press **Start production**—playback begins as soon as the first segment is ready.
12
+ - **Single-voice or multi-voice narration**: **Single voice** works immediately without AI. Switch to **Multi-voice narration** to let your configured DSH model identify speakers and tone and assign a distinct voice to each role. You see the expected request count and confirm before any model call. Edge switches voices per role, while per-line expressive delivery uses LaiVox.
13
+ - **Use LaiVox expressive voices (optional)**: Under **Settings → Production & Voice Engine**, switch the engine to LaiVox for per-line expressive delivery and access to **My voices** uploaded in the LaiVox browser extension. Requires an API key backed by a LaiVox membership reading allowance or a separately purchased read-aloud pack.
14
+ - **Let AI help organize and queue**: Ask AI in chat to turn a book in your workspace into an audiobook. It prepares an import preview and a production plan below its reply, waits for your confirmation, and queues AI jobs behind your own without interrupting active playback or production.
15
+ - **Read AI replies and quick snippets aloud**: Click **Read aloud with Edge** next to any assistant message, or ask the assistant to read aloud (code blocks and URLs are skipped, table cells are read). You can also send `/laivox some text` to voice a passage—results stay organized under **Bookshelf → Chat audio**.
16
+ - **Export for offline listening**: Download a single chapter as MP3 or WAV, or export an entire book as a ZIP archive of chapter audio files.
17
+
18
+ Step-by-step walkthroughs are in the [user guide](docs/GUIDE.md) (Chinese).
19
+
20
+ | Roles and voices | Import preview | Chat audio | Dark theme |
21
+ |---|---|---|---|
22
+ | ![Roles](assets/screenshots/roles.png) | ![Import](assets/screenshots/import.png) | ![Chat audio](assets/screenshots/snippets.png) | ![Dark theme](assets/screenshots/listen-dark.png) |
23
+
24
+ ## Install
25
+
26
+ Make sure the `dsh` command is available:
27
+
28
+ - **DSH Desktop**: open the application menu and choose **Manage dsh Command… → Install** (below **Check for Updates…**). Open a new terminal and run `dsh --version` to verify. Desktop uses the `desktop` profile. Launch Desktop once before installing, then **fully quit it** (including from the system tray) before running the commands below. See the [official Desktop docs](https://github.com/deepseek-ai/deepseek-harness/blob/38a6a5c/apps/desktop/README.md#terminal-command).
29
+ - **DSH Web / CLI**: requires Node.js 24.9 or later. Replace `desktop` with `web` (or your own profile name) in the commands below.
30
+
31
+ ### Online install (recommended)
32
+
33
+ ```sh
34
+ dsh plugin --profile desktop add dsh-laivox-tts
35
+ ```
36
+
37
+ This installs the prebuilt package from npm—nothing is compiled locally and no install scripts run.
38
+
39
+ ### Install from GitHub Release or offline package
40
+
41
+ If npm is unavailable or you prefer pinning a release tarball, install via URL or download `dsh-laivox-tts.tgz` from [Releases](https://github.com/xiaolai181/dsh_laivox_tts/releases) (replace `latest/download` with `download/v0.7.16` to pin a version):
42
+
43
+ ```sh
44
+ dsh plugin --profile desktop add "https://github.com/xiaolai181/dsh_laivox_tts/releases/latest/download/dsh-laivox-tts.tgz"
45
+ # Or from a downloaded local file:
46
+ dsh plugin --profile desktop add ./dsh-laivox-tts.tgz
47
+ ```
48
+
49
+ <details>
50
+ <summary>Install from a source folder (for developers)</summary>
51
+
52
+ ```sh
53
+ git clone https://github.com/xiaolai181/dsh_laivox_tts.git laivox-tts
54
+ cd laivox-tts
55
+ npx pnpm install # pnpm is required; this also builds lib/
56
+ dsh plugin --profile desktop add .
57
+ ```
58
+
59
+ The profile links directly to this folder, so keep it in place. After `git pull`, run `npx pnpm install` again to rebuild.
60
+
61
+ > **Switching back from a source install to a release package**: after `dsh plugin remove`, a `dsh-laivox-tts` link remains inside the profile's `node_modules`. Remove only that link (on Windows, use `rmdir` without `/s`) before reinstalling so files in your source folder are not deleted.
62
+
63
+ </details>
64
+
65
+ ### After installing
66
+
67
+ - **Desktop**: reopen DeepSeek Harness. **Web**: restart `dsh web`.
68
+ - **Novel voices (LaiVox)** appears in the sidebar.
69
+ - Verify installed plugins with `dsh plugin --profile desktop list`.
70
+
71
+ ### Update and uninstall
72
+
73
+ - **Update**: run the install command again (`latest/download` pulls the newest release).
74
+ - **Uninstall**: run `dsh plugin --profile desktop remove dsh-laivox-tts`. Your books and audio remain on disk.
75
+
76
+ ## First five minutes
77
+
78
+ Choose your preferred language under **DSH Settings → General → Language** (Simplified Chinese, Traditional Chinese, or English).
79
+
80
+ 1. Open **Novel voices (LaiVox)** from the sidebar. The workbench has three tabs: **Listen**, **Produce**, and **Bookshelf**, with tasks and settings in the top right.
81
+ 2. On a fresh empty profile, first launch places two ready-to-play sample books on your bookshelf—a single-voice Edge sample and a multi-voice LaiVox sample—so you can listen right away without an API key and delete them anytime.
82
+ 3. Go to **Bookshelf → Import TXT / EPUB / PDF** to pick a novel (or click **New book** to paste text). Adjust chapter splits if needed and confirm the import.
83
+ 4. Open a chapter, select **Single voice**, and click **Start production** (no AI required). Playback starts once the first segment is ready, with speed control, sleep timer, bookmarks, follow-along highlighting, and optional auto-advance to the next chapter.
84
+
85
+ ## Privacy and cost
86
+
87
+ - **Microsoft Edge online voices**: Built in as the default with no account needed. Text being voiced is sent to Microsoft's online Edge speech service; availability and terms are governed by Microsoft.
88
+ - **AI features**: Text cleanup, multi-voice scripting, and AI chapter detection use the model configured in DSH and count against that model's quota. Every step displays the expected request count and waits for your confirmation. **Single voice** never calls a model.
89
+ - **LaiVox engine (optional add-on)**: Enable under **Settings → Production & Voice Engine** with an API key backed by a membership reading allowance or a separately purchased read-aloud pack. Text submitted for synthesis is sent to the LaiVox service under its service and retention policies. The API key is stored in DSH's credential store and LaiVox is only contacted when you use it. Uploading and editing custom voices stay in the LaiVox browser extension.
90
+ - **Rights and boundaries**: Import and voice only texts you own or are legally permitted to use; generated audio is for personal, lawful use. The AI assistant can only read files inside the current chat workspace and cannot delete books from your bookshelf.
91
+
92
+ ## Local data and storage
93
+
94
+ Your bookshelf, text, scripts, and audio stay on your machine:
95
+
96
+ - **Audio storage limit**: 2 GiB by default, configurable from 0.5 to 20 GiB under **Settings → Storage** (takes effect after reopening DSH). Production pauses if the limit is reached; you can clear audio per book or chapter while keeping text and scripts intact.
97
+ - **Chat audio retention**: Unplayed chat audio expires after 7 days by default (configurable to 1 day, 30 days, or never). Saving a clip to the bookshelf keeps it permanently.
98
+ - **Complete removal**: Uninstall the plugin and delete its plugin data folder to wipe all local files.
99
+
100
+ <details>
101
+ <summary>Data folder and backup notes before upgrading</summary>
102
+
103
+ - All plugin data lives in `<DSH home>/profiles/<profile>/dsh-laivox-tts/` (default DSH home: `~/.dsh`), with `library.sqlite` storing your bookshelf, scripts, jobs, audio, and playback progress.
104
+ - **Back up before upgrading**: fully quit DSH and copy the entire `dsh-laivox-tts` folder. A newer release may upgrade the local database schema (currently v13), which older plugin versions cannot open.
105
+ - Built-in sample books are seeded only once on a fresh empty profile (existing profiles with books are untouched on upgrade) and will not reappear after deletion.
106
+
107
+ </details>
108
+
109
+ <details>
110
+ <summary>File limits and usage notes</summary>
111
+
112
+ - **PDF support**: Text-based PDFs are supported; image-only scanned PDFs are not supported.
113
+ - **Import limits**: Up to 50 MiB per file; EPUB archives up to 150 MiB uncompressed (32 MiB per internal file); PDFs up to 5,000 pages or 30 million characters; up to 5,000 chapters per book.
114
+ - **Chat behavior**: Confirmation controls, import previews, and outcomes appear only below the latest reply. The first read-aloud sentence usually takes 1–2 seconds to start (0.5–1 second for subsequent sentences). If the same chat is open in two windows, AI-triggered read-aloud plays in both.
115
+
116
+ </details>
117
+
118
+ ## License
119
+
120
+ The LaiVox plugin code is released under the [MIT License](LICENSE). The LaiVox TTS server and access to it are not covered. The LaiVox brand, icons and preset voice samples are under their own terms. See [Third-party notices](THIRD_PARTY_NOTICES.md).
package/README.md CHANGED
@@ -1,120 +1,122 @@
1
- # Novel voices (LaiVox)
1
+ # 小说配音(LaiVox)
2
2
 
3
- **English** · [简体中文](README.zh-CN.md)
3
+ **简体中文** · [English](README.en.md)
4
4
 
5
- An audiobook plugin for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH). Turn TXT, EPUB, and PDF novels into single-voice or multi-voice audiobooks, or have AI replies read aloud with one click. Built-in Microsoft Edge online voices work out of the box with no account required, and the workbench supports Simplified Chinese, Traditional Chinese, and English.
5
+ [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(DSH)的有声书插件:把 TXT、EPUB、PDF 小说做成单人朗读或多角色有声书,也能一键把 AI 的回答读给你听。默认内置微软 Edge 在线语音,无需注册账号,支持简体中文、繁体中文与英文。
6
6
 
7
- ![The LaiVox workbench: bookshelf, chapter text and player](assets/screenshots/listen.png)
7
+ ![LaiVox 工作台:书架、正文与播放器](assets/screenshots/listen.png)
8
8
 
9
- ## What you can do
9
+ ## 你能用它做什么
10
10
 
11
- - **Turn books into audio**: Import TXT, EPUB, or PDF novels with automatic chapter detection and preview, or paste text into a new book. Pick a chapter and press **Start production**—playback begins as soon as the first segment is ready.
12
- - **Single-voice or multi-voice narration**: **Single voice** works immediately without AI. Switch to **Multi-voice narration** to let your configured DSH model identify speakers and tone and assign a distinct voice to each role. You see the expected request count and confirm before any model call. Edge switches voices per role, while per-line expressive delivery uses LaiVox.
13
- - **Use LaiVox expressive voices (optional)**: Under **Settings → Production & Voice Engine**, switch the engine to LaiVox for per-line expressive delivery and access to **My voices** uploaded in the LaiVox browser extension. Requires an API key backed by a LaiVox membership reading allowance or a separately purchased read-aloud pack.
14
- - **Let AI help organize and queue**: Ask AI in chat to turn a book in your workspace into an audiobook. It prepares an import preview and a production plan below its reply, waits for your confirmation, and queues AI jobs behind your own without interrupting active playback or production.
15
- - **Read AI replies and quick snippets aloud**: Click **Read aloud with Edge** next to any assistant message, or ask the assistant to read aloud (code blocks and URLs are skipped, table cells are read). You can also send `/laivox some text` to voice a passage—results stay organized under **Bookshelf → Chat audio**.
16
- - **Export for offline listening**: Download a single chapter as MP3 or WAV, or export an entire book as a ZIP archive of chapter audio files.
11
+ - **听手里的小说**:导入 TXT、EPUB 或 PDF,自动分章并预览目录;也可以直接新建书籍粘贴正文。选好章节点击「开始制作」,第一段完成即可开听,不用等整章做完。
12
+ - **单人朗读,或多角色配音**:单人朗读开箱即用;选择「多角色演绎」后,由你在 DSH 中配置的模型分辨说话人和语气,为每个角色分配独立音色。开始前会列出预计请求数,由你确认后才调用模型。Edge 引擎会按角色切换不同音色,逐句情绪演绎需使用 LaiVox 引擎。
13
+ - **使用 LaiVox 拟人音色(可选)**:在设置的「制作与发声」中切换为 LaiVox。支持按每句语气做拟人化情感演绎,账号开通自有音色后,也可直接选用在 LaiVox 浏览器扩展里上传的「我的音色」。使用会员朗读额度或单独购买的朗读时长包,填入 API Key 即可启用。
14
+ - **让 AI 当你的有声书助手**:在对话里直接说“把工作目录里的 book.txt 做成有声书”,AI 会在回答下方准备好导入预览和制作计划。点击确认后才会导入与制作,且任务自动排在已有队列之后,不会打断你正在听或正在做的书。
15
+ - **一键听 AI 回答,随手朗读片段**:点击回答下方的「用 Edge 朗读」,或直接说“读给我听”,系统会自动跳过代码块与链接地址,并读出表格文字;在输入框发送 `/laivox 一段文字` 也能快速生成音频,结果收纳在「书架 → 对话音频」。
16
+ - **导出带走**:支持单章导出 MP3 / WAV,或将整本书打包导出为按章命名的 ZIP。
17
17
 
18
- Step-by-step walkthroughs are in the [user guide](docs/GUIDE.md) (Chinese).
18
+ 更完整的场景操作说明见 [使用指南](docs/GUIDE.md)。
19
19
 
20
- | Roles and voices | Import preview | Chat audio | Dark theme |
20
+ | 角色与音色 | 导入预览 | 对话音频 | 深色主题 |
21
21
  |---|---|---|---|
22
- | ![Roles](assets/screenshots/roles.png) | ![Import](assets/screenshots/import.png) | ![Chat audio](assets/screenshots/snippets.png) | ![Dark theme](assets/screenshots/listen-dark.png) |
22
+ | ![角色](assets/screenshots/roles.png) | ![导入](assets/screenshots/import.png) | ![对话音频](assets/screenshots/snippets.png) | ![深色主题](assets/screenshots/listen-dark.png) |
23
23
 
24
- ## Install
24
+ ## 安装
25
25
 
26
- Make sure the `dsh` command is available:
26
+ 安装前先准备好 `dsh` 命令:
27
27
 
28
- - **DSH Desktop**: open the application menu and choose **Manage dsh Command… → Install** (below **Check for Updates…**). Open a new terminal and run `dsh --version` to verify. Desktop uses the `desktop` profile. Launch Desktop once before installing, then **fully quit it** (including from the system tray) before running the commands below. See the [official Desktop docs](https://github.com/deepseek-ai/deepseek-harness/blob/38a6a5c/apps/desktop/README.md#terminal-command).
29
- - **DSH Web / CLI**: requires Node.js 24.9 or later. Replace `desktop` with `web` (or your own profile name) in the commands below.
28
+ - **DSH 桌面版**:在「应用程序」菜单中选「管理 dsh 命令…」→「安装」(位于「检查更新」下方),打开新终端执行 `dsh --version` 确认可用。桌面版的默认 Profile 名为 `desktop`。安装插件前请先启动一次桌面版,再**完全退出**(包括系统托盘),然后执行下方命令。详见 [官方桌面版文档](https://github.com/deepseek-ai/deepseek-harness/blob/38a6a5c/apps/desktop/README.zh.md#终端命令)。
29
+ - **DSH Web / 命令行版**:需要 Node.js 24.9 或更高版本,示例中使用 Profile 名 `web`。
30
30
 
31
- ### Online install (recommended)
31
+ 如使用其他 Profile,将命令中的 `desktop` 替换为你的 Profile 名称即可。
32
+
33
+ ### 在线安装(推荐)
32
34
 
33
35
  ```sh
34
36
  dsh plugin --profile desktop add dsh-laivox-tts
35
37
  ```
36
38
 
37
- This installs the prebuilt package from npm—nothing is compiled locally and no install scripts run.
39
+ 直接安装 npm 上的预构建插件包,无需在本地编译或授权构建脚本(国内网络可自动受益于镜像加速)。
38
40
 
39
- ### Install from GitHub Release or offline package
41
+ ### GitHub Release 链接或离线安装包安装
40
42
 
41
- If npm is unavailable or you prefer pinning a release tarball, install via URL or download `dsh-laivox-tts.tgz` from [Releases](https://github.com/xiaolai181/dsh_laivox_tts/releases) (replace `latest/download` with `download/v0.7.14` to pin a version):
43
+ 如需锁定版本或无法直连 npm,可使用 Release 下载链接(将 `latest/download` 替换为 `download/v0.7.16` 可锁定版本),或从 [Releases](https://github.com/xiaolai181/dsh_laivox_tts/releases) 下载 `dsh-laivox-tts.tgz` 到本地后安装:
42
44
 
43
45
  ```sh
44
46
  dsh plugin --profile desktop add "https://github.com/xiaolai181/dsh_laivox_tts/releases/latest/download/dsh-laivox-tts.tgz"
45
- # Or from a downloaded local file:
47
+ # 或使用本地文件:
46
48
  dsh plugin --profile desktop add ./dsh-laivox-tts.tgz
47
49
  ```
48
50
 
49
51
  <details>
50
- <summary>Install from a source folder (for developers)</summary>
52
+ <summary>从源码目录安装(开发者)</summary>
51
53
 
52
54
  ```sh
53
55
  git clone https://github.com/xiaolai181/dsh_laivox_tts.git laivox-tts
54
56
  cd laivox-tts
55
- npx pnpm install # pnpm is required; this also builds lib/
57
+ npx pnpm install # 必须使用 pnpm,安装时会自动构建 lib/
56
58
  dsh plugin --profile desktop add .
57
59
  ```
58
60
 
59
- The profile links directly to this folder, so keep it in place. After `git pull`, run `npx pnpm install` again to rebuild.
61
+ Profile 会直接链接到该源码目录,安装后请勿移动或删除。执行 `git pull` 更新源码后,需再次运行 `npx pnpm install` 重新构建。
60
62
 
61
- > **Switching back from a source install to a release package**: after `dsh plugin remove`, a `dsh-laivox-tts` link remains inside the profile's `node_modules`. Remove only that link (on Windows, use `rmdir` without `/s`) before reinstalling so files in your source folder are not deleted.
63
+ > **从源码安装改回插件包安装时**:执行 `dsh plugin remove` 后,Profile 的 `node_modules` 下仍会保留 `dsh-laivox-tts` 目录链接。请先只删除该链接本身(Windows 上使用不带 `/s` 的 `rmdir`),再安装插件包,避免误删源码目录内的文件。
62
64
 
63
65
  </details>
64
66
 
65
- ### After installing
67
+ ### 安装完成后
66
68
 
67
- - **Desktop**: reopen DeepSeek Harness. **Web**: restart `dsh web`.
68
- - **Novel voices (LaiVox)** appears in the sidebar.
69
- - Verify installed plugins with `dsh plugin --profile desktop list`.
69
+ - **桌面版**:重新打开 DeepSeek Harness。**Web 版**:重启 `dsh web`。
70
+ - 左侧栏会出现「小说配音(LaiVox)」。
71
+ - 可通过 `dsh plugin --profile desktop list` 查看安装状态。
70
72
 
71
- ### Update and uninstall
73
+ ### 更新与卸载
72
74
 
73
- - **Update**: run the install command again (`latest/download` pulls the newest release).
74
- - **Uninstall**: run `dsh plugin --profile desktop remove dsh-laivox-tts`. Your books and audio remain on disk.
75
+ - **更新**:重新运行一次安装命令即可(使用 `latest/download` 会自动获取最新版)。
76
+ - **卸载**:运行 `dsh plugin --profile desktop remove dsh-laivox-tts`。已导入的书籍与生成的音频会保留在本机。
75
77
 
76
- ## First five minutes
78
+ ## 五分钟上手
77
79
 
78
- Choose your preferred language under **DSH Settings → General → Language** (Simplified Chinese, Traditional Chinese, or English).
80
+ 可在 **DSH 设置 → 通用设置 → 语言** 中切换简体中文、繁体中文或英文,工作台会同步跟随。
79
81
 
80
- 1. Open **Novel voices (LaiVox)** from the sidebar. The workbench has three tabs: **Listen**, **Produce**, and **Bookshelf**, with tasks and settings in the top right.
81
- 2. On a fresh empty profile, first launch places two ready-to-play sample books on your bookshelf—a single-voice Edge sample and a multi-voice LaiVox sample—so you can listen right away without an API key and delete them anytime.
82
- 3. Go to **Bookshelf → Import TXT / EPUB / PDF** to pick a novel (or click **New book** to paste text). Adjust chapter splits if needed and confirm the import.
83
- 4. Open a chapter, select **Single voice**, and click **Start production** (no AI required). Playback starts once the first segment is ready, with speed control, sleep timer, bookmarks, follow-along highlighting, and optional auto-advance to the next chapter.
82
+ 1. 从侧栏打开「小说配音(LaiVox)」。工作台顶部有三个页签:**收听**、**制作**、**书架**,右上角为任务列表与设置。
83
+ 2. 首次打开若书架为空,会自动放好两本免 Key 试听示例:《社戏 · 月夜行船 · Edge》(Edge 单人朗读)与《绿野仙踪 · 营救铁皮人 · LaiVox》(LaiVox 多角色配音),点开即可直接试听,不需要时可随时删除。
84
+ 3. 在 **书架 →「导入 TXT / EPUB / PDF」** 选择小说文件(或点击「新建书籍」粘贴正文)。分章有误时可点击标题调整,确认后导入。
85
+ 4. 打开章节,选择「单人朗读」并点击「开始制作」(无需调用 AI);第一段生成完毕即可播放,支持倍速、定时关闭、书签、随读高亮与自动续播下一章(可在设置中关闭)。
84
86
 
85
- ## Privacy and cost
87
+ ## 隐私与费用
86
88
 
87
- - **Microsoft Edge online voices**: Built in as the default with no account needed. Text being voiced is sent to Microsoft's online Edge speech service; availability and terms are governed by Microsoft.
88
- - **AI features**: Text cleanup, multi-voice scripting, and AI chapter detection use the model configured in DSH and count against that model's quota. Every step displays the expected request count and waits for your confirmation. **Single voice** never calls a model.
89
- - **LaiVox engine (optional add-on)**: Enable under **Settings → Production & Voice Engine** with an API key backed by a membership reading allowance or a separately purchased read-aloud pack. Text submitted for synthesis is sent to the LaiVox service under its service and retention policies. The API key is stored in DSH's credential store and LaiVox is only contacted when you use it. Uploading and editing custom voices stay in the LaiVox browser extension.
90
- - **Rights and boundaries**: Import and voice only texts you own or are legally permitted to use; generated audio is for personal, lawful use. The AI assistant can only read files inside the current chat workspace and cannot delete books from your bookshelf.
89
+ - **微软 Edge 在线语音**:默认内置,无需注册账号。待朗读或合成的文字会发送至微软 Edge 在线语音服务,服务可用性与条款受微软方约束。
90
+ - **AI 辅助功能**:正文清洗、多角色演绎编剧与 AI 辅助分章会使用你在 DSH 中配置的模型,并计入对应模型额度;每一步都会先展示预计请求数,经你确认后才会调用。单人朗读从不调用模型。
91
+ - **LaiVox 引擎(可选增值)**:在设置的「制作与发声」中开启并保存 API Key。支持使用会员朗读额度或单独购买的朗读时长包,合成文字会发送至 LaiVox 服务并按其隐私与保留策略处理;API Key 保存在 DSH 凭据服务中,仅在使用 LaiVox 时连接服务。自有音色的上传与管理仍在 LaiVox 浏览器扩展中进行。
92
+ - **版权与权限边界**:请仅导入并制作你拥有合法使用权的文本,生成的音频仅供个人合规使用。AI 助手仅能读取当前对话的工作目录,无法删除书架中的任何书籍。
91
93
 
92
- ## Local data and storage
94
+ ## 数据与本地存储
93
95
 
94
- Your bookshelf, text, scripts, and audio stay on your machine:
96
+ 你的书架、正文、台词与已生成的音频全部保存在本机:
95
97
 
96
- - **Audio storage limit**: 2 GiB by default, configurable from 0.5 to 20 GiB under **Settings → Storage** (takes effect after reopening DSH). Production pauses if the limit is reached; you can clear audio per book or chapter while keeping text and scripts intact.
97
- - **Chat audio retention**: Unplayed chat audio expires after 7 days by default (configurable to 1 day, 30 days, or never). Saving a clip to the bookshelf keeps it permanently.
98
- - **Complete removal**: Uninstall the plugin and delete its plugin data folder to wipe all local files.
98
+ - **存储上限**:音频缓存默认上限为 2 GiB,可在「设置 → 存储」中调整为 0.5~20 GiB(修改后重新打开 DSH 生效)。空间达到上限时会暂停新制作,你可以随时按书或按章清理音频,正文和台词会保留。
99
+ - **对话音频清理**:通过对话生成的朗读音频若超过 7 天未收听会自动清理,可在设置中改为 1 天、30 天或永不清理;转存到书架后将永久保留。
100
+ - **彻底清除**:卸载插件后删除对应的插件数据目录即可完全清除本地数据。
99
101
 
100
102
  <details>
101
- <summary>Data folder and backup notes before upgrading</summary>
103
+ <summary>数据目录与升级前备份说明</summary>
102
104
 
103
- - All plugin data lives in `<DSH home>/profiles/<profile>/dsh-laivox-tts/` (default DSH home: `~/.dsh`), with `library.sqlite` storing your bookshelf, scripts, jobs, audio, and playback progress.
104
- - **Back up before upgrading**: fully quit DSH and copy the entire `dsh-laivox-tts` folder. A newer release may upgrade the local database schema (currently v13), which older plugin versions cannot open.
105
- - Built-in sample books are seeded only once on a fresh empty profile (existing profiles with books are untouched on upgrade) and will not reappear after deletion.
105
+ - 所有数据位于当前 Profile 目录下的 `<DSH 主目录>/profiles/<Profile 名>/dsh-laivox-tts/`(DSH 主目录默认为 `~/.dsh`),其中 `library.sqlite` 保存书架、台词、任务、音频与播放进度。
106
+ - **升级前建议备份**:完全退出 DSH 后复制整个 `dsh-laivox-tts` 目录。跨版本更新可能升级本地数据库结构(当前为 v13),升级后的数据库无法再被旧版本插件打开。
107
+ - 内置试听示例仅在全新空白 Profile 首次启动时写入一次(已有书籍的老 Profile 升级不会写入),删除后重启或升级不会重新出现。
106
108
 
107
109
  </details>
108
110
 
109
111
  <details>
110
- <summary>File limits and usage notes</summary>
112
+ <summary>文件规格与使用须知</summary>
111
113
 
112
- - **PDF support**: Text-based PDFs are supported; image-only scanned PDFs are not supported.
113
- - **Import limits**: Up to 50 MiB per file; EPUB archives up to 150 MiB uncompressed (32 MiB per internal file); PDFs up to 5,000 pages or 30 million characters; up to 5,000 chapters per book.
114
- - **Chat behavior**: Confirmation controls, import previews, and outcomes appear only below the latest reply. The first read-aloud sentence usually takes 1–2 seconds to start (0.5–1 second for subsequent sentences). If the same chat is open in two windows, AI-triggered read-aloud plays in both.
114
+ - **PDF 支持**:支持包含可选中文字的 PDF,暂不支持纯图片扫描版。
115
+ - **导入限制**:单个文件最大 50 MiB;EPUB 解压后不超过 150 MiB(其中单个内部文件不超过 32 MiB);PDF 不超过 5,000 页或 3,000 万字;单本书籍最多 5,000 章。
116
+ - **对话交互说明**:确认操作按钮、导入预览与生成结果仅挂在最新一轮回答下方;朗读首句通常约需 1~2 秒准备,后续段落约 0.5~1 秒;同一对话在多个窗口同时打开时,由 AI 发起的朗读会在这些窗口同步播放。
115
117
 
116
118
  </details>
117
119
 
118
- ## License
120
+ ## 许可
119
121
 
120
- The LaiVox plugin code is released under the [MIT License](LICENSE). The LaiVox TTS server and access to it are not covered. The LaiVox brand, icons and preset voice samples are under their own terms. See [Third-party notices](THIRD_PARTY_NOTICES.md).
122
+ LaiVox 自有的插件代码采用 [MIT 许可证](LICENSE),LaiVox TTS 服务端和服务访问权限不在此范围内。LaiVox 品牌、图标和预置试听音频按各自的授权使用,详见 [许可与第三方声明](THIRD_PARTY_NOTICES.md)。
package/lib/client.js CHANGED
@@ -881,7 +881,7 @@ var en_default = {
881
881
  \u5408\u6210\u97F3\u9891: "Synthesizing audio",
882
882
  \u8BD5\u7528: "Trial",
883
883
  \u57FA\u7840\u7248: "Basic",
884
- \u8FDB\u9636\u7248: "Pro",
884
+ Pro: "Pro",
885
885
  \u7BA1\u7406\u5458: "Administrator",
886
886
  \u672A\u5F00\u901A: "Inactive",
887
887
  "{v1} \xB7 \u9000\u6B3E\u5BA1\u6838\u4E2D\uFF0C\u4E91\u7AEF\u5DF2\u6682\u505C": "{v1} \xB7 Cloud access paused while a refund is under review",
@@ -1266,6 +1266,7 @@ var en_default = {
1266
1266
  "\u6717\u8BFB\u989D\u5EA6\u6309\u603B\u989D\u8BA1\u7B97\uFF0C\u4E0D\u9700\u8981\u5F00\u542F\u4F7F\u7528\u65E5\u3002": "The read-aloud allowance is a total, so there are no usage days to open.",
1267
1267
  "\u65F6\u957F\u5305\u4EF7\u683C\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002": "The pack price could not be read right now.",
1268
1268
  "\u65F6\u957F\u5305 {v1}\uFF0C{v2} \u5C0F\u65F6\u6717\u8BFB\uFF0C\u8D2D\u4E70\u540E {v3} \u5929\u5185\u6709\u6548\u3002\u7528\u5230 {v4}% \u540E\u53EF\u518D\u4E70\u3002": "Read-aloud pack {v1}: {v2} h of read-aloud, valid for {v3} days after purchase. You can buy again once {v4}% is used.",
1269
+ "\u65F6\u957F\u5305 {v1} \u8D77\uFF08{v2} \u5C0F\u65F6\u53EF\u9009\uFF09\uFF0C\u8D2D\u4E70\u540E {v3} \u5929\u5185\u6709\u6548\u3002\u7528\u5230 {v4}% \u540E\u53EF\u518D\u4E70\u3002": "Read-aloud pack from {v1} ({v2} h options), valid for {v3} days after purchase. Renew or switch tiers once {v4}% is used.",
1269
1270
  "\u5F53\u524D Key \u4F7F\u7528\u4F1A\u5458\u7684\u6717\u8BFB\u989D\u5EA6\uFF08\u4E0D\u5360 AI \u6574\u7406\u989D\u5EA6\uFF09\u3002": "This key uses your membership\u2019s read-aloud allowance (not its AI processing allowance).",
1270
1271
  "\u5F53\u524D Key \u4F7F\u7528\u6717\u8BFB\u65F6\u957F\u5305\u3002": "This key uses the read-aloud pack.",
1271
1272
  "\u5F53\u524D Key \u4F7F\u7528\u6717\u8BFB\u65F6\u957F\u5305\uFF1A{v1}": "This key uses the read-aloud pack: {v1}",
@@ -2445,7 +2446,7 @@ var zh_hant_default = {
2445
2446
  \u5408\u6210\u97F3\u9891: "\u5408\u6210\u97F3\u8A0A",
2446
2447
  \u8BD5\u7528: "\u8A66\u7528",
2447
2448
  \u57FA\u7840\u7248: "\u57FA\u790E\u7248",
2448
- \u8FDB\u9636\u7248: "\u9032\u968E\u7248",
2449
+ Pro: "Pro",
2449
2450
  \u7BA1\u7406\u5458: "\u7BA1\u7406\u54E1",
2450
2451
  \u672A\u5F00\u901A: "\u672A\u958B\u901A",
2451
2452
  "{v1} \xB7 \u9000\u6B3E\u5BA1\u6838\u4E2D\uFF0C\u4E91\u7AEF\u5DF2\u6682\u505C": "{v1} \xB7 \u9000\u6B3E\u7A3D\u6838\u4E2D\uFF0C\u96F2\u7AEF\u5DF2\u66AB\u505C",
@@ -2830,6 +2831,7 @@ var zh_hant_default = {
2830
2831
  "\u6717\u8BFB\u989D\u5EA6\u6309\u603B\u989D\u8BA1\u7B97\uFF0C\u4E0D\u9700\u8981\u5F00\u542F\u4F7F\u7528\u65E5\u3002": "\u6717\u8B80\u984D\u5EA6\u6309\u7E3D\u984D\u8A08\u7B97\uFF0C\u4E0D\u9700\u8981\u958B\u555F\u4F7F\u7528\u65E5\u3002",
2831
2832
  "\u65F6\u957F\u5305\u4EF7\u683C\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002": "\u6642\u9577\u5305\u50F9\u683C\u66AB\u6642\u7121\u6CD5\u8B80\u53D6\u3002",
2832
2833
  "\u65F6\u957F\u5305 {v1}\uFF0C{v2} \u5C0F\u65F6\u6717\u8BFB\uFF0C\u8D2D\u4E70\u540E {v3} \u5929\u5185\u6709\u6548\u3002\u7528\u5230 {v4}% \u540E\u53EF\u518D\u4E70\u3002": "\u6642\u9577\u5305 {v1}\uFF0C{v2} \u5C0F\u6642\u6717\u8B80\uFF0C\u8CFC\u8CB7\u5F8C {v3} \u5929\u5167\u6709\u6548\u3002\u7528\u5230 {v4}% \u5F8C\u53EF\u518D\u8CB7\u3002",
2834
+ "\u65F6\u957F\u5305 {v1} \u8D77\uFF08{v2} \u5C0F\u65F6\u53EF\u9009\uFF09\uFF0C\u8D2D\u4E70\u540E {v3} \u5929\u5185\u6709\u6548\u3002\u7528\u5230 {v4}% \u540E\u53EF\u518D\u4E70\u3002": "\u6642\u9577\u5305 {v1} \u8D77\uFF08{v2} \u5C0F\u6642\u53EF\u9078\uFF09\uFF0C\u8CFC\u8CB7\u5F8C {v3} \u5929\u5167\u6709\u6548\u3002\u7528\u5230 {v4}% \u5F8C\u53EF\u518D\u8CB7\u3002",
2833
2835
  "\u5F53\u524D Key \u4F7F\u7528\u4F1A\u5458\u7684\u6717\u8BFB\u989D\u5EA6\uFF08\u4E0D\u5360 AI \u6574\u7406\u989D\u5EA6\uFF09\u3002": "\u76EE\u524D Key \u4F7F\u7528\u6703\u54E1\u7684\u6717\u8B80\u984D\u5EA6\uFF08\u4E0D\u5360 AI \u6574\u7406\u984D\u5EA6\uFF09\u3002",
2834
2836
  "\u5F53\u524D Key \u4F7F\u7528\u6717\u8BFB\u65F6\u957F\u5305\u3002": "\u76EE\u524D Key \u4F7F\u7528\u6717\u8B80\u6642\u9577\u5305\u3002",
2835
2837
  "\u5F53\u524D Key \u4F7F\u7528\u6717\u8BFB\u65F6\u957F\u5305\uFF1A{v1}": "\u76EE\u524D Key \u4F7F\u7528\u6717\u8B80\u6642\u9577\u5305\uFF1A{v1}",
@@ -8929,7 +8931,7 @@ function productionView(chapter, options = {}, { keyMissing = false } = {}) {
8929
8931
  }
8930
8932
 
8931
8933
  // src/client/workbench/laivox.mjs
8932
- var PLAN_NAMES = { trial: "\u8BD5\u7528", basic: "\u57FA\u7840\u7248", pro: "\u8FDB\u9636\u7248", admin: "\u7BA1\u7406\u5458", pack: "\u6717\u8BFB\u65F6\u957F\u5305", none: "\u672A\u5F00\u901A" };
8934
+ var PLAN_NAMES = { trial: "\u8BD5\u7528", basic: "\u57FA\u7840\u7248", pro: "Pro", admin: "\u7BA1\u7406\u5458", pack: "\u6717\u8BFB\u65F6\u957F\u5305", none: "\u672A\u5F00\u901A" };
8933
8935
  function shortTime(value) {
8934
8936
  const date = value ? new Date(value) : null;
8935
8937
  if (!date || Number.isNaN(date.getTime())) return "";
@@ -9008,6 +9010,17 @@ function usageBlock(usage) {
9008
9010
  }
9009
9011
  function packPriceLine(catalog) {
9010
9012
  if (!catalog?.available) return translate("\u65F6\u957F\u5305\u4EF7\u683C\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002");
9013
+ const tiers = Array.isArray(catalog.tiers) ? catalog.tiers.filter((tier) => Number.isSafeInteger(tier?.amountCents) && tier.amountCents > 0 && Number(tier?.hours) > 0) : [];
9014
+ if (tiers.length > 1) {
9015
+ const min2 = tiers.reduce((best, tier) => tier.amountCents < best.amountCents ? tier : best, tiers[0]);
9016
+ const hoursList = tiers.map((tier) => String(tier.hours)).join(" / ");
9017
+ return translate("\u65F6\u957F\u5305 {v1} \u8D77\uFF08{v2} \u5C0F\u65F6\u53EF\u9009\uFF09\uFF0C\u8D2D\u4E70\u540E {v3} \u5929\u5185\u6709\u6548\u3002\u7528\u5230 {v4}% \u540E\u53EF\u518D\u4E70\u3002", {
9018
+ v1: "\xA5" + (min2.amountCents / 100).toFixed(2),
9019
+ v2: hoursList,
9020
+ v3: catalog.windowDays,
9021
+ v4: catalog.thresholdPct
9022
+ });
9023
+ }
9011
9024
  return translate("\u65F6\u957F\u5305 {v1}\uFF0C{v2} \u5C0F\u65F6\u6717\u8BFB\uFF0C\u8D2D\u4E70\u540E {v3} \u5929\u5185\u6709\u6548\u3002\u7528\u5230 {v4}% \u540E\u53EF\u518D\u4E70\u3002", {
9012
9025
  v1: "\xA5" + (catalog.amountCents / 100).toFixed(2),
9013
9026
  v2: catalog.hours,
@@ -16513,6 +16526,13 @@ function finalLine(state) {
16513
16526
  if (state.state === "dismissed") return { label: translate("\u5DF2\u5FFD\u7565"), title: state.title };
16514
16527
  return null;
16515
16528
  }
16529
+ function confirmButtonDisabled({ busy, keyMissing, usesAi, hosted, emptyText = false }) {
16530
+ if (busy) return true;
16531
+ if (keyMissing) return false;
16532
+ if (emptyText) return true;
16533
+ if (usesAi && (!hosted?.plan?.confirmation || hosted?.pending)) return true;
16534
+ return false;
16535
+ }
16516
16536
 
16517
16537
  // src/client/chat/ProposalConfirm.jsx
16518
16538
  var import_jsx_runtime43 = require("react/jsx-runtime");
@@ -16632,7 +16652,7 @@ function MakeConfirm({ proposal, session, actions, onSettled }) {
16632
16652
  ] })
16633
16653
  ] }),
16634
16654
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { className: "lv-hactions", children: [
16635
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { className: "lv-hbtn lv-hprimary", disabled: busy || !keyMissing && summary.usesAi && (!hosted.plan?.confirmation || hosted.pending), onClick: () => {
16655
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { className: "lv-hbtn lv-hprimary", disabled: confirmButtonDisabled({ busy, keyMissing, usesAi: summary.usesAi, hosted }), onClick: () => {
16636
16656
  if (keyMissing) {
16637
16657
  requestSettings();
16638
16658
  return;
@@ -16734,6 +16754,7 @@ function TextConfirm({ proposal, session, actions, onSettled }) {
16734
16754
  }
16735
16755
  const confirm = () => settle(async () => {
16736
16756
  if (!summary.usesAi) return actions.confirm(session, proposal.id, previewOptions);
16757
+ if (!hosted.plan?.confirmation) return;
16737
16758
  return actions.confirm(session, proposal.id, { ...previewOptions ?? {}, confirmation: hosted.plan.confirmation });
16738
16759
  });
16739
16760
  const dismiss = () => settle(() => actions.dismiss(session, proposal.id));
@@ -16757,7 +16778,7 @@ function TextConfirm({ proposal, session, actions, onSettled }) {
16757
16778
  ] })
16758
16779
  ] }),
16759
16780
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { className: "lv-hactions", children: [
16760
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { className: "lv-hbtn lv-hprimary", disabled: busy || open && text !== null && !text.trim() || summary.usesAi && (!hosted.plan?.confirmation || hosted.pending), onClick: () => {
16781
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { className: "lv-hbtn lv-hprimary", disabled: confirmButtonDisabled({ busy, keyMissing, usesAi: summary.usesAi, hosted, emptyText: open && text !== null && !text.trim() }), onClick: () => {
16761
16782
  if (keyMissing) {
16762
16783
  requestSettings();
16763
16784
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-laivox-tts",
3
- "version": "0.7.14",
3
+ "version": "0.7.16",
4
4
  "private": false,
5
5
  "description": "把 TXT、EPUB、PDF 小说做成单人朗读或多角色有声书,也能一键朗读对话里的 AI 回答,支持本地书架与 MP3/WAV 导出。",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "assets/samples",
32
32
  "cordis.patch.yml",
33
33
  "README.md",
34
- "README.zh-CN.md",
34
+ "README.en.md",
35
35
  "THIRD_PARTY_NOTICES.md",
36
36
  "LICENSE",
37
37
  "icon.svg",
package/src/host/api.mjs CHANGED
@@ -241,7 +241,7 @@ export function registerAPI(ctx, { library, jobs, imports, chat, gatewayFor, key
241
241
  })
242
242
  }
243
243
  const media = registerMediaRoutes(route, library, mp3?.encodePcm, createMp3Encoder)
244
- if (jobs && 'bindExportGuard' in jobs) jobs.bindExportGuard(book => media.busyBooks().includes(book))
244
+ if (jobs && 'bindExportGuard' in jobs) jobs.bindExportGuard((book, fn) => media.guardBook(book, fn))
245
245
  if (snippets && 'bindExportGuard' in snippets) snippets.bindExportGuard(async (book, fn) => media.guardBook(book, fn))
246
246
  route('models', 'GET', request => modelDirectory(ctx.llm, { signal: request.signal }))
247
247
  route('models/reasoning', 'GET', async (request, params) => {
@@ -147,14 +147,32 @@ export function forgetPackCatalog() { catalogCache = null }
147
147
  export function packCatalogView(data) {
148
148
  const cents = Number(data?.amount_cents)
149
149
  if (data?.available !== true || data?.currency !== 'CNY' || !Number.isSafeInteger(cents) || cents <= 0) return { available: false }
150
- return {
150
+ const windowDays = Number(data.window_days) > 0 ? Number(data.window_days) : 60
151
+ const tiers = Array.isArray(data.tiers)
152
+ ? data.tiers.flatMap(tier => {
153
+ const tCents = Number(tier?.amount_cents)
154
+ const tHours = Number(tier?.tts_hours) > 0 ? Number(tier.tts_hours) : Math.round((Number(tier?.tts_seconds) || 0) / 3600)
155
+ const tID = typeof tier?.id === 'string' ? tier.id.trim() : ''
156
+ if (!tID || !Number.isSafeInteger(tCents) || tCents <= 0 || !Number.isFinite(tHours) || tHours <= 0) return []
157
+ return [{
158
+ id: tID,
159
+ hours: tHours,
160
+ amountCents: tCents,
161
+ windowDays: Number(tier?.window_days) > 0 ? Number(tier.window_days) : windowDays,
162
+ default: tier?.default === true,
163
+ }]
164
+ })
165
+ : []
166
+ const view = {
151
167
  available: true,
152
168
  currency: 'CNY',
153
169
  amountCents: cents,
154
170
  hours: Number(data.tts_hours) > 0 ? Number(data.tts_hours) : Math.round((Number(data.tts_seconds) || 0) / 3600),
155
- windowDays: Number(data.window_days) > 0 ? Number(data.window_days) : 60,
171
+ windowDays,
156
172
  thresholdPct: Number(data.renew_threshold_pct) > 0 ? Number(data.renew_threshold_pct) : 90,
157
173
  }
174
+ if (tiers.length > 0) view.tiers = tiers
175
+ return view
158
176
  }
159
177
 
160
178
  export async function laivoxHandoff(gatewayFor, signal, now = Date.now()) {
@@ -167,11 +167,17 @@ function unpack(bytes, signal) {
167
167
  const spineIds = new Set((spineNode?.children ?? []).filter(item => item.tag === 'itemref').map(item => item.attr.idref))
168
168
  for (const item of items) {
169
169
  if (settled) return
170
- const path = localPath(base, item.attr.href)
171
170
  const type = item.attr['media-type'] ?? ''
172
171
  const nav = (item.attr.properties ?? '').split(/\s+/u).includes('nav')
173
172
  const ncx = type === 'application/x-dtbncx+xml' || item.attr.id === spineNode?.attr.toc
174
173
  const inSpine = spineIds.has(item.attr.id)
174
+ if (!nav && !ncx && !inSpine) continue
175
+ let path
176
+ try { path = localPath(base, item.attr.href) }
177
+ catch (error) {
178
+ if (!inSpine && error?.message === 'EPUB_PATH_INVALID') continue
179
+ throw error
180
+ }
175
181
  if (nav || ncx || (inSpine && isDocument(path, type))) await readEntry(path)
176
182
  else if (inSpine && !files.has(path)) files.set(path, Buffer.alloc(0))
177
183
  }
@@ -28,16 +28,27 @@ function stripInlineLinks(line) {
28
28
  const image = line[i] === '!' && line[i + 1] === '['
29
29
  if (line[i] !== '[' && !image) { out.push(line[i]); continue }
30
30
  const labelAt = image ? i + 2 : i + 1
31
- let close = line.indexOf(']', labelAt)
31
+ const close = line.indexOf(']', labelAt)
32
32
  if (close < 0) {
33
33
  out.push(line.slice(i))
34
34
  break
35
35
  }
36
- if (line[close + 1] !== '(') { out.push(line[i]); continue }
36
+ if (line[close + 1] !== '(') {
37
+ out.push(line.slice(i, close + 1))
38
+ i = close
39
+ continue
40
+ }
37
41
  const end = line.indexOf(')', close + 2)
38
- if (end < 0) { out.push(line[i]); continue }
42
+ if (end < 0) {
43
+ out.push(line.slice(i))
44
+ break
45
+ }
39
46
  const label = line.slice(labelAt, close)
40
- if (!image && !label) { out.push(line[i]); continue }
47
+ if (!image && !label) {
48
+ out.push(line.slice(i, close + 1))
49
+ i = close
50
+ continue
51
+ }
41
52
  out.push(label)
42
53
  i = end
43
54
  }
package/src/host/jobs.mjs CHANGED
@@ -75,7 +75,7 @@ function retakeStored(row, part) {
75
75
  }
76
76
 
77
77
  export function createJobQueue({ library, editorial, llm, gatewayFor, errorCode, logger, synthesize = synthesizePart, edgeConcurrency = EDGE_CONCURRENCY, autoResumeWaits = EDGE_AUTO_RESUME_WAITS, transientWindow = LAIVOX_TRANSIENT_WINDOW }) {
78
- let exportBusy = () => false
78
+ let guardBookExport = async (_book, run) => run()
79
79
  let flight
80
80
  let dispatcher
81
81
  let claiming
@@ -536,10 +536,11 @@ export function createJobQueue({ library, editorial, llm, gatewayFor, errorCode,
536
536
  }
537
537
  timing(part).synthesized = Date.now()
538
538
  try {
539
- if (part.retake && exportBusy(chapter.book)) throw new Error('BOOK_EXPORTING')
540
- await library.putAudio(chapter.id, job.rev, part.key, stored, { replace: part.retake === true, writeId: part.retake ? part.localWriteId : null })
539
+ const saveAudio = () => library.putAudio(chapter.id, job.rev, part.key, stored, { replace: part.retake === true, writeId: part.retake ? part.localWriteId : null })
540
+ if (part.retake) await guardBookExport(chapter.book, saveAudio)
541
+ else await saveAudio()
541
542
  } catch (error) {
542
- if (scoped.aborted || error?.message === 'AUDIO_LIMIT' || error?.message === 'VERSION_CONFLICT') throw error
543
+ if (scoped.aborted || error?.message === 'BOOK_EXPORTING' || error?.message === 'AUDIO_LIMIT' || error?.message === 'VERSION_CONFLICT') throw error
543
544
  const existing = await library.audio(chapter.id, part.key)
544
545
  const kept = existing && (!part.retake || retakeStored(existing, part))
545
546
  if (!kept) throw error
@@ -1140,7 +1141,18 @@ export function createJobQueue({ library, editorial, llm, gatewayFor, errorCode,
1140
1141
  enqueuePrepared,
1141
1142
  bulkTargets,
1142
1143
  cancelForBook,
1143
- bindExportGuard(isBusy) { exportBusy = typeof isBusy === 'function' ? isBusy : () => false },
1144
+ bindExportGuard(fn) {
1145
+ if (typeof fn !== 'function') {
1146
+ guardBookExport = async (_book, run) => run()
1147
+ return
1148
+ }
1149
+ guardBookExport = fn.length >= 2
1150
+ ? fn
1151
+ : async (book, run) => {
1152
+ if (fn(book)) throw new Error('BOOK_EXPORTING')
1153
+ return run()
1154
+ }
1155
+ },
1144
1156
  async enqueue(ids, input, signal) {
1145
1157
  if (input.mode !== undefined || input.operationId !== undefined) return enqueuePrepared(ids, input, signal)
1146
1158
  if (!Array.isArray(ids) || !ids.length || ids.length > 500) throw new Error('INVALID_INPUT')
@@ -784,7 +784,7 @@ function searchBookContent({ book, query = '', roleName = '', limit = 40, allowS
784
784
  for (const line of lines) {
785
785
  if (!matchedRoles.has(line.roleId)) continue
786
786
  if (cleanQuery && !line.text.toLowerCase().includes(needleLower)) continue
787
- const safeText = line.text.slice(0, Math.max(0, heardEnd - line.start))
787
+ const safeText = row.text.slice(line.start, Math.min(line.end, heardEnd)).trim()
788
788
  const queryInSafe = !cleanQuery || safeText.toLowerCase().includes(needleLower)
789
789
  const ahead = isAhead(line.start) || !queryInSafe
790
790
  const excerpt = !allowSpoilers && ahead ? '' : (allowSpoilers ? line.text : safeText).slice(0, 200)
@@ -808,7 +808,7 @@ function searchBookContent({ book, query = '', roleName = '', limit = 40, allowS
808
808
  let speaker = null
809
809
  if (row.editorial) {
810
810
  const editorial = parse(row.editorial)
811
- const lines = extractSpeakerLines(visible, editorial, roleMap, visible.length, 500)
811
+ const lines = extractSpeakerLines(row.text, editorial, roleMap, visible.length, 500)
812
812
  const hitLine = lines.find(line => idx >= line.start && idx < line.end)
813
813
  if (hitLine) speaker = hitLine.speaker
814
814
  }
@@ -396,7 +396,7 @@ export function registerMediaRoutes(route, library, encodePcm = sharedEncodePcm,
396
396
  if (job.spec?.purpose !== 'generate' || !planComplete(job.progress)) throw new Error('AUDIO_INCOMPLETE')
397
397
  const { book } = await library.chapterHeader(job.chapter)
398
398
  const id = params.has('export') ? exportIdOf(params.get('export')) : null
399
- if (id && exportCancels.has(id)) throw new Error('INVALID_INPUT')
399
+ if (id && (exportCancels.has(id) || exports.get(id)?.state === 'running')) throw new Error('INVALID_INPUT')
400
400
  const release = occupy({ book, chapter: job.chapter })
401
401
  // With an export id the page can follow the preparation (parts read so far)
402
402
  // through media/book/progress, as for a whole book. The response may only
@@ -519,7 +519,7 @@ export function registerMediaRoutes(route, library, encodePcm = sharedEncodePcm,
519
519
  const includeSpeaker = params.get('speakers') !== '0'
520
520
  const filter = parseSelectionFilter(params)
521
521
  const id = exportIdOf(params.get('export'))
522
- if (exportCancels.has(id)) throw new Error('INVALID_INPUT')
522
+ if (exportCancels.has(id) || exports.get(id)?.state === 'running') throw new Error('INVALID_INPUT')
523
523
  const state = { state: 'running', done: 0, total: 0, bytes: 0, error: null }
524
524
  // Occupy first: a refused export must not leave a progress entry that stays
525
525
  // `running` forever.
@@ -149,6 +149,7 @@ function stripHtmlComments(text) {
149
149
 
150
150
  function stripSpokenLinks(text) {
151
151
  const out = []
152
+ let noParen = false
152
153
  for (let i = 0; i < text.length; i++) {
153
154
  const image = text[i] === '!' && text[i + 1] === '['
154
155
  if (text[i] !== '[' && !image) { out.push(text[i]); continue }
@@ -161,58 +162,96 @@ function stripSpokenLinks(text) {
161
162
  const label = text.slice(labelAt, close)
162
163
  const next = text[close + 1]
163
164
  if (next === '(') {
165
+ if (noParen) {
166
+ out.push(text.slice(i, close + 1))
167
+ i = close
168
+ continue
169
+ }
164
170
  const end = text.indexOf(')', close + 2)
165
- if (end < 0) { out.push(text[i]); continue }
171
+ if (end < 0) {
172
+ noParen = true
173
+ out.push(text.slice(i, close + 1))
174
+ i = close
175
+ continue
176
+ }
166
177
  out.push(label)
167
178
  i = end
168
179
  continue
169
180
  }
170
181
  if (next === '[') {
171
182
  const end = text.indexOf(']', close + 2)
172
- if (end < 0 || (!image && !label)) { out.push(text[i]); continue }
183
+ if (end < 0) {
184
+ out.push(text.slice(i))
185
+ break
186
+ }
187
+ if (!image && !label) {
188
+ out.push(text.slice(i, close + 1))
189
+ i = close
190
+ continue
191
+ }
173
192
  out.push(label)
174
193
  i = end
175
194
  continue
176
195
  }
177
- out.push(text[i])
196
+ out.push(text.slice(i, close + 1))
197
+ i = close
178
198
  }
179
199
  return out.join('')
180
200
  }
181
201
 
182
202
  function stripWrappedMarks(text) {
183
203
  const tokens = ['**', '__', '~~']
184
- let out = ''
204
+ const missed = { '**': -1, '__': -1, '~~': -1 }
205
+ const out = []
206
+ let lineEnd = -1
185
207
  for (let i = 0; i < text.length; i++) {
208
+ if (i >= lineEnd) {
209
+ const nl = text.indexOf('\n', i)
210
+ lineEnd = nl < 0 ? text.length : nl
211
+ }
186
212
  const token = tokens.find(item => text.startsWith(item, i))
187
- if (!token) { out += text[i]; continue }
213
+ if (!token) { out.push(text[i]); continue }
214
+ if (missed[token] === lineEnd) { out.push(text[i]); continue }
188
215
  const from = i + token.length
189
- const lineEnd = text.indexOf('\n', from)
190
- const window = text.slice(from, lineEnd < 0 ? text.length : lineEnd)
191
- const rel = window.indexOf(token)
192
- if (rel <= 0) { out += text[i]; continue }
193
- out += window.slice(0, rel)
194
- i = from + rel + token.length - 1
216
+ const close = text.indexOf(token, from)
217
+ if (close < 0 || close >= lineEnd) {
218
+ missed[token] = lineEnd
219
+ out.push(text[i])
220
+ continue
221
+ }
222
+ if (close === from) { out.push(text[i]); continue }
223
+ out.push(text.slice(from, close))
224
+ i = close + token.length - 1
195
225
  }
196
- return out
226
+ return out.join('')
197
227
  }
198
228
 
199
229
  function stripSingleMarks(text, mark) {
200
230
  const blocked = mark === '*' ? /[\w*]/u : /[\w_]/u
201
- let out = ''
231
+ const out = []
232
+ let lineEnd = -1
233
+ let missedLineEnd = -1
202
234
  for (let i = 0; i < text.length; i++) {
235
+ if (i >= lineEnd) {
236
+ const nl = text.indexOf('\n', i)
237
+ lineEnd = nl < 0 ? text.length : nl
238
+ }
203
239
  const prev = i === 0 ? '' : text[i - 1]
204
240
  const next = text[i + 1]
205
- if (text[i] !== mark || (i > 0 && blocked.test(prev)) || next == null || /\s/u.test(next)) { out += text[i]; continue }
206
- const lineEnd = text.indexOf('\n', i + 1)
207
- const window = text.slice(i + 1, lineEnd < 0 ? text.length : lineEnd)
208
- const rel = window.indexOf(mark)
209
- const afterIndex = i + 1 + rel + 1
210
- const after = rel < 0 ? '' : text[afterIndex] ?? ''
211
- if (rel <= 0 || /\w/u.test(after)) { out += text[i]; continue }
212
- out += window.slice(0, rel)
213
- i += rel + 1
241
+ if (text[i] !== mark || (i > 0 && blocked.test(prev)) || next == null || /\s/u.test(next)) { out.push(text[i]); continue }
242
+ if (missedLineEnd === lineEnd) { out.push(text[i]); continue }
243
+ const close = text.indexOf(mark, i + 1)
244
+ if (close < 0 || close >= lineEnd) {
245
+ missedLineEnd = lineEnd
246
+ out.push(text[i])
247
+ continue
248
+ }
249
+ const after = text[close + 1] ?? ''
250
+ if (close === i + 1 || /\w/u.test(after)) { out.push(text[i]); continue }
251
+ out.push(text.slice(i + 1, close))
252
+ i = close
214
253
  }
215
- return out
254
+ return out.join('')
216
255
  }
217
256
 
218
257
  export function speakableText(markdown) {
package/README.zh-CN.md DELETED
@@ -1,122 +0,0 @@
1
- # 小说配音(LaiVox)
2
-
3
- [English](README.md) · **简体中文**
4
-
5
- [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(DSH)的有声书插件:把 TXT、EPUB、PDF 小说做成单人朗读或多角色有声书,也能一键把 AI 的回答读给你听。默认内置微软 Edge 在线语音,无需注册账号,支持简体中文、繁体中文与英文。
6
-
7
- ![LaiVox 工作台:书架、正文与播放器](assets/screenshots/listen.png)
8
-
9
- ## 你能用它做什么
10
-
11
- - **听手里的小说**:导入 TXT、EPUB 或 PDF,自动分章并预览目录;也可以直接新建书籍粘贴正文。选好章节点击「开始制作」,第一段完成即可开听,不用等整章做完。
12
- - **单人朗读,或多角色配音**:单人朗读开箱即用;选择「多角色演绎」后,由你在 DSH 中配置的模型分辨说话人和语气,为每个角色分配独立音色。开始前会列出预计请求数,由你确认后才调用模型。Edge 引擎会按角色切换不同音色,逐句情绪演绎需使用 LaiVox 引擎。
13
- - **使用 LaiVox 拟人音色(可选)**:在设置的「制作与发声」中切换为 LaiVox。支持按每句语气做拟人化情感演绎,账号开通自有音色后,也可直接选用在 LaiVox 浏览器扩展里上传的「我的音色」。使用会员朗读额度或单独购买的朗读时长包,填入 API Key 即可启用。
14
- - **让 AI 当你的有声书助手**:在对话里直接说“把工作目录里的 book.txt 做成有声书”,AI 会在回答下方准备好导入预览和制作计划。点击确认后才会导入与制作,且任务自动排在已有队列之后,不会打断你正在听或正在做的书。
15
- - **一键听 AI 回答,随手朗读片段**:点击回答下方的「用 Edge 朗读」,或直接说“读给我听”,系统会自动跳过代码块与链接地址,并读出表格文字;在输入框发送 `/laivox 一段文字` 也能快速生成音频,结果收纳在「书架 → 对话音频」。
16
- - **导出带走**:支持单章导出 MP3 / WAV,或将整本书打包导出为按章命名的 ZIP。
17
-
18
- 更完整的场景操作说明见 [使用指南](docs/GUIDE.md)。
19
-
20
- | 角色与音色 | 导入预览 | 对话音频 | 深色主题 |
21
- |---|---|---|---|
22
- | ![角色](assets/screenshots/roles.png) | ![导入](assets/screenshots/import.png) | ![对话音频](assets/screenshots/snippets.png) | ![深色主题](assets/screenshots/listen-dark.png) |
23
-
24
- ## 安装
25
-
26
- 安装前先准备好 `dsh` 命令:
27
-
28
- - **DSH 桌面版**:在「应用程序」菜单中选「管理 dsh 命令…」→「安装」(位于「检查更新」下方),打开新终端执行 `dsh --version` 确认可用。桌面版的默认 Profile 名为 `desktop`。安装插件前请先启动一次桌面版,再**完全退出**(包括系统托盘),然后执行下方命令。详见 [官方桌面版文档](https://github.com/deepseek-ai/deepseek-harness/blob/38a6a5c/apps/desktop/README.zh.md#终端命令)。
29
- - **DSH Web / 命令行版**:需要 Node.js 24.9 或更高版本,示例中使用 Profile 名 `web`。
30
-
31
- 如使用其他 Profile,将命令中的 `desktop` 替换为你的 Profile 名称即可。
32
-
33
- ### 在线安装(推荐)
34
-
35
- ```sh
36
- dsh plugin --profile desktop add dsh-laivox-tts
37
- ```
38
-
39
- 直接安装 npm 上的预构建插件包,无需在本地编译或授权构建脚本(国内网络可自动受益于镜像加速)。
40
-
41
- ### GitHub Release 链接或离线安装包安装
42
-
43
- 如需锁定版本或无法直连 npm,可使用 Release 下载链接(将 `latest/download` 替换为 `download/v0.7.14` 可锁定版本),或从 [Releases](https://github.com/xiaolai181/dsh_laivox_tts/releases) 下载 `dsh-laivox-tts.tgz` 到本地后安装:
44
-
45
- ```sh
46
- dsh plugin --profile desktop add "https://github.com/xiaolai181/dsh_laivox_tts/releases/latest/download/dsh-laivox-tts.tgz"
47
- # 或使用本地文件:
48
- dsh plugin --profile desktop add ./dsh-laivox-tts.tgz
49
- ```
50
-
51
- <details>
52
- <summary>从源码目录安装(开发者)</summary>
53
-
54
- ```sh
55
- git clone https://github.com/xiaolai181/dsh_laivox_tts.git laivox-tts
56
- cd laivox-tts
57
- npx pnpm install # 必须使用 pnpm,安装时会自动构建 lib/
58
- dsh plugin --profile desktop add .
59
- ```
60
-
61
- Profile 会直接链接到该源码目录,安装后请勿移动或删除。执行 `git pull` 更新源码后,需再次运行 `npx pnpm install` 重新构建。
62
-
63
- > **从源码安装改回插件包安装时**:执行 `dsh plugin remove` 后,Profile 的 `node_modules` 下仍会保留 `dsh-laivox-tts` 目录链接。请先只删除该链接本身(Windows 上使用不带 `/s` 的 `rmdir`),再安装插件包,避免误删源码目录内的文件。
64
-
65
- </details>
66
-
67
- ### 安装完成后
68
-
69
- - **桌面版**:重新打开 DeepSeek Harness。**Web 版**:重启 `dsh web`。
70
- - 左侧栏会出现「小说配音(LaiVox)」。
71
- - 可通过 `dsh plugin --profile desktop list` 查看安装状态。
72
-
73
- ### 更新与卸载
74
-
75
- - **更新**:重新运行一次安装命令即可(使用 `latest/download` 会自动获取最新版)。
76
- - **卸载**:运行 `dsh plugin --profile desktop remove dsh-laivox-tts`。已导入的书籍与生成的音频会保留在本机。
77
-
78
- ## 五分钟上手
79
-
80
- 可在 **DSH 设置 → 通用设置 → 语言** 中切换简体中文、繁体中文或英文,工作台会同步跟随。
81
-
82
- 1. 从侧栏打开「小说配音(LaiVox)」。工作台顶部有三个页签:**收听**、**制作**、**书架**,右上角为任务列表与设置。
83
- 2. 首次打开若书架为空,会自动放好两本免 Key 试听示例:《社戏 · 月夜行船 · Edge》(Edge 单人朗读)与《绿野仙踪 · 营救铁皮人 · LaiVox》(LaiVox 多角色配音),点开即可直接试听,不需要时可随时删除。
84
- 3. 在 **书架 →「导入 TXT / EPUB / PDF」** 选择小说文件(或点击「新建书籍」粘贴正文)。分章有误时可点击标题调整,确认后导入。
85
- 4. 打开章节,选择「单人朗读」并点击「开始制作」(无需调用 AI);第一段生成完毕即可播放,支持倍速、定时关闭、书签、随读高亮与自动续播下一章(可在设置中关闭)。
86
-
87
- ## 隐私与费用
88
-
89
- - **微软 Edge 在线语音**:默认内置,无需注册账号。待朗读或合成的文字会发送至微软 Edge 在线语音服务,服务可用性与条款受微软方约束。
90
- - **AI 辅助功能**:正文清洗、多角色演绎编剧与 AI 辅助分章会使用你在 DSH 中配置的模型,并计入对应模型额度;每一步都会先展示预计请求数,经你确认后才会调用。单人朗读从不调用模型。
91
- - **LaiVox 引擎(可选增值)**:在设置的「制作与发声」中开启并保存 API Key。支持使用会员朗读额度或单独购买的朗读时长包,合成文字会发送至 LaiVox 服务并按其隐私与保留策略处理;API Key 保存在 DSH 凭据服务中,仅在使用 LaiVox 时连接服务。自有音色的上传与管理仍在 LaiVox 浏览器扩展中进行。
92
- - **版权与权限边界**:请仅导入并制作你拥有合法使用权的文本,生成的音频仅供个人合规使用。AI 助手仅能读取当前对话的工作目录,无法删除书架中的任何书籍。
93
-
94
- ## 数据与本地存储
95
-
96
- 你的书架、正文、台词与已生成的音频全部保存在本机:
97
-
98
- - **存储上限**:音频缓存默认上限为 2 GiB,可在「设置 → 存储」中调整为 0.5~20 GiB(修改后重新打开 DSH 生效)。空间达到上限时会暂停新制作,你可以随时按书或按章清理音频,正文和台词会保留。
99
- - **对话音频清理**:通过对话生成的朗读音频若超过 7 天未收听会自动清理,可在设置中改为 1 天、30 天或永不清理;转存到书架后将永久保留。
100
- - **彻底清除**:卸载插件后删除对应的插件数据目录即可完全清除本地数据。
101
-
102
- <details>
103
- <summary>数据目录与升级前备份说明</summary>
104
-
105
- - 所有数据位于当前 Profile 目录下的 `<DSH 主目录>/profiles/<Profile 名>/dsh-laivox-tts/`(DSH 主目录默认为 `~/.dsh`),其中 `library.sqlite` 保存书架、台词、任务、音频与播放进度。
106
- - **升级前建议备份**:完全退出 DSH 后复制整个 `dsh-laivox-tts` 目录。跨版本更新可能升级本地数据库结构(当前为 v13),升级后的数据库无法再被旧版本插件打开。
107
- - 内置试听示例仅在全新空白 Profile 首次启动时写入一次(已有书籍的老 Profile 升级不会写入),删除后重启或升级不会重新出现。
108
-
109
- </details>
110
-
111
- <details>
112
- <summary>文件规格与使用须知</summary>
113
-
114
- - **PDF 支持**:支持包含可选中文字的 PDF,暂不支持纯图片扫描版。
115
- - **导入限制**:单个文件最大 50 MiB;EPUB 解压后不超过 150 MiB(其中单个内部文件不超过 32 MiB);PDF 不超过 5,000 页或 3,000 万字;单本书籍最多 5,000 章。
116
- - **对话交互说明**:确认操作按钮、导入预览与生成结果仅挂在最新一轮回答下方;朗读首句通常约需 1~2 秒准备,后续段落约 0.5~1 秒;同一对话在多个窗口同时打开时,由 AI 发起的朗读会在这些窗口同步播放。
117
-
118
- </details>
119
-
120
- ## 许可
121
-
122
- LaiVox 自有的插件代码采用 [MIT 许可证](LICENSE),LaiVox TTS 服务端和服务访问权限不在此范围内。LaiVox 品牌、图标和预置试听音频按各自的授权使用,详见 [许可与第三方声明](THIRD_PARTY_NOTICES.md)。