decklight 0.3.0 → 0.5.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/README.md +9 -3
- package/SPEC.md +57 -16
- package/cli/agents.mjs +127 -17
- package/cli/associate.mjs +12 -5
- package/cli/decklight.mjs +9 -0
- package/cli/edit.mjs +27 -6
- package/cli/marketplace.mjs +258 -77
- package/cli/plugin.mjs +9 -1
- package/cli/present.mjs +11 -7
- package/cli/report-bug.mjs +9 -1
- package/cli/skill-content.mjs +5 -5
- package/cli/theme.mjs +32 -14
- package/cli/units.mjs +19 -7
- package/cli/update-check.mjs +156 -0
- package/cli/wizard.mjs +184 -16
- package/dist/decklight.js +47 -47
- package/dist/decklight.js.map +4 -4
- package/package.json +7 -4
- package/tools/chrome.mjs +42 -16
- package/tools/local-voice.mjs +33 -2
- package/tools/theme-check.mjs +6 -1
- package/tools/tts-engines.mjs +10 -1
- package/tools/video.mjs +214 -41
- package/tools/voiceover.mjs +69 -11
package/tools/voiceover.mjs
CHANGED
|
@@ -108,13 +108,36 @@ const clean = (s) => s
|
|
|
108
108
|
.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&')
|
|
109
109
|
.replace(/\s+/g, ' ')
|
|
110
110
|
.trim();
|
|
111
|
-
const
|
|
111
|
+
const raw = sections.map((sec) => {
|
|
112
112
|
const aside = sec.match(NOTES_ASIDE);
|
|
113
|
-
if (aside) return
|
|
113
|
+
if (aside) return aside[1];
|
|
114
114
|
const md = sec.match(/^Note:\s*$([\s\S]*?)(?=^Rehearse:\s*$|<\/script>)/m);
|
|
115
|
-
|
|
116
|
-
return '';
|
|
115
|
+
return md ? md[1] : '';
|
|
117
116
|
});
|
|
117
|
+
const slides = raw.map(clean);
|
|
118
|
+
/**
|
|
119
|
+
* A slide's ⟨CLICK⟩ segments, or null when there is only one.
|
|
120
|
+
*
|
|
121
|
+
* These are the author's own build cues, and the sync rule they carry already
|
|
122
|
+
* ships: src/core/narration.js speaks segment k over build step k in live
|
|
123
|
+
* playback, and captions, rehearse mode and the notes editor all read the same
|
|
124
|
+
* segmentation. Recording them separately is what lets a rendered mp4 mirror
|
|
125
|
+
* that (SPEC PRESENTING). An empty segment is dropped rather than synthesised
|
|
126
|
+
* as silence — a ⟨CLICK⟩ at the very start or end of a note is punctuation,
|
|
127
|
+
* not a beat.
|
|
128
|
+
*/
|
|
129
|
+
export const notesSegments = (notes) => {
|
|
130
|
+
const parts = String(notes ?? '').split('⟨CLICK⟩').map(clean).filter(Boolean);
|
|
131
|
+
return parts.length > 1 ? parts : null;
|
|
132
|
+
};
|
|
133
|
+
// Segmenting needs ffmpeg specifically: the per-slide file is CONCATENATED from
|
|
134
|
+
// the segments, and afconvert (Core Audio, macOS-only) has no concat demuxer.
|
|
135
|
+
// Without it the slide is synthesised whole, exactly as before.
|
|
136
|
+
const canSegment = encoder === 'ffmpeg';
|
|
137
|
+
const segmented = raw.map((r) => (canSegment ? notesSegments(r) : null));
|
|
138
|
+
if (!canSegment && raw.some((r) => notesSegments(r))) {
|
|
139
|
+
console.log(' note: ⟨CLICK⟩ segments need ffmpeg to concatenate — narrating each slide whole');
|
|
140
|
+
}
|
|
118
141
|
console.log(`${basename(deckPath)}: ${slides.length} slides, ${slides.filter(Boolean).length} with notes`);
|
|
119
142
|
|
|
120
143
|
// ── optional narration pass through a local model ────────────────────────────
|
|
@@ -164,17 +187,52 @@ for (let i = 0; i < slides.length; i++) {
|
|
|
164
187
|
const hash = slideHash(text);
|
|
165
188
|
manifest.push({ file: `slide-${n}.m4a`, hash });
|
|
166
189
|
if (prev?.slides?.[i]?.hash === hash && existsSync(m4a)) {
|
|
190
|
+
// Carry the segments across, or an unchanged slide loses its build sync on
|
|
191
|
+
// the next rerun: the audio is still on disk and the manifest is the only
|
|
192
|
+
// thing that knows it is there.
|
|
193
|
+
const kept = prev.slides[i].segments;
|
|
194
|
+
if (kept?.every((sg) => existsSync(join(outDir, sg.file)))) manifest[i].segments = kept;
|
|
167
195
|
skipped++;
|
|
168
|
-
console.log(` slide ${n}: unchanged — kept`);
|
|
196
|
+
console.log(` slide ${n}: unchanged — kept${manifest[i].segments ? ` (${manifest[i].segments.length} segments)` : ''}`);
|
|
169
197
|
continue;
|
|
170
198
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
199
|
+
// A segmented slide is synthesised segment by segment, and the per-slide file
|
|
200
|
+
// is CONCATENATED from those — one synthesis, both shapes. TTS is billed per
|
|
201
|
+
// character; asking for the same words twice to get the same audio cut two
|
|
202
|
+
// ways would be a bill nobody agreed to. --reuse-text takes the whole-slide
|
|
203
|
+
// path, since its prior text is one script rather than segments.
|
|
204
|
+
const segs = prior ? null : segmented[i];
|
|
205
|
+
let usage = { cost: 0 };
|
|
206
|
+
if (segs) {
|
|
207
|
+
const parts = [];
|
|
208
|
+
for (let k = 0; k < segs.length; k++) {
|
|
209
|
+
const kk = String(k + 1).padStart(2, '0');
|
|
210
|
+
const sWav = join(outDir, `slide-${n}-${kk}.wav`);
|
|
211
|
+
const sM4a = join(outDir, `slide-${n}-${kk}.m4a`);
|
|
212
|
+
const out = await tts.synth(segs[k], { voice, style });
|
|
213
|
+
writeFileSync(sWav, out.wav);
|
|
214
|
+
usage = { cost: usage.cost + (out.usage?.cost ?? 0) };
|
|
215
|
+
toAac(sWav, sM4a);
|
|
216
|
+
if (!keepWav) rmSync(sWav);
|
|
217
|
+
parts.push({ file: `slide-${n}-${kk}.m4a`, path: sM4a });
|
|
218
|
+
}
|
|
219
|
+
const list = join(outDir, `slide-${n}.concat`);
|
|
220
|
+
writeFileSync(list, `${parts.map((p) => `file '${p.path.replaceAll("'", "'\\''")}'`).join('\n')}\n`);
|
|
221
|
+
execFileSync('ffmpeg', ['-y', '-f', 'concat', '-safe', '0', '-i', list, '-c', 'copy', m4a],
|
|
222
|
+
{ stdio: 'ignore' });
|
|
223
|
+
rmSync(list, { force: true });
|
|
224
|
+
manifest[i].segments = parts.map((p) => ({ file: p.file }));
|
|
225
|
+
} else {
|
|
226
|
+
const out = await tts.synth(text, { voice, style });
|
|
227
|
+
writeFileSync(wav, out.wav);
|
|
228
|
+
usage = out.usage ?? { cost: 0 };
|
|
229
|
+
toAac(wav, m4a);
|
|
230
|
+
if (!keepWav) rmSync(wav);
|
|
231
|
+
}
|
|
232
|
+
totalCost += usage.cost ?? 0;
|
|
174
233
|
const costNote = usage.cost ? ` · ~$${usage.cost.toFixed(4)}` : '';
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
console.log(` slide ${n}: ${text.length} chars → ${basename(m4a)}${costNote}`);
|
|
234
|
+
console.log(` slide ${n}: ${text.length} chars → ${basename(m4a)}`
|
|
235
|
+
+ `${segs ? ` (${segs.length} ⟨CLICK⟩ segments)` : ''}${costNote}`);
|
|
178
236
|
// crash-safe: persist progress after every slide so an interrupted run
|
|
179
237
|
// resumes incrementally instead of re-synthesizing everything
|
|
180
238
|
writeFileSync(join(outDir, 'manifest.json'),
|