dsh-laivox-tts 0.7.19 → 0.7.20
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 +1 -1
- package/README.md +1 -1
- package/lib/client.js +9 -3
- package/package.json +1 -1
- package/src/domain/ai-batch.mjs +32 -9
- package/src/domain/ai.mjs +12 -2
- package/src/host/editorial.mjs +14 -9
package/README.en.md
CHANGED
|
@@ -38,7 +38,7 @@ This installs the prebuilt package from npm—nothing is compiled locally and no
|
|
|
38
38
|
|
|
39
39
|
### Install from GitHub Release or offline package
|
|
40
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.
|
|
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.20` to pin a version):
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
44
|
dsh plugin --profile desktop add "https://github.com/xiaolai181/dsh_laivox_tts/releases/latest/download/dsh-laivox-tts.tgz"
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ dsh plugin --profile desktop add dsh-laivox-tts
|
|
|
40
40
|
|
|
41
41
|
### GitHub Release 链接或离线安装包安装
|
|
42
42
|
|
|
43
|
-
如需锁定版本或无法直连 npm,可使用 Release 下载链接(将 `latest/download` 替换为 `download/v0.7.
|
|
43
|
+
如需锁定版本或无法直连 npm,可使用 Release 下载链接(将 `latest/download` 替换为 `download/v0.7.20` 可锁定版本),或从 [Releases](https://github.com/xiaolai181/dsh_laivox_tts/releases) 下载 `dsh-laivox-tts.tgz` 到本地后安装:
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
46
|
dsh plugin --profile desktop add "https://github.com/xiaolai181/dsh_laivox_tts/releases/latest/download/dsh-laivox-tts.tgz"
|
package/lib/client.js
CHANGED
|
@@ -1320,6 +1320,7 @@ var en_default = {
|
|
|
1320
1320
|
"\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42": "About {requests} regular requests",
|
|
1321
1321
|
"\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u989D\u5EA6\u3002": "About {requests} regular requests, using DSH model quota.",
|
|
1322
1322
|
"\u6A21\u578B\u8F93\u51FA\u9700\u8981\u4FEE\u590D\u65F6\uFF0C\u8BF7\u6C42\u6570\u53EF\u80FD\u589E\u52A0\u3002": "Repairing model output can take more requests.",
|
|
1323
|
+
"\u7F16\u5267\u6BCF\u6BB5\u53EF\u80FD\u518D\u8865\u5199\u4E00\u6B21\uFF0C\u901A\u5E38\u4E0D\u8D85\u8FC7 {max} \u6B21\u3002": "Each script window may need one repair request, usually no more than {max} in total.",
|
|
1323
1324
|
"\u6E05\u6D17\u5B8C\u6210\u540E\uFF0C\u7F16\u5267\u6B21\u6570\u53EF\u80FD\u8C03\u6574\u3002": "The scripting count may change after cleaning finishes.",
|
|
1324
1325
|
"\u4F1A\u628A\u6B63\u6587\u53D1\u7ED9 {model}\uFF0C\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u989D\u5EA6\u3002": "The text goes to {model}, about {requests} regular requests, using DSH model quota.",
|
|
1325
1326
|
"\u5F00\u542F AI \u65F6\u4F1A\u628A\u6B63\u6587\u53D1\u7ED9 {model}\uFF0C\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u989D\u5EA6\u3002": "With AI on, the text goes to {model}, about {requests} regular requests, using DSH model quota.",
|
|
@@ -2903,6 +2904,7 @@ var zh_hant_default = {
|
|
|
2903
2904
|
"\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42": "\u9810\u8A08 {requests} \u6B21\u5E38\u898F\u8ACB\u6C42",
|
|
2904
2905
|
"\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u989D\u5EA6\u3002": "\u9810\u8A08 {requests} \u6B21\u5E38\u898F\u8ACB\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u984D\u5EA6\u3002",
|
|
2905
2906
|
"\u6A21\u578B\u8F93\u51FA\u9700\u8981\u4FEE\u590D\u65F6\uFF0C\u8BF7\u6C42\u6570\u53EF\u80FD\u589E\u52A0\u3002": "\u6A21\u578B\u8F38\u51FA\u9700\u8981\u4FEE\u5FA9\u6642\uFF0C\u8ACB\u6C42\u6578\u53EF\u80FD\u589E\u52A0\u3002",
|
|
2907
|
+
"\u7F16\u5267\u6BCF\u6BB5\u53EF\u80FD\u518D\u8865\u5199\u4E00\u6B21\uFF0C\u901A\u5E38\u4E0D\u8D85\u8FC7 {max} \u6B21\u3002": "\u7DE8\u5287\u6BCF\u6BB5\u53EF\u80FD\u518D\u88DC\u5BEB\u4E00\u6B21\uFF0C\u901A\u5E38\u4E0D\u8D85\u904E {max} \u6B21\u3002",
|
|
2906
2908
|
"\u6E05\u6D17\u5B8C\u6210\u540E\uFF0C\u7F16\u5267\u6B21\u6570\u53EF\u80FD\u8C03\u6574\u3002": "\u6E05\u6D17\u5B8C\u6210\u5F8C\uFF0C\u7DE8\u5287\u6B21\u6578\u53EF\u80FD\u8ABF\u6574\u3002",
|
|
2907
2909
|
"\u4F1A\u628A\u6B63\u6587\u53D1\u7ED9 {model}\uFF0C\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u989D\u5EA6\u3002": "\u6703\u628A\u6B63\u6587\u767C\u7D66 {model}\uFF0C\u9810\u8A08 {requests} \u6B21\u5E38\u898F\u8ACB\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u984D\u5EA6\u3002",
|
|
2908
2910
|
"\u5F00\u542F AI \u65F6\u4F1A\u628A\u6B63\u6587\u53D1\u7ED9 {model}\uFF0C\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u989D\u5EA6\u3002": "\u958B\u555F AI \u6642\u6703\u628A\u6B63\u6587\u767C\u7D66 {model}\uFF0C\u9810\u8A08 {requests} \u6B21\u5E38\u898F\u8ACB\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u984D\u5EA6\u3002",
|
|
@@ -5493,7 +5495,7 @@ function PlanSheet({ dialog, answer, narratorSetting, account }) {
|
|
|
5493
5495
|
plan.aiPlan?.selection && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: modelIdentity(plan.aiPlan.selection) }),
|
|
5494
5496
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { children: [
|
|
5495
5497
|
translate("\u9884\u8BA1 {requests} \u6B21\u5E38\u89C4\u8BF7\u6C42\uFF0C\u4F7F\u7528 DSH \u6A21\u578B\u989D\u5EA6\u3002", { requests: plan.estimate.requests }),
|
|
5496
|
-
plan.estimate.cast > 0 ? translate("\
|
|
5498
|
+
plan.estimate.cast > 0 ? translate("\u7F16\u5267\u6BCF\u6BB5\u53EF\u80FD\u518D\u8865\u5199\u4E00\u6B21\uFF0C\u901A\u5E38\u4E0D\u8D85\u8FC7 {max} \u6B21\u3002", { max: plan.estimate.requests + plan.estimate.cast }) : "",
|
|
5497
5499
|
plan.estimate.provisional ? translate("\u6E05\u6D17\u5B8C\u6210\u540E\uFF0C\u7F16\u5267\u6B21\u6570\u53EF\u80FD\u8C03\u6574\u3002") : ""
|
|
5498
5500
|
] })
|
|
5499
5501
|
] }),
|
|
@@ -11144,9 +11146,13 @@ var CAST_REPAIRS = 7;
|
|
|
11144
11146
|
var CHARS_PER_SEGMENT = 35;
|
|
11145
11147
|
var positive = (value) => Number.isFinite(value) && value > 0 ? Math.ceil(value) : 0;
|
|
11146
11148
|
var batches = (characters, window2) => characters > 0 ? Math.ceil(characters / window2) : 0;
|
|
11149
|
+
var EXTRACT_OUTPUT_CEILING = 32768;
|
|
11150
|
+
var EXTRACT_WINDOW_MAX = 12e3;
|
|
11151
|
+
function extractOutputLimit(selection) {
|
|
11152
|
+
return Math.min(EXTRACT_OUTPUT_CEILING, selection?.maxTokens || 8192);
|
|
11153
|
+
}
|
|
11147
11154
|
function extractWindowChars(selection) {
|
|
11148
|
-
|
|
11149
|
-
return Math.min(6e3, Math.max(1500, Math.floor(limit * 0.45)));
|
|
11155
|
+
return Math.min(EXTRACT_WINDOW_MAX, Math.max(1500, Math.floor(extractOutputLimit(selection) * 0.45)));
|
|
11150
11156
|
}
|
|
11151
11157
|
function estimateAiCalls({ cleanCharacters = 0, castCharacters = 0, extract = false, windowChars } = {}) {
|
|
11152
11158
|
const clean = batches(positive(cleanCharacters), CLEAN_WINDOW);
|
package/package.json
CHANGED
package/src/domain/ai-batch.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isSeparator, iterateChapterSegments, iterateSourceLines, sourceLines, SEGMENT_VERSION } from './segment.mjs'
|
|
2
|
-
import { CAST_SEGMENTS, CAST_WINDOW, CLEAN_WINDOW, extractWindowChars } from './ai.mjs'
|
|
2
|
+
import { CAST_SEGMENTS, CAST_WINDOW, CLEAN_WINDOW, extractOutputLimit, extractWindowChars } from './ai.mjs'
|
|
3
3
|
import { splitOversized } from './script-lines.mjs'
|
|
4
4
|
|
|
5
5
|
const CAST_OUTPUT_CEILING = 16384
|
|
@@ -10,27 +10,50 @@ export function castOutputLimit(selection) {
|
|
|
10
10
|
return Math.min(CAST_OUTPUT_CEILING, selection?.maxTokens || 8192)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export { extractWindowChars }
|
|
13
|
+
export { extractOutputLimit, extractWindowChars }
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const blank = text => text.replace(/[^\r\n]/g, ' ')
|
|
16
|
+
|
|
17
|
+
// Contiguous original slices. A deleted line stays inside the window as spaces
|
|
18
|
+
// of the same UTF-16 length: offsets still map onto the chapter, the model sees
|
|
19
|
+
// nothing there, and spaces are never a coverage hole. Blank lines and
|
|
20
|
+
// separators stay as they are. Only kept text counts toward the limit, so a
|
|
21
|
+
// deleted ad does not cost a request of its own.
|
|
16
22
|
export function extractSourceWindows(text, removed = [], limit = extractWindowChars({})) {
|
|
23
|
+
const body = String(text ?? '')
|
|
17
24
|
const hidden = new Set(removed)
|
|
18
25
|
const windows = []
|
|
19
26
|
let current = null
|
|
20
|
-
const flush = () => {
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
const flush = () => {
|
|
28
|
+
if (!current) return
|
|
29
|
+
let slice = body.slice(current.start, current.end)
|
|
30
|
+
for (const range of current.masks) {
|
|
31
|
+
if (range.start >= current.end) continue
|
|
32
|
+
const from = range.start - current.start
|
|
33
|
+
const to = Math.min(range.end, current.end) - current.start
|
|
34
|
+
slice = slice.slice(0, from) + blank(slice.slice(from, to)) + slice.slice(to)
|
|
35
|
+
}
|
|
36
|
+
windows.push({ start: current.start, end: current.end, text: slice })
|
|
37
|
+
current = null
|
|
38
|
+
}
|
|
39
|
+
for (const line of sourceLines(body)) {
|
|
40
|
+
if (hidden.has(line.id)) {
|
|
41
|
+
if (current && line.text.length) current.masks.push({ start: line.start, end: line.start + line.text.length })
|
|
42
|
+
continue
|
|
43
|
+
}
|
|
44
|
+
if (isSeparator(line.text) || !line.text.trim()) continue
|
|
23
45
|
let offset = 0
|
|
24
46
|
for (const piece of splitOversized(line.text, limit)) {
|
|
25
47
|
const start = line.start + offset
|
|
26
48
|
const end = start + piece.length
|
|
49
|
+
const size = [...piece].length
|
|
27
50
|
offset += piece.length
|
|
28
|
-
if (current &&
|
|
51
|
+
if (current && current.size + size <= limit) {
|
|
29
52
|
current.end = end
|
|
30
|
-
current.
|
|
53
|
+
current.size += size
|
|
31
54
|
} else {
|
|
32
55
|
flush()
|
|
33
|
-
current = { start, end,
|
|
56
|
+
current = { start, end, size, masks: [] }
|
|
34
57
|
}
|
|
35
58
|
}
|
|
36
59
|
}
|
package/src/domain/ai.mjs
CHANGED
|
@@ -16,9 +16,19 @@ const CHARS_PER_SEGMENT = 35
|
|
|
16
16
|
const positive = value => (Number.isFinite(value) && value > 0 ? Math.ceil(value) : 0)
|
|
17
17
|
const batches = (characters, window) => (characters > 0 ? Math.ceil(characters / window) : 0)
|
|
18
18
|
|
|
19
|
+
// Extract casting writes every line back, so its window follows the output
|
|
20
|
+
// budget. maxTokens is the DSH adapter's per-request cap (resolveModelInfo
|
|
21
|
+
// defaultMaxTokens); 8192 is the fallback when the host does not disclose it.
|
|
22
|
+
// 0.45 characters per output token leaves room for the per-line JSON fields.
|
|
23
|
+
export const EXTRACT_OUTPUT_CEILING = 32768
|
|
24
|
+
export const EXTRACT_WINDOW_MAX = 12000
|
|
25
|
+
|
|
26
|
+
export function extractOutputLimit(selection) {
|
|
27
|
+
return Math.min(EXTRACT_OUTPUT_CEILING, selection?.maxTokens || 8192)
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
export function extractWindowChars(selection) {
|
|
20
|
-
|
|
21
|
-
return Math.min(6000, Math.max(1500, Math.floor(limit * 0.45)))
|
|
31
|
+
return Math.min(EXTRACT_WINDOW_MAX, Math.max(1500, Math.floor(extractOutputLimit(selection) * 0.45)))
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
export function estimateAiCalls({ cleanCharacters = 0, castCharacters = 0, extract = false, windowChars } = {}) {
|
package/src/host/editorial.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
2
|
import { isSeparator, sourceLines, segmentChapter, segmentVersion, SEGMENT_VERSION } from '../domain/segment.mjs'
|
|
3
3
|
import { normalizeInstruct } from '../domain/voice-direction.mjs'
|
|
4
|
-
import { CAST_SEGMENTS, CAST_WINDOW, CLEAN_WINDOW, extractWindowChars } from '../domain/ai.mjs'
|
|
4
|
+
import { CAST_SEGMENTS, CAST_WINDOW, CLEAN_WINDOW, extractOutputLimit, extractWindowChars } from '../domain/ai.mjs'
|
|
5
5
|
import { batchWindows as windows, castOutputLimit, castSegmentsFor, extractSourceWindows } from '../domain/ai-batch.mjs'
|
|
6
6
|
import { voiceAssignments } from '../domain/voice-assignment.mjs'
|
|
7
7
|
import { messageFor } from '../domain/messages.mjs'
|
|
@@ -71,12 +71,15 @@ export async function modelDirectory(llm, { provider, timeoutMs = 8000, signal }
|
|
|
71
71
|
return groups.flat().sort((a, b) => modelPriority(b) - modelPriority(a))
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// The catalog (listModels) carries no output limit. The exact-route lookup
|
|
75
|
+
// does: defaultMaxTokens is the adapter's per-request output cap.
|
|
74
76
|
export async function modelReasoning(llm, provider, model, signal) {
|
|
75
77
|
const info = await llm.resolveModelInfo?.(provider, model, signal)
|
|
76
78
|
const reasoning = info?.reasoning
|
|
77
79
|
return {
|
|
78
80
|
efforts: reasoning?.efforts.map(({ id, name }) => ({ id, name })) ?? [],
|
|
79
81
|
defaultEffort: reasoning?.defaultEffort,
|
|
82
|
+
...(Number.isSafeInteger(info?.defaultMaxTokens) && info.defaultMaxTokens > 0 ? { maxTokens: info.defaultMaxTokens } : {}),
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -86,13 +89,15 @@ export async function resolvePluginModel(llm, selection, signal) {
|
|
|
86
89
|
const selected = selection == null ? models[0] : models.find(model => model.provider === selection.provider && model.model === selection.model)
|
|
87
90
|
if (!selected) throw new Error('MODEL_NOT_CONFIGURED')
|
|
88
91
|
const requested = selection?.reasoningEffort
|
|
89
|
-
|
|
90
|
-
if (requested === null) return selected
|
|
91
|
-
const { efforts } = await modelReasoning(llm, selected.provider, selected.model, signal).catch(() => ({ efforts: [] }))
|
|
92
|
+
const info = await modelReasoning(llm, selected.provider, selected.model, signal).catch(() => ({ efforts: [] }))
|
|
92
93
|
signal?.throwIfAborted()
|
|
93
|
-
const
|
|
94
|
+
const maxTokens = info.maxTokens ?? selected.maxTokens
|
|
95
|
+
const model = maxTokens ? { ...selected, maxTokens } : selected
|
|
96
|
+
// Null explicitly follows the model default. An omitted effort uses the plugin default.
|
|
97
|
+
if (requested === null) return model
|
|
98
|
+
const available = id => info.efforts.some(effort => effort.id === id)
|
|
94
99
|
if (requested !== undefined && !available(requested)) throw new Error('MODEL_REASONING_UNSUPPORTED')
|
|
95
|
-
return { ...
|
|
100
|
+
return { ...model, reasoningEffort: requested ?? (available('off') ? 'off' : undefined) }
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
function decodeReply(text) {
|
|
@@ -370,7 +375,7 @@ export function plainSegments(chapter, spec, version) {
|
|
|
370
375
|
}
|
|
371
376
|
|
|
372
377
|
export function createEditorialService(llm, library, {
|
|
373
|
-
cleanWindow = CLEAN_WINDOW, castWindow = { chars: CAST_WINDOW, segments: CAST_SEGMENTS }, timeouts = {}, gate = createStreamGate(),
|
|
378
|
+
cleanWindow = CLEAN_WINDOW, castWindow = { chars: CAST_WINDOW, segments: CAST_SEGMENTS }, extractChars = null, timeouts = {}, gate = createStreamGate(),
|
|
374
379
|
} = {}) {
|
|
375
380
|
return {
|
|
376
381
|
// onCastBatch(prefix): called after every finished cast batch (and once at the
|
|
@@ -441,7 +446,7 @@ export function createEditorialService(llm, library, {
|
|
|
441
446
|
let scriptLines = null
|
|
442
447
|
if (spec.cast && EXTRACT_SCRIPT && progress.script === 'extract-v1') {
|
|
443
448
|
progress.stage = 'scripting'
|
|
444
|
-
const windowLimit =
|
|
449
|
+
const windowLimit = Number.isSafeInteger(extractChars) && extractChars > 0 ? extractChars : extractWindowChars(spec.selection)
|
|
445
450
|
progress.windows ??= extractSourceWindows(chapter.text, removed, windowLimit).map(item => ({ ...item, state: 'pending', splits: 0 }))
|
|
446
451
|
reopenGappedWindows(progress)
|
|
447
452
|
progress.cast ??= []
|
|
@@ -461,7 +466,7 @@ export function createEditorialService(llm, library, {
|
|
|
461
466
|
const started = Date.now()
|
|
462
467
|
let seen
|
|
463
468
|
try {
|
|
464
|
-
const value = await ask(llm, spec.selection, prompt, payload, signal,
|
|
469
|
+
const value = await ask(llm, spec.selection, prompt, payload, signal, extractOutputLimit(spec.selection), { ...requestOptions, onUsage: usage => { seen = normalizeModelUsage(usage) } })
|
|
465
470
|
noteAttempt(progress, { phase: 'cast', batch: index, model: modelLabel(spec.selection), count: progress.aiRequests, ms: Date.now() - started, reason: 'stop', usage: seen })
|
|
466
471
|
return value
|
|
467
472
|
} catch (error) {
|