decklight 0.8.0 → 0.9.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/PLATFORM.md +666 -0
- package/README.md +224 -150
- package/SPEC.md +732 -886
- package/cli/agent-review.mjs +245 -0
- package/cli/agents.mjs +25 -5
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +183 -0
- package/cli/bundle.mjs +383 -31
- package/cli/cast.mjs +7 -7
- package/cli/check.mjs +961 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +44 -19
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +59 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +409 -0
- package/cli/design-system.mjs +429 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +445 -0
- package/cli/edit-look.mjs +388 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2126 -842
- package/cli/enhance.mjs +483 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +65 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +400 -234
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace.mjs +215 -21
- package/cli/narrate.mjs +176 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +943 -0
- package/cli/pdf.mjs +41 -13
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +71 -26
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +14 -12
- package/cli/remote.mjs +11 -11
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +235 -44
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +190 -33
- package/cli/skills.mjs +107 -24
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +515 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +39 -42
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1126 -49
- package/dist/decklight.js +212 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +753 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +35 -2
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +196 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +19 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +461 -48
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
package/tools/local-voice.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import { run, PROBE_MS } from './exec.mjs';
|
|
|
24
24
|
// beats a bridge that starts and never speaks.
|
|
25
25
|
|
|
26
26
|
const PIPER_SUGGEST = 'piper is the free offline voice — install it with '
|
|
27
|
-
+ '`uv tool install piper-tts`, then run `decklight
|
|
27
|
+
+ '`uv tool install piper-tts`, then run `decklight setup voice`';
|
|
28
28
|
|
|
29
29
|
/** `say -v '?'` on macOS: one voice per line, name, locale, sample sentence. */
|
|
30
30
|
export const SAY_LIST = ['-v', '?'];
|
|
@@ -117,6 +117,23 @@ const QUALITY_SUFFIX = /\s*\((?:Personal Voice|Siri[^)]*|Premium|Neural|Enhanced
|
|
|
117
117
|
/** `Daniel (Enhanced)` → `Daniel`; `Eddy (English (UK))` → unchanged. */
|
|
118
118
|
export const plainName = (name) => String(name ?? '').replace(QUALITY_SUFFIX, '').trim();
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* macOS 27 names a plain voice by its language too — `Daniel (English (UK))`,
|
|
122
|
+
* `Samantha (English (US))`, where earlier releases said `Daniel` and
|
|
123
|
+
* `Samantha`. A language-and-region pair, always nested exactly this way; a
|
|
124
|
+
* quality marker (`(Enhanced)`) is never nested, so the two cannot be taken for
|
|
125
|
+
* each other.
|
|
126
|
+
*/
|
|
127
|
+
const LANGUAGE_SUFFIX = /\s*\([^()]+\([^()]+\)\)\s*$/;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The name under both suffixes: `Daniel (English (UK))` and `Daniel (Enhanced)`
|
|
131
|
+
* are both `Daniel`. For MATCHING only — a row keeps the name `say -v` was
|
|
132
|
+
* given, because the two are different builds: on macOS 27 `say -v Daniel`
|
|
133
|
+
* speaks the Enhanced one and `say -v "Daniel (English (UK))"` the compact one.
|
|
134
|
+
*/
|
|
135
|
+
export const baseName = (name) => plainName(name).replace(LANGUAGE_SUFFIX, '').trim();
|
|
136
|
+
|
|
120
137
|
/**
|
|
121
138
|
* Drop a plain voice that is the SAME VOICE as a better one beside it.
|
|
122
139
|
*
|
|
@@ -162,7 +179,10 @@ export function withoutSupersededPlain(voices = [], { keep } = {}) {
|
|
|
162
179
|
return voices.filter((v) => {
|
|
163
180
|
if (!Number.isInteger(v?.tier) || v.tier !== PLAIN_TIER) return true;
|
|
164
181
|
if (keep && v.name === keep) return true;
|
|
165
|
-
|
|
182
|
+
// by BASE name: on macOS 27 the plain twin of `Daniel (Enhanced)` is
|
|
183
|
+
// listed as `Daniel (English (UK))`, and matching the whole name let every
|
|
184
|
+
// one of them through
|
|
185
|
+
return !better.has(`${(v.locale || '').toLowerCase()}\u0000${baseName(v.name)}`);
|
|
166
186
|
});
|
|
167
187
|
}
|
|
168
188
|
|
|
@@ -189,7 +209,13 @@ export function parseSayVoices(stdout, { lang } = {}) {
|
|
|
189
209
|
const name = m[1].trim();
|
|
190
210
|
if (!name) continue;
|
|
191
211
|
const sample = (m[3] ?? '').trim();
|
|
192
|
-
|
|
212
|
+
const locale = m[2].replace('-', '_');
|
|
213
|
+
// macOS 27 prints some voices twice, line for line — one voice, and a
|
|
214
|
+
// picker that offered it twice would be offering nothing more. Line for
|
|
215
|
+
// line means the SAMPLE too: a Siri voice listed under a plain voice's name
|
|
216
|
+
// differs only there, and is the other rule's to drop (below).
|
|
217
|
+
if (out.some((v) => v.name === name && v.locale === locale && v.sample === sample)) continue;
|
|
218
|
+
out.push({ name, locale, tier: sayTier(name, sample), sample });
|
|
193
219
|
}
|
|
194
220
|
// the unaddressable Siri duplicates (see above), and the `((null))`
|
|
195
221
|
// artifacts an undownloaded Siri stub can leave in the listing — both are
|
|
@@ -355,7 +381,7 @@ export function detectLocalVoice({
|
|
|
355
381
|
engine: null,
|
|
356
382
|
why: 'Android has a system voice, but only as an in-app Java API — there is no '
|
|
357
383
|
+ 'command line behind it, so nothing here can drive it',
|
|
358
|
-
suggest: 'record the narration on a desktop (decklight
|
|
384
|
+
suggest: 'record the narration on a desktop (decklight <deck>, then V → Record this deck…) and ship the '
|
|
359
385
|
+ 'audio with the deck — a recorded track needs no bridge at all',
|
|
360
386
|
};
|
|
361
387
|
}
|
|
@@ -376,7 +402,7 @@ export function detectLocalVoice({
|
|
|
376
402
|
caveat: 'the best voices here are Siri’s, a free download: System Settings '
|
|
377
403
|
+ '→ Accessibility → Spoken Content → System Voice → Manage Voices… '
|
|
378
404
|
+ '(open it with: open "x-apple.systempreferences:com.apple.preference.universalaccess") '
|
|
379
|
-
+ '— then
|
|
405
|
+
+ '— then open the deck again',
|
|
380
406
|
}),
|
|
381
407
|
};
|
|
382
408
|
}
|
|
@@ -399,7 +425,7 @@ export function detectLocalVoice({
|
|
|
399
425
|
...(voices.some((v) => v.tier === 0) ? {} : {
|
|
400
426
|
caveat: 'the best voices here are Windows’ natural ones, a free download: Settings '
|
|
401
427
|
+ '→ Accessibility → Narrator → Add natural voices '
|
|
402
|
-
+ '(open it with: start ms-settings:easeofaccess-narrator) — then
|
|
428
|
+
+ '(open it with: start ms-settings:easeofaccess-narrator) — then open the deck again',
|
|
403
429
|
}),
|
|
404
430
|
};
|
|
405
431
|
}
|
|
@@ -426,39 +452,3 @@ export function detectLocalVoice({
|
|
|
426
452
|
suggest: PIPER_SUGGEST,
|
|
427
453
|
};
|
|
428
454
|
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Ollama, which is not a speech engine and is the single most common thing a
|
|
432
|
-
* local-AI user expects to be one.
|
|
433
|
-
*
|
|
434
|
-
* It is probed only so the answer can be honest. Serving LLMs is not serving
|
|
435
|
-
* speech: there is no audio endpoint, and the models people name in this
|
|
436
|
-
* context (Kokoro, Orpheus) either are not Ollama models or need a separate
|
|
437
|
-
* audio decoder Ollama does not run.
|
|
438
|
-
*/
|
|
439
|
-
export const OLLAMA_URL = 'http://127.0.0.1:11434/api/tags';
|
|
440
|
-
|
|
441
|
-
export async function ollamaRunning({ fetchImpl = fetch, timeoutMs = 300 } = {}) {
|
|
442
|
-
// A machine without Ollama must not pay for the question. The signal alone is
|
|
443
|
-
// not enough: it only helps if the implementation honors it, and a socket
|
|
444
|
-
// that hangs before the abort lands would stall dev's startup — which is the
|
|
445
|
-
// one thing this budget exists to prevent. So the timeout is RACED, and the
|
|
446
|
-
// abort is the courtesy that lets the request stop early.
|
|
447
|
-
const ac = new AbortController();
|
|
448
|
-
let timer;
|
|
449
|
-
const expired = new Promise((done) => {
|
|
450
|
-
timer = setTimeout(() => { ac.abort(); done(null); }, timeoutMs);
|
|
451
|
-
});
|
|
452
|
-
try {
|
|
453
|
-
const answered = Promise.resolve()
|
|
454
|
-
.then(() => fetchImpl(OLLAMA_URL, { signal: ac.signal }))
|
|
455
|
-
.catch(() => null);
|
|
456
|
-
const r = await Promise.race([answered, expired]);
|
|
457
|
-
return !!r?.ok;
|
|
458
|
-
} finally {
|
|
459
|
-
clearTimeout(timer);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
export const OLLAMA_NOTE = 'Ollama is running, but it serves LLMs and cannot speak — '
|
|
464
|
-
+ 'it has no speech endpoint';
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// Copyright 2026 Gilles Philippart
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A narration track's manifest.json — what the synthesis core writes
|
|
6
|
+
* (tools/narration-synth.mjs, behind `decklight narrate`) and
|
|
7
|
+
* the deck's own synthesized recorder now writes too (#535), so the two are
|
|
8
|
+
* interchangeable to everything that reads one: `decklight video`, the export
|
|
9
|
+
* dialog, the narration picker.
|
|
10
|
+
*
|
|
11
|
+
* { engine, model, voice, style, slides: [{ file, hash, segments: [{ file }] } | null] }
|
|
12
|
+
*
|
|
13
|
+
* `hash` is the CLIP KEY shortened — the same key the on-disk clip cache files
|
|
14
|
+
* a sentence under — computed over the slide's whole cleaned notes, so "is
|
|
15
|
+
* this folder still the deck's notes?" (`video`, #536) and "has anyone paid
|
|
16
|
+
* for these words?" (the cache) are one definition, never two.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { createHash } from 'node:crypto';
|
|
20
|
+
import { cacheKey } from './tts-cache.mjs';
|
|
21
|
+
import { readsAudioTags } from './elevenlabs-tts.mjs';
|
|
22
|
+
import { sectionBodies, NOTES_ASIDE, cleanNotes, readNotes, isHiddenSection } from './deck-html.mjs';
|
|
23
|
+
import { deckConfig } from '../cli/runtime-link.mjs';
|
|
24
|
+
import { PAUSE_MARK } from './sentences.mjs';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Each slide's notes as WRITTEN — the notes aside's markup, or a markdown
|
|
28
|
+
* Note: block, ⟨CLICK⟩ markers and all; '' for a hidden slide (no file, and
|
|
29
|
+
* the numbering stays) or one with no notes. Index i is slide i+1. The raw
|
|
30
|
+
* form is what the ⟨CLICK⟩ beats are cut from (tools/narration-synth.mjs), so
|
|
31
|
+
* every marker comes back in its canonical form (`readNotes`): entity
|
|
32
|
+
* brackets, `[click]`, `<pause>` and the rest, the way the runtime reads them.
|
|
33
|
+
*/
|
|
34
|
+
export function slideNotes(html) {
|
|
35
|
+
return sectionBodies(html).map((sec) => {
|
|
36
|
+
if (isHiddenSection(sec)) return '';
|
|
37
|
+
const aside = sec.match(NOTES_ASIDE);
|
|
38
|
+
if (aside) return readNotes(aside[1]);
|
|
39
|
+
const md = sec.match(/^Note:\s*$([\s\S]*?)(?=^Rehearse:\s*$|<\/script>)/m);
|
|
40
|
+
return md ? readNotes(md[1]) : '';
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Each slide's narration text, from the deck FILE — exactly what the
|
|
46
|
+
* synthesis core voices (tools/narration-synth.mjs): the notes, ⟨CLICK⟩
|
|
47
|
+
* markers removed, whitespace collapsed; '' for a hidden slide or one with no
|
|
48
|
+
* notes. Index i is slide i+1.
|
|
49
|
+
*
|
|
50
|
+
* ⟨PAUSE⟩ markers STAY (#560). A recording bakes the hold into its audio, so
|
|
51
|
+
* a take made before a marker was added — or moved — is not the deck's take
|
|
52
|
+
* any more, and this is the text the hash is taken over. A slide with no
|
|
53
|
+
* marker reads exactly as it did before markers existed: no track churns.
|
|
54
|
+
*/
|
|
55
|
+
export const slideTexts = (html) => slideNotes(html).map((raw) => (raw ? cleanNotes(raw, { marks: true }) : ''));
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Each slide's narration text as this file read it before it decoded entities
|
|
59
|
+
* beyond `< > &` — `—` was the letters of its name, and a
|
|
60
|
+
* marker written with entity brackets was not a marker.
|
|
61
|
+
*
|
|
62
|
+
* Only the DECK's recorder (`recorder: 'deck'`) needs it: it voiced the
|
|
63
|
+
* browser's reading, which always decoded, but was stamped over this one, so a
|
|
64
|
+
* slide of it whose stamp matches this text is still these words — not stale
|
|
65
|
+
* because the reader got better. A track the synthesis core voiced from this
|
|
66
|
+
* text spoke the entity's name, and being flagged is the fix.
|
|
67
|
+
*/
|
|
68
|
+
export const priorSlideTexts = (html) => sectionBodies(html).map((sec) => {
|
|
69
|
+
if (isHiddenSection(sec)) return '';
|
|
70
|
+
const raw = sec.match(NOTES_ASIDE)?.[1] ?? sec.match(/^Note:\s*$([\s\S]*?)(?=^Rehearse:\s*$|<\/script>)/m)?.[1];
|
|
71
|
+
return raw ? raw.replace(/⟨CLICK⟩/g, ' ').replace(/⟨PAUSE⟩/g, ` ${PAUSE_MARK} `).replace(/<[^>]+>/g, ' ')
|
|
72
|
+
.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&')
|
|
73
|
+
.replace(/\s+/g, ' ').trim() : '';
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The built-in beat pause, mirrored from the runtime (src/core/narration.js
|
|
78
|
+
* `BEAT_PAUSE_S`), which the CLI may not import; test/narration-manifest
|
|
79
|
+
* pins the two together, the way test/video pins the slide pause.
|
|
80
|
+
*/
|
|
81
|
+
export const BEAT_PAUSE_DEFAULT = 0.5;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Seconds one ⟨PAUSE⟩ holds on each slide: two beat pauses (#560), resolved
|
|
85
|
+
* the way the runtime's `pauseFor` resolves every narration pause — the
|
|
86
|
+
* section's `data-narration-beat-pause`, else the configuration block's
|
|
87
|
+
* `narration.beatPause`, else the default; a value that is not a finite
|
|
88
|
+
* number ≥ 0 falls through to the next tier. Read off the section's OPEN tag,
|
|
89
|
+
* so the attribute in a slide's content is never mistaken for the slide's.
|
|
90
|
+
* Index i is slide i+1.
|
|
91
|
+
*/
|
|
92
|
+
export function markerPauses(html) {
|
|
93
|
+
const cfg = deckConfig(html)?.narration?.beatPause;
|
|
94
|
+
const deck = typeof cfg === 'number' && Number.isFinite(cfg) && cfg >= 0 ? cfg : BEAT_PAUSE_DEFAULT;
|
|
95
|
+
return sectionBodies(html).map((sec) => {
|
|
96
|
+
const raw = sec.slice(0, sec.indexOf('>')).match(/\sdata-narration-beat-pause="([^"]*)"/)?.[1];
|
|
97
|
+
const n = raw != null && raw.trim() !== '' ? Number(raw) : NaN;
|
|
98
|
+
return 2 * (Number.isFinite(n) && n >= 0 ? n : deck);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The key fields for a manifest header, the way `clipKey` derives them from
|
|
105
|
+
* an engine object (tools/tts-cache.mjs) — spelled out per engine here
|
|
106
|
+
* because a manifest is written where no engine object exists: the author
|
|
107
|
+
* server writing the deck recorder's take knows only what the bridge said of
|
|
108
|
+
* itself. The traits are the engines' own (tools/tts-engines.mjs):
|
|
109
|
+
* piper voiceIsFixed — the model IS the voice, and it is what is keyed
|
|
110
|
+
* say, sapi modelIsDefaultVoice — the spoken voice is keyed, the boot voice is not
|
|
111
|
+
* elevenlabs voice and model both; a delivery style only on eleven_v3 / v4
|
|
112
|
+
* chirp voice and its one model; no style
|
|
113
|
+
* gemini voice and model; the one engine every style reaches
|
|
114
|
+
* `format` is the audio's extension, wav unless a header says otherwise —
|
|
115
|
+
* ElevenLabs alone can be told to speak mp3.
|
|
116
|
+
*/
|
|
117
|
+
export function manifestKey({ engine, model, voice, style, format } = {}, text) {
|
|
118
|
+
const e = engine ?? '';
|
|
119
|
+
const fixed = e === 'piper';
|
|
120
|
+
const defaultVoice = e === 'say' || e === 'sapi';
|
|
121
|
+
const stylable = e === 'gemini' || (e === 'elevenlabs' && readsAudioTags(model));
|
|
122
|
+
return cacheKey({
|
|
123
|
+
engine: e,
|
|
124
|
+
model: fixed || defaultVoice ? undefined : (model ?? undefined),
|
|
125
|
+
format: format ?? 'wav',
|
|
126
|
+
voice: fixed ? model : defaultVoice ? (voice ?? model) : voice,
|
|
127
|
+
style: stylable ? style : undefined,
|
|
128
|
+
text,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** The manifest's per-slide hash: the clip key, shortened (voiceover.mjs `slideHash`). */
|
|
133
|
+
export const manifestHash = (header, text) => manifestKey(header, text).slice(0, 16);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The hash a manifest written before the key carried `model` used
|
|
137
|
+
* (voiceover.mjs `legacyHash`): accepted for a header that predates the
|
|
138
|
+
* field, so a folder recorded then is not flagged for a formula change.
|
|
139
|
+
*/
|
|
140
|
+
export const legacyHash = ({ engine, voice, style } = {}, text) => createHash('sha256')
|
|
141
|
+
.update(`${engine}|${voice}|${style}|${text}`).digest('hex').slice(0, 16);
|
|
142
|
+
|
|
143
|
+
/** Does this manifest slide entry vouch for `text`, under its header? */
|
|
144
|
+
export function entryMatches(header, entry, text) {
|
|
145
|
+
if (!entry?.hash) return true; // a hand-recorded take carries no hash to disagree
|
|
146
|
+
if (entry.hash === manifestHash(header, text)) return true;
|
|
147
|
+
return header?.model === undefined && entry.hash === legacyHash(header, text);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The slides of `manifest` whose audio was voiced from other notes than
|
|
152
|
+
* `texts` — 1-based, within `range` (default: every slide the manifest has).
|
|
153
|
+
* `hashless` counts the entries with no hash at all, which are exempt and
|
|
154
|
+
* worth one line rather than a verdict. `prior` (`priorSlideTexts`) lets a
|
|
155
|
+
* deck-recorded slide stamped under the old reading of the file stand.
|
|
156
|
+
*/
|
|
157
|
+
export function staleSlides(manifest, texts, range = null, prior = null) {
|
|
158
|
+
const out = { stale: [], hashless: 0 };
|
|
159
|
+
const slides = manifest?.slides ?? [];
|
|
160
|
+
for (let i = 0; i < slides.length; i++) {
|
|
161
|
+
const n = i + 1;
|
|
162
|
+
if (range && (n < range.from || n > range.to)) continue;
|
|
163
|
+
const entry = slides[i];
|
|
164
|
+
if (!entry) continue;
|
|
165
|
+
if (!entry.hash) { out.hashless++; continue; }
|
|
166
|
+
if (entryMatches(manifest, entry, texts[i] ?? '')) continue;
|
|
167
|
+
if (manifest.recorder === 'deck' && prior?.[i] && entryMatches(manifest, entry, prior[i])) continue;
|
|
168
|
+
out.stale.push(n);
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The manifest the deck recorder writes, after each slide of a take (#535):
|
|
175
|
+
* `recorded` maps slide number → its beat file numbers; every slide inside
|
|
176
|
+
* `range` not in it has no notes and is null; every slide outside it keeps
|
|
177
|
+
* `prev`'s entry — a ranged re-record is a surgical redo, the same promise
|
|
178
|
+
* `voiceover --slides` makes. Files are wav: the recorder stitches WAV.
|
|
179
|
+
*/
|
|
180
|
+
export function recorderManifest({ prev, header, texts, range, recorded }) {
|
|
181
|
+
const total = Math.max(texts.length, prev?.slides?.length ?? 0);
|
|
182
|
+
const slides = [];
|
|
183
|
+
for (let i = 0; i < total; i++) {
|
|
184
|
+
const n = i + 1;
|
|
185
|
+
if (n < range.from || n > range.to) { slides.push(prev?.slides?.[i] ?? null); continue; }
|
|
186
|
+
const take = recorded[n];
|
|
187
|
+
if (!take) { slides.push(null); continue; }
|
|
188
|
+
const nn = String(n).padStart(2, '0');
|
|
189
|
+
const entry = { file: `slide-${nn}.wav`, hash: manifestHash(header, texts[i] ?? '') };
|
|
190
|
+
const segs = (take.segments ?? []).filter((k) => Number.isInteger(k) && k > 0);
|
|
191
|
+
if (segs.length) entry.segments = segs.map((k) => ({ file: `slide-${nn}-${String(k).padStart(2, '0')}.wav` }));
|
|
192
|
+
slides.push(entry);
|
|
193
|
+
}
|
|
194
|
+
const { engine, model, voice, style } = header;
|
|
195
|
+
return { engine, model, voice, style, recorder: 'deck', slides };
|
|
196
|
+
}
|