dsh-laivox-tts 0.7.21 → 0.7.22
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/package.json +1 -1
- package/src/host/cast.mjs +53 -15
- package/src/host/editorial.mjs +2 -2
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.22` 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.22` 可锁定版本),或从 [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/package.json
CHANGED
package/src/host/cast.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
2
|
import { normalizeInstruct } from '../domain/voice-direction.mjs'
|
|
3
3
|
import { ROLE_AGES } from '../domain/voice-assignment.mjs'
|
|
4
|
-
import { dialogueMatches } from '../domain/segment.mjs'
|
|
4
|
+
import { dialogueMatches, hasSpeakable } from '../domain/segment.mjs'
|
|
5
5
|
import { alignLine, uncoveredSpeakable } from '../domain/script-lines.mjs'
|
|
6
6
|
|
|
7
7
|
export const EMOTIONS = ['neutral', 'happy', 'sad', 'angry', 'afraid', 'tense', 'gentle']
|
|
@@ -213,7 +213,7 @@ export const EXTRACT = [
|
|
|
213
213
|
'【说话人】',
|
|
214
214
|
'1. 只有角色说出口的话,或明确的内心独白,归该角色。动作、神态、环境和“他说”“她问道”归 narrator。',
|
|
215
215
|
'2. 没有写名字的引号对白不能标成 narrator。根据上一句动作或对话的另一方判断;不知道真名时新建“男人”“女人”“陌生人”。',
|
|
216
|
-
'3.
|
|
216
|
+
'3. 段首 AAAA:BBBB。AAAA 只是纯名字、没有动作神态和环境时,丢掉这个名字,BBBB 以及同一人紧接着说的后文都归这个人;名字在 roles 里就用对应 ref,不在才新建。禁止把「审问者:姓名?」整句标成 narrator。AAAA 带动作则归旁白:这半句连冒号归 narrator,后面的话另成一条。',
|
|
217
217
|
'4. 复用 roles 里的 ref。新角色先声明 {"ref":"new1","name":"角色名","gender":"female|male|","age":"child|teen|young|middle|elder|"},最多 12 个。',
|
|
218
218
|
'',
|
|
219
219
|
'【正文与语气】',
|
|
@@ -306,22 +306,58 @@ function narrationInstruct(lines, at) {
|
|
|
306
306
|
return before?.instruct || after?.instruct || '客观叙述,语气平稳。'
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
//
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
// "叶文洁:我没走。" is a labeled turn. "雷志成压低了声音说:" is not: nothing speakable follows the colon.
|
|
310
|
+
function colonTail(text) {
|
|
311
|
+
const match = /^([^\s,。!?;:、]{1,12})[::][ \t]*([\s\S]*)$/u.exec(String(text ?? '').trim())
|
|
312
|
+
if (!match || !hasSpeakable(match[2])) return null
|
|
313
|
+
return { name: match[1].normalize('NFKC'), speech: match[2].trim() }
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// A known role wins even when the name contains 问 or 说, as in 审问者.
|
|
317
|
+
function labeledByRole(text, roles) {
|
|
318
|
+
const trimmed = String(text ?? '').trim()
|
|
319
|
+
let found = null
|
|
320
|
+
const seen = new Set()
|
|
321
|
+
for (const role of roles ?? []) {
|
|
322
|
+
if (!role || role.id === NARRATOR.id || seen.has(role.id)) continue
|
|
323
|
+
seen.add(role.id)
|
|
324
|
+
const name = roleName(role.name)
|
|
325
|
+
if (!name || [...name].length > 12 || !trimmed.startsWith(name)) continue
|
|
326
|
+
const rest = trimmed.slice(name.length).trimStart()
|
|
327
|
+
if (!/^[::]/u.test(rest)) continue
|
|
328
|
+
const speech = rest.replace(/^[::][ \t]*/u, '').trim()
|
|
329
|
+
if (!hasSpeakable(speech)) continue
|
|
330
|
+
if (!found || [...name].length > [...found.name].length) found = { role, name, speech }
|
|
331
|
+
}
|
|
332
|
+
return found
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Quote-free narration the model skipped is copied back as narrator. A line that
|
|
336
|
+
// still says "名字:台词" goes back to the model. splitKnown is only for the pass
|
|
337
|
+
// after that one repair: a known speaker is split instead of being read as narrator.
|
|
338
|
+
function fillNarrationGaps(windowText, windowStart, lines, roles = [], splitKnown = false) {
|
|
312
339
|
const local = line => ({ start: line.start - windowStart, end: line.end - windowStart })
|
|
313
340
|
const gaps = uncoveredSpeakable(windowText, lines.map(local))
|
|
314
341
|
const dialogue = []
|
|
315
342
|
const next = [...lines]
|
|
316
343
|
for (const gap of gaps) {
|
|
317
344
|
const text = windowText.slice(gap.start, gap.end)
|
|
318
|
-
|
|
345
|
+
const labeled = labeledByRole(text, roles)
|
|
346
|
+
if (labeled && splitKnown) {
|
|
347
|
+
const start = windowStart + gap.start
|
|
348
|
+
next.push({
|
|
349
|
+
roleId: labeled.role.id, content: labeled.speech, source: text, start, end: windowStart + gap.end,
|
|
350
|
+
emotion: 'neutral', intensity: 0,
|
|
351
|
+
})
|
|
352
|
+
continue
|
|
353
|
+
}
|
|
354
|
+
if (labeled || hasQuotedSpeech(text) || colonTail(text)) {
|
|
319
355
|
dialogue.push({ start: gap.start, end: gap.end, text })
|
|
320
356
|
continue
|
|
321
357
|
}
|
|
358
|
+
const start = windowStart + gap.start
|
|
322
359
|
const spoken = text.replace(/^[「」『』“”\s]+/u, '').replace(/[「」『』“”\s]+$/u, '')
|
|
323
360
|
if (!spoken) continue
|
|
324
|
-
const start = windowStart + gap.start
|
|
325
361
|
const instruct = normalizeInstruct(narrationInstruct(next, start))
|
|
326
362
|
next.push({
|
|
327
363
|
roleId: NARRATOR.id, content: spoken, source: text, start, end: windowStart + gap.end,
|
|
@@ -332,11 +368,10 @@ function fillNarrationGaps(windowText, windowStart, lines) {
|
|
|
332
368
|
return { lines: next, dialogue }
|
|
333
369
|
}
|
|
334
370
|
|
|
335
|
-
// A hole
|
|
336
|
-
// back here
|
|
337
|
-
export function narrationSlice(text, start) {
|
|
338
|
-
|
|
339
|
-
const filled = fillNarrationGaps(text, start, [])
|
|
371
|
+
// A hole inside a window that already succeeded. Only plain narration is copied
|
|
372
|
+
// back here. A labeled or quoted hole returns null so the caller asks the model.
|
|
373
|
+
export function narrationSlice(text, start, roles = []) {
|
|
374
|
+
const filled = fillNarrationGaps(text, start, [], roles, false)
|
|
340
375
|
return filled.dialogue.length ? null : filled.lines
|
|
341
376
|
}
|
|
342
377
|
|
|
@@ -356,8 +391,10 @@ export async function extractWindow(windowText, windowStart, bookRoles, context,
|
|
|
356
391
|
if (error?.message === 'MODEL_OUTPUT_INVALID') return { truncated: true, lines: [], gaps: [], roles: [], complete: false }
|
|
357
392
|
throw error
|
|
358
393
|
}
|
|
359
|
-
const
|
|
394
|
+
const knownRoles = [...bookRoles, ...first.roles]
|
|
395
|
+
const absorbed = fillNarrationGaps(windowText, windowStart, first.lines, knownRoles, false)
|
|
360
396
|
if (!absorbed.dialogue.length) return { lines: absorbed.lines, roles: first.roles, gaps: [], complete: true, truncated: false }
|
|
397
|
+
const settle = (lines, roleList) => fillNarrationGaps(windowText, windowStart, lines, roleList, true)
|
|
361
398
|
let repair
|
|
362
399
|
try {
|
|
363
400
|
repair = await request(EXTRACT + '\n' + REPAIR_EXTRACT, {
|
|
@@ -366,7 +403,8 @@ export async function extractWindow(windowText, windowStart, bookRoles, context,
|
|
|
366
403
|
})
|
|
367
404
|
} catch (error) {
|
|
368
405
|
if (error?.message === 'MODEL_RESPONSE_TRUNCATED' || error?.message === 'MODEL_OUTPUT_INVALID') {
|
|
369
|
-
|
|
406
|
+
const settled = settle(absorbed.lines, knownRoles)
|
|
407
|
+
return { lines: settled.lines, roles: first.roles, gaps: settled.dialogue, complete: settled.dialogue.length === 0, truncated: false }
|
|
370
408
|
}
|
|
371
409
|
throw error
|
|
372
410
|
}
|
|
@@ -387,6 +425,6 @@ export async function extractWindow(windowText, windowStart, bookRoles, context,
|
|
|
387
425
|
}
|
|
388
426
|
for (const role of extra.roles) roles.set(role.id, role)
|
|
389
427
|
}
|
|
390
|
-
const filled =
|
|
428
|
+
const filled = settle(lines, [...knownRoles, ...roles.values()])
|
|
391
429
|
return { lines: filled.lines, roles: [...roles.values()], gaps: filled.dialogue, complete: filled.dialogue.length === 0, truncated: false }
|
|
392
430
|
}
|
package/src/host/editorial.mjs
CHANGED
|
@@ -497,8 +497,8 @@ export function createEditorialService(llm, library, {
|
|
|
497
497
|
const context = doneLines.slice(-2).map(line => ({ source: line.source, roleName: names.get(line.roleId) ?? '' }))
|
|
498
498
|
const knownIds = new Set(known.map(role => role.id))
|
|
499
499
|
const nested = progress.windows.some(row => row !== item && row.state === 'done' && row.start <= item.start && row.end >= item.end)
|
|
500
|
-
const local = nested ? narrationSlice(item.text, item.start) : null
|
|
501
|
-
const output = local ? { lines: local, roles: [], truncated: false } : await extractWindow(item.text, item.start, known, context, (prompt, payload) => request(prompt, payload, index), withSeed(paletteFrom(progress.cast, known), progress.seed, knownIds), [NARRATOR, ...allRoles])
|
|
500
|
+
const local = nested ? narrationSlice(item.text, item.start, allRoles) : null
|
|
501
|
+
const output = local != null ? { lines: local, roles: [], truncated: false } : await extractWindow(item.text, item.start, known, context, (prompt, payload) => request(prompt, payload, index), withSeed(paletteFrom(progress.cast, known), progress.seed, knownIds), [NARRATOR, ...allRoles])
|
|
502
502
|
if (output.truncated) {
|
|
503
503
|
if ((item.splits ?? 0) >= 1) {
|
|
504
504
|
item.state = 'gap'
|