@slidevideo/cli 0.1.2 → 0.2.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/IMPRESSUM.md +18 -4
  3. package/LICENSE-TERMS.md +46 -13
  4. package/README.md +3 -3
  5. package/addons/slidevideo/global-top.vue +1 -1
  6. package/addons/slidevideo/playback-entries.ts +1 -1
  7. package/addons/slidevideo/preview.ts +2 -2
  8. package/dist/adapters/browser-runtime.d.ts +3 -0
  9. package/dist/adapters/elevenlabs.d.ts +1 -0
  10. package/dist/adapters/elevenlabs.js +8 -4
  11. package/dist/adapters/powerpoint.d.ts +1 -1
  12. package/dist/adapters/powerpoint.js +10 -11
  13. package/dist/adapters/slidev-inspection.js +2 -4
  14. package/dist/adapters/slidev-server.js +136 -15
  15. package/dist/adapters/slidev.d.ts +9 -0
  16. package/dist/adapters/slidev.js +347 -62
  17. package/dist/annotations.d.ts +1 -1
  18. package/dist/annotations.js +3 -3
  19. package/dist/assembly.d.ts +44 -38
  20. package/dist/assembly.js +60 -21
  21. package/dist/calibration.js +5 -4
  22. package/dist/cli.js +86 -31
  23. package/dist/compositor.d.ts +30 -3
  24. package/dist/compositor.js +196 -30
  25. package/dist/contracts.d.ts +6 -6
  26. package/dist/executables.d.ts +2 -0
  27. package/dist/executables.js +27 -8
  28. package/dist/media.d.ts +7 -1
  29. package/dist/media.js +23 -4
  30. package/dist/pipeline.d.ts +1 -1
  31. package/dist/pipeline.js +107 -42
  32. package/dist/preview/server.js +4 -4
  33. package/dist/run.d.ts +1 -1
  34. package/dist/run.js +8 -3
  35. package/dist/setup-install.d.ts +1 -0
  36. package/dist/setup-install.js +8 -1
  37. package/dist/setup.d.ts +26 -8
  38. package/dist/setup.js +168 -76
  39. package/dist/speech.js +10 -6
  40. package/dist/storyboard.js +3 -6
  41. package/dist/timing.js +2 -2
  42. package/package.json +1 -3
  43. package/schemas/schedule.v1.json +389 -1
  44. package/schemas/storyboard.v1.json +342 -1
  45. package/skills/slidevideo/SKILL.md +2 -2
  46. package/skills/slidevideo/references/production.md +7 -6
  47. package/skills/slidevideo/references/storyboard.md +9 -8
  48. package/schemas/schedule.v2.json +0 -496
  49. package/schemas/storyboard.v2.json +0 -802
package/dist/setup.js CHANGED
@@ -2,19 +2,30 @@ import { readFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { createInterface } from 'node:readline/promises';
4
4
  import { parseEnv } from 'node:util';
5
+ import { Writable } from 'node:stream';
6
+ import { elevenLabsApiKey } from './adapters/elevenlabs.js';
5
7
  import { chromium } from 'playwright';
6
- import { browserCandidates, browserName, discoverExecutable, findOnPath, isExecutable, saveExecutablePaths, toolCandidate, withExecutables } from './executables.js';
7
- import { requireCondition } from './errors.js';
8
+ import { browserCandidates, browserName, configuredLicense, discoverExecutable, findOnPath, isExecutable, saveElevenLabsKey, saveExecutablePaths, toolCandidate, withExecutables } from './executables.js';
9
+ import { ProductionError, requireCondition } from './errors.js';
8
10
  import { packagePath, userConfigFile } from './installation.js';
9
11
  import { execute } from './media.js';
10
12
  import { ffmpegInstaller, installChromium, installEdgeEnvironment, runInstaller } from './setup-install.js';
11
13
  import { hasLicenseTerminal, setupLicense } from './setup-license.js';
14
+ const presentations = ['slidev', 'powerpoint'];
15
+ const providers = ['edge-tts', 'elevenlabs'];
12
16
  const windows = process.platform === 'win32';
17
+ const macos = process.platform === 'darwin';
13
18
  const ffmpegInstructions = windows
14
19
  ? 'Install FFmpeg with winget install --id Gyan.FFmpeg --exact, or pass --ffmpeg and --ffprobe with the installed paths.'
15
- : 'Install ffmpeg with libx264 and ffprobe through your distribution, or pass --ffmpeg and --ffprobe with the installed paths.';
16
- const browserInstructions = 'Install Chromium and rerun setup, or pass --browser with its executable path.';
17
- const edgeInstructions = `Install Python with venv support or uv, then run setup with --install. For manual setup, install the packages from ${packagePath('tools', 'edge-tts', 'requirements.lock')} in a virtual environment, then pass its interpreter with --python.`;
20
+ : macos
21
+ ? 'Install FFmpeg with brew install ffmpeg, or pass --ffmpeg and --ffprobe with the installed paths.'
22
+ : 'Install ffmpeg with libx264 and ffprobe through your distribution, or pass --ffmpeg and --ffprobe with the installed paths.';
23
+ const browserInstructions = macos
24
+ ? 'Run slidevideo setup --presentation slidev --install to install Chromium, install Chromium manually, or pass --browser with its executable path.'
25
+ : 'Install Chromium and rerun setup, or pass --browser with its executable path.';
26
+ const edgeInstructions = macos
27
+ ? `Install Python 3 with venv support or uv (brew install uv), then run setup with --install. For manual setup, install the packages from ${packagePath('tools', 'edge-tts', 'requirements.lock')} in a virtual environment, then pass its interpreter with --python.`
28
+ : `Install Python with venv support or uv, then run setup with --install. For manual setup, install the packages from ${packagePath('tools', 'edge-tts', 'requirements.lock')} in a virtual environment, then pass its interpreter with --python.`;
18
29
  async function checkTool(tool, verify, instructions) {
19
30
  const candidate = toolCandidate(tool);
20
31
  if (!candidate || !isExecutable(candidate.path)) {
@@ -71,47 +82,43 @@ async function checkPython(path) {
71
82
  ].join('\n');
72
83
  return (await execute(path, ['-c', probe, JSON.stringify(requirements)], 10000)).toString().trim();
73
84
  }
74
- async function choices(options) {
75
- let { presentation, provider, 'voice-id': voiceId } = options;
76
- const { install, manual } = options;
77
- requireCondition(!(install && manual), 'OPTION', 'Choose either --install or --manual');
78
- const interactive = process.stdin.isTTY && !options.json && !options.quiet;
79
- if (interactive) {
80
- const reader = createInterface({ input: process.stdin, output: process.stderr });
81
- try {
82
- presentation ??= (await reader.question('Presentation format (slidev/powerpoint) [slidev]: ')).trim().toLowerCase() || 'slidev';
83
- provider ??= (await reader.question('Speech provider (edge-tts/elevenlabs) [edge-tts]: ')).trim().toLowerCase() || 'edge-tts';
84
- if (provider === 'elevenlabs' && voiceId === undefined)
85
- voiceId = await reader.question('ElevenLabs voice ID: ');
86
- }
87
- finally {
88
- reader.close();
89
- }
85
+ async function checkElevenLabs() {
86
+ try {
87
+ const dotenv = await readFile('.env', 'utf8').catch((error) => {
88
+ if (error.code === 'ENOENT')
89
+ return '';
90
+ throw error;
91
+ });
92
+ const credentials = parseEnv(dotenv);
93
+ const hasKey = !!elevenLabsApiKey({ ...credentials, ...process.env })?.trim();
94
+ return { name: 'elevenlabs-key', ready: hasKey, detail: hasKey ? 'ElevenLabs API key is configured' : 'Run slidevideo setup --provider elevenlabs to save your API key for all projects.' };
95
+ }
96
+ catch {
97
+ return { name: 'elevenlabs-key', ready: false, detail: 'Cannot read the project .env file. Check its format and permissions, then rerun setup.' };
90
98
  }
91
- requireCondition(presentation === 'slidev' || presentation === 'powerpoint', 'OPTION', 'Set --presentation to slidev or powerpoint');
92
- requireCondition(provider === 'edge-tts' || provider === 'elevenlabs', 'OPTION', 'Set --provider to edge-tts or elevenlabs');
93
- return { presentation, provider, voiceId: voiceId?.trim() || (provider === 'edge-tts' ? 'en-US-AriaNeural' : ''), install, manual, interactive };
94
99
  }
95
- export async function setup(options) {
96
- const { presentation, provider, voiceId, install, manual, interactive } = await choices(options);
97
- if (interactive && hasLicenseTerminal())
98
- await setupLicense();
99
- const supported = (process.platform === 'linux' || windows) && (presentation === 'slidev' || windows);
100
+ function choices(options) {
101
+ const { presentation, provider, install, manual } = options;
102
+ requireCondition(!(install && manual), 'OPTION', 'Choose either --install or --manual');
103
+ requireCondition(presentation === undefined || presentations.some(name => name === presentation), 'OPTION', 'Set --presentation to slidev or powerpoint');
104
+ requireCondition(provider === undefined || providers.some(name => name === provider), 'OPTION', 'Set --provider to edge-tts or elevenlabs');
105
+ const selectedPresentations = presentations.filter(name => presentation === undefined || name === presentation);
106
+ const selectedProviders = providers.filter(name => provider === undefined || name === provider);
107
+ const interactive = process.stdin.isTTY && !options.json && !options.quiet && !manual;
108
+ return { selectedPresentations, selectedProviders, install, manual, interactive };
109
+ }
110
+ export async function setup(options, beforePrompts) {
111
+ const { selectedPresentations, selectedProviders, install, manual, interactive } = choices(options);
112
+ const deferred = new Set();
113
+ const supported = process.platform === 'linux' || macos || windows;
100
114
  const installed = {};
101
115
  const installationErrors = [];
102
116
  const checks = async () => {
103
- if (!supported)
104
- return [{ name: 'platform', ready: false, detail: presentation === 'powerpoint' ? 'Use Windows with installed desktop PowerPoint.' : 'Use Linux or Windows.' }];
105
- const media = [
117
+ const shared = supported ? await Promise.all([
106
118
  checkTool('ffmpeg', async (path) => {
107
119
  const encoders = (await execute(path, ['-hide_banner', '-encoders'], 10000)).toString();
108
120
  if (!/^\s*V\S*\s+libx264\s/m.test(encoders))
109
121
  throw new Error('FFmpeg needs the libx264 encoder');
110
- if (presentation === 'powerpoint') {
111
- const devices = (await execute(path, ['-hide_banner', '-devices'], 10000)).toString();
112
- if (!/\bgdigrab\b/.test(devices))
113
- throw new Error('FFmpeg needs the gdigrab input');
114
- }
115
122
  return (await execute(path, ['-version'], 10000)).toString().split(/\r?\n/, 1)[0];
116
123
  }, ffmpegInstructions),
117
124
  checkTool('ffprobe', async (path) => {
@@ -120,36 +127,115 @@ export async function setup(options) {
120
127
  throw new Error('Expected the ffprobe executable');
121
128
  return version;
122
129
  }, ffmpegInstructions),
123
- ];
124
- const visual = presentation === 'slidev'
125
- ? checkTool('browser', checkBrowser, browserInstructions).then(check => [check])
126
- : powerpointChecks();
127
- const speech = provider === 'edge-tts'
128
- ? checkTool('python', checkPython, edgeInstructions).then(check => [check])
129
- : (async () => {
130
- const dotenv = await readFile('.env', 'utf8').catch((error) => {
131
- if (error.code === 'ENOENT')
132
- return '';
133
- throw error;
134
- });
135
- const credentials = parseEnv(dotenv);
136
- const hasKey = !!(process.env.ELEVENLABS_API_KEY ?? credentials.ELEVENLABS_API_KEY ?? process.env.ELEVENLABS_KEY ?? credentials.ELEVENLABS_KEY)?.trim();
137
- return [
138
- { name: 'elevenlabs-key', ready: hasKey, detail: hasKey ? 'ElevenLabs API key is set' : 'Set ELEVENLABS_API_KEY in your environment or project .env file.' },
139
- { name: 'elevenlabs-voice', ready: !!voiceId, detail: voiceId ? 'ElevenLabs voice ID supplied' : 'Pass --voice-id with your ElevenLabs voice ID.' },
140
- ];
141
- })();
142
- const [video, audio, ...mediaTools] = await Promise.all([visual, speech, ...media]);
143
- return [...mediaTools, ...video, ...audio];
130
+ ]) : [{ name: 'platform', ready: false, detail: 'Use Linux, macOS, or Windows.' }];
131
+ const presentationReports = {};
132
+ const providerReports = {};
133
+ const readiness = (checks) => ({
134
+ status: checks.every(check => check.ready) ? 'ready' : 'missing_dependencies', checks,
135
+ });
136
+ await Promise.all(selectedPresentations.map(async (name) => {
137
+ if (!supported || name === 'powerpoint' && !windows) {
138
+ presentationReports[name] = { status: 'unavailable', checks: [{ name: 'platform', ready: false,
139
+ detail: name === 'powerpoint' ? 'Use Windows with installed desktop PowerPoint.' : 'Use Linux, macOS, or Windows.' }] };
140
+ }
141
+ else if (name === 'slidev') {
142
+ presentationReports[name] = readiness([await checkTool('browser', checkBrowser, browserInstructions)]);
143
+ }
144
+ else {
145
+ const [native, capture] = await Promise.all([
146
+ powerpointChecks(),
147
+ checkTool('ffmpeg', async (path) => {
148
+ const devices = (await execute(path, ['-hide_banner', '-devices'], 10000)).toString();
149
+ if (!/\bgdigrab\b/.test(devices))
150
+ throw new Error('FFmpeg needs the gdigrab input');
151
+ return 'FFmpeg has the gdigrab input';
152
+ }, ffmpegInstructions),
153
+ ]);
154
+ presentationReports[name] = readiness([{ ...capture, name: 'ffmpeg-gdigrab' }, ...native]);
155
+ }
156
+ }));
157
+ await Promise.all(selectedProviders.map(async (provider) => {
158
+ let prerequisites;
159
+ if (provider === 'edge-tts') {
160
+ prerequisites = [await checkTool('python', checkPython, edgeInstructions)];
161
+ }
162
+ else {
163
+ prerequisites = [await checkElevenLabs()];
164
+ }
165
+ providerReports[provider] = { ...readiness(prerequisites), ...(deferred.has(provider) ? { deferred: true } : {}) };
166
+ }));
167
+ return { shared_checks: shared, presentations: presentationReports, providers: providerReports };
144
168
  };
145
- let dependencies = await checks();
146
- const missing = (...names) => dependencies.some(check => !check.ready && names.includes(check.name));
147
- const ffmpeg = missing('ffmpeg', 'ffprobe') ? ffmpegInstaller() : undefined;
148
- const canInstall = ffmpeg || missing('browser', 'python');
169
+ let reports = await checks();
170
+ if (interactive) {
171
+ beforePrompts?.(reports);
172
+ let hidden = false;
173
+ const output = new Writable({ write(chunk, _encoding, done) {
174
+ if (!hidden)
175
+ process.stderr.write(chunk);
176
+ done();
177
+ } });
178
+ const reader = createInterface({ input: process.stdin, output, terminal: true, historySize: 0 });
179
+ const controller = new AbortController();
180
+ reader.once('close', () => controller.abort());
181
+ const ask = (prompt) => reader.question(prompt, { signal: controller.signal });
182
+ try {
183
+ for (const provider of selectedProviders) {
184
+ const report = reports.providers[provider];
185
+ if (!report || report.status === 'ready' && options.provider !== 'elevenlabs')
186
+ continue;
187
+ if (options.provider === undefined) {
188
+ const answer = await ask(`Set up ${provider} now? [Y/n, leave for later]: `);
189
+ if (/^n(?:o)?$/i.test(answer.trim())) {
190
+ deferred.add(provider);
191
+ report.deferred = true;
192
+ continue;
193
+ }
194
+ }
195
+ if (provider === 'elevenlabs') {
196
+ process.stderr.write('ElevenLabs API key (hidden; Enter leaves it unchanged): ');
197
+ hidden = true;
198
+ let key;
199
+ try {
200
+ key = (await ask('')).trim();
201
+ }
202
+ finally {
203
+ hidden = false;
204
+ process.stderr.write('\n');
205
+ }
206
+ if (key) {
207
+ await saveElevenLabsKey(key);
208
+ const check = await withExecutables(options, checkElevenLabs);
209
+ reports.providers.elevenlabs = { status: check.ready ? 'ready' : 'missing_dependencies', checks: [check] };
210
+ console.error(`Saved ElevenLabs key to ${userConfigFile()}.`);
211
+ }
212
+ else if (report.status !== 'ready') {
213
+ deferred.add(provider);
214
+ report.deferred = true;
215
+ }
216
+ }
217
+ }
218
+ }
219
+ catch (error) {
220
+ if (controller.signal.aborted)
221
+ throw new ProductionError('INTERRUPTED', 'Provider setup interrupted.', 130);
222
+ throw error;
223
+ }
224
+ finally {
225
+ reader.close();
226
+ }
227
+ if (hasLicenseTerminal() && !configuredLicense())
228
+ await setupLicense();
229
+ }
230
+ const dependencies = () => [...reports.shared_checks,
231
+ ...Object.values(reports.presentations).flatMap(report => report.checks),
232
+ ...Object.values(reports.providers).flatMap(report => report.checks)];
233
+ const missing = (...names) => dependencies().some(check => !check.ready && names.includes(check.name));
234
+ const ffmpeg = supported && missing('ffmpeg', 'ffprobe', 'ffmpeg-gdigrab') ? ffmpegInstaller() : undefined;
235
+ const installEdge = missing('python') && !reports.providers['edge-tts']?.deferred;
236
+ const canInstall = supported && (ffmpeg || missing('browser') || installEdge);
149
237
  let runInstall = install;
150
238
  if (interactive && !install && !manual && canInstall) {
151
- for (const check of dependencies.filter(check => !check.ready))
152
- console.error(check.detail);
153
239
  const reader = createInterface({ input: process.stdin, output: process.stderr });
154
240
  try {
155
241
  runInstall = /^y(?:es)?$/i.test((await reader.question('Install the supported missing dependencies now? [y/N]: ')).trim());
@@ -169,9 +255,10 @@ export async function setup(options) {
169
255
  };
170
256
  if (ffmpeg)
171
257
  await attempt('FFmpeg', async () => {
172
- await runInstaller(ffmpeg.command, ffmpeg.args);
258
+ await runInstaller(ffmpeg.command, ffmpeg.args, ffmpeg.env);
173
259
  for (const tool of ['ffmpeg', 'ffprobe']) {
174
- if (!missing(tool))
260
+ const needsTool = missing(tool) || tool === 'ffmpeg' && missing('ffmpeg-gdigrab');
261
+ if (!needsTool)
175
262
  continue;
176
263
  const path = discoverExecutable(tool);
177
264
  if (path)
@@ -180,13 +267,13 @@ export async function setup(options) {
180
267
  });
181
268
  if (missing('browser'))
182
269
  await attempt('Chromium', async () => { installed.browser = await installChromium(); });
183
- if (missing('python'))
270
+ if (installEdge)
184
271
  await attempt('Edge TTS', async () => { installed.python = await installEdgeEnvironment(); });
185
- dependencies = await withExecutables({ ...options, ...installed }, checks);
272
+ reports = await withExecutables({ ...options, ...installed }, checks);
186
273
  }
187
274
  const paths = {};
188
275
  for (const tool of ['browser', 'python', 'ffmpeg', 'ffprobe']) {
189
- if (!dependencies.some(check => check.name === tool && check.ready))
276
+ if (!dependencies().some(check => check.name === tool && check.ready))
190
277
  continue;
191
278
  const path = installed[tool] ?? (options[tool] !== undefined ? toolCandidate(tool)?.path : undefined);
192
279
  if (path)
@@ -194,23 +281,28 @@ export async function setup(options) {
194
281
  }
195
282
  if (Object.keys(paths).length)
196
283
  await saveExecutablePaths(paths);
197
- const browsers = presentation === 'slidev' ? browserCandidates() : [];
284
+ const browsers = selectedPresentations.includes('slidev') ? browserCandidates() : [];
198
285
  const selected = installed.browser ?? toolCandidate('browser')?.path;
199
- if (presentation === 'slidev' && selected && isExecutable(selected) && !browsers.some(item => item.path === selected)) {
286
+ if (selectedPresentations.includes('slidev') && selected && isExecutable(selected) && !browsers.some(item => item.path === selected)) {
200
287
  browsers.push({ path: selected, name: browserName(selected) });
201
288
  }
202
- const browserRequirement = presentation === 'slidev'
289
+ const browserRequirement = selectedPresentations.includes('slidev')
203
290
  ? 'Slidev recording needs Chromium. The packaged release check uses Chromium on Linux. Google Chrome and Microsoft Edge are detected but their capture workflows are unverified.'
204
291
  : undefined;
205
292
  return {
206
293
  version: 1,
207
294
  command: 'setup',
208
- status: dependencies.every(check => check.ready) ? 'ready' : 'missing_dependencies',
209
- presentation,
210
- voice: { provider, voice: voiceId || 'your-voice-id' },
295
+ status: reports.shared_checks.every(check => check.ready)
296
+ && Object.values(reports.presentations).some(report => report.status === 'ready')
297
+ && Object.values(reports.providers).some(report => report.status === 'ready') ? 'ready' : 'missing_dependencies',
298
+ presentation: options.presentation,
299
+ voice: options.provider ? { provider: options.provider, voice: options['voice-id']?.trim() || (options.provider === 'edge-tts' ? 'en-US-AriaNeural' : 'your-voice-id') } : undefined,
300
+ shared_checks: reports.shared_checks,
301
+ presentations: reports.presentations,
302
+ providers: reports.providers,
211
303
  config_file: userConfigFile(),
212
304
  saved_paths: paths,
213
- checks: dependencies,
305
+ checks: dependencies(),
214
306
  browsers,
215
307
  browser_requirement: browserRequirement,
216
308
  installation_errors: installationErrors,
package/dist/speech.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { mkdir, copyFile, readFile } from 'node:fs/promises';
2
2
  import { join, resolve, dirname } from 'node:path';
3
3
  import { Ajv } from 'ajv';
4
- import { digest, json, saveJson, probe, hashFile, decode, executionScope, audioDuration } from './media.js';
4
+ import { digest, json, saveJson, probe, hashFile, decode, executionSignal, audioDuration } from './media.js';
5
5
  import { requireCondition, ProductionError } from './errors.js';
6
6
  const speechSchema = JSON.parse(await readFile(new URL('../schemas/speech.v1.json', import.meta.url), 'utf8'));
7
7
  const validateSpeech = new Ajv({ allErrors: true }).compile(speechSchema);
@@ -14,6 +14,12 @@ export function speechKey(segment, voice, adapter) {
14
14
  const options = Object.fromEntries(Object.entries(voice.options ?? {}).sort(([a], [b]) => a.localeCompare(b)));
15
15
  return digest(JSON.stringify({ text: segment.text, provider: voice.provider, voice: voice.voice, options, adapter: adapter.id, version: adapter.version }));
16
16
  }
17
+ function matchesSpeechCache(asset, segment, voice, adapter) {
18
+ const key = speechKey(segment, voice, adapter);
19
+ const provenance = asset.provenance;
20
+ const provenanceKey = speechKey({ ...segment, text: asset.transcript.original }, { provider: provenance.provider, voice: provenance.voice, options: provenance.options }, { id: provenance.adapter, version: provenance.version });
21
+ return asset.key === key && provenanceKey === key && asset.transcript.original === segment.text;
22
+ }
17
23
  function checkAlignment(asset) {
18
24
  if (asset.alignment) {
19
25
  const alignment = asset.alignment;
@@ -44,9 +50,7 @@ export async function retainedSpeechTiming(segment, voice, adapter, cache) {
44
50
  const manifest = { version: 1, assets: [entry] };
45
51
  requireCondition(validateSpeech(manifest), 'CACHE_INPUT', `Invalid speech cache entry for ${segment.id}: ${cached}`);
46
52
  const asset = manifest.assets[0];
47
- const provenance = asset.provenance;
48
- const provenanceKey = speechKey({ ...segment, text: asset.transcript.original }, { provider: provenance.provider, voice: provenance.voice, options: provenance.options }, { id: provenance.adapter, version: provenance.version });
49
- if (asset.key !== key || provenanceKey !== key || asset.transcript.original !== segment.text)
53
+ if (!matchesSpeechCache(asset, segment, voice, adapter))
50
54
  return undefined;
51
55
  requireCondition(Number.isFinite(asset.duration_ms) && asset.duration_ms > 0, 'SPEECH_DURATION', `Invalid retained speech duration: ${segment.id}`);
52
56
  checkAlignment(asset);
@@ -71,7 +75,7 @@ export async function generateSpeech(story, directory, adapters, cache, progress
71
75
  const assets = [];
72
76
  progress?.(`Speech: ${story.narration.length} segments`);
73
77
  for (const segment of story.narration) {
74
- executionScope.getStore()?.throwIfAborted();
78
+ executionSignal()?.throwIfAborted();
75
79
  const voice = segment.voice ?? story.voice;
76
80
  requireCondition(voice, 'VOICE_REQUIRED', `Narration ${segment.id} needs a voice`);
77
81
  const adapter = adapters.get(voice.provider);
@@ -98,7 +102,7 @@ export async function generateSpeech(story, directory, adapters, cache, progress
98
102
  if (asset) {
99
103
  progress?.(`Reusing cached speech ${segment.id} (${assets.length + 1}/${story.narration.length})`);
100
104
  asset.audio = resolve(dirname(cached), asset.audio);
101
- requireCondition(asset.key === key && asset.transcript.original === segment.text, 'CACHE_MISMATCH', `Cache does not match ${segment.id}`);
105
+ requireCondition(matchesSpeechCache(asset, segment, voice, adapter), 'CACHE_MISMATCH', `Cache does not match ${segment.id}`);
102
106
  await checkSpeech(asset);
103
107
  await decode(asset.audio);
104
108
  const destination = speechPath(directory, segment.id, asset.format);
@@ -5,7 +5,7 @@ import { parse } from 'yaml';
5
5
  import { Ajv } from 'ajv';
6
6
  import { requireCondition, ProductionError } from './errors.js';
7
7
  import { hashFile, digest } from './media.js';
8
- const validators = await Promise.all([1, 2].map(async (version) => new Ajv({ allErrors: true }).compile(JSON.parse(await readFile(fileURLToPath(new URL(`../schemas/storyboard.v${version}.json`, import.meta.url)), 'utf8')))));
8
+ const validate = new Ajv({ allErrors: true }).compile(JSON.parse(await readFile(fileURLToPath(new URL('../schemas/storyboard.v1.json', import.meta.url)), 'utf8')));
9
9
  export async function loadStoryboard(file) {
10
10
  let data;
11
11
  try {
@@ -14,14 +14,11 @@ export async function loadStoryboard(file) {
14
14
  catch (error) {
15
15
  throw new ProductionError('STORYBOARD', `Cannot read storyboard: ${String(error)}`);
16
16
  }
17
- const version = data && typeof data === 'object' && 'version' in data ? data.version : undefined;
18
- requireCondition(version === 1 || version === 2, 'SCHEMA', 'Storyboard version must be 1 or 2');
19
- const validate = validators[version - 1];
20
17
  requireCondition(validate(data), 'SCHEMA', JSON.stringify(validate.errors));
21
18
  data.deck = resolve(dirname(file), data.deck);
22
19
  data.media = data.media.map(media => ({ ...media, src: resolve(dirname(file), media.src) }));
23
20
  const ids = new Set();
24
- for (const item of [...data.scenes, ...data.narration, ...data.media, ...data.cues, ...(data.annotations ?? []), ...(data.overlays ?? []), ...data.scenes.flatMap(s => s.actions)]) {
21
+ for (const item of [...data.scenes, ...data.narration, ...data.media, ...data.cues, ...data.annotations, ...(data.overlays ?? []), ...data.scenes.flatMap(s => s.actions)]) {
25
22
  requireCondition(!ids.has(item.id), 'DUPLICATE_ID', `Duplicate stable ID ${item.id}`);
26
23
  ids.add(item.id);
27
24
  }
@@ -43,7 +40,7 @@ export async function loadStoryboard(file) {
43
40
  if (cue.action.type === 'play')
44
41
  requireCondition(mediaIds.has(cue.action.media), 'MEDIA_REFERENCE', `Unknown media ${cue.action.media}`);
45
42
  }
46
- for (const annotation of data.annotations ?? []) {
43
+ for (const annotation of data.annotations) {
47
44
  const context = { annotation: annotation.id, target: annotation.target };
48
45
  requireCondition(data.scenes.some(scene => scene.id === annotation.scene), 'ANNOTATION_SCENE', `Annotation ${annotation.id}: unknown scene ${annotation.scene}`, 2, context);
49
46
  requireCondition(segments.has(annotation.at.segment), 'CUE_REFERENCE', `Annotation ${annotation.id}: unknown narration ${annotation.at.segment}`, 2, context);
package/dist/timing.js CHANGED
@@ -117,7 +117,7 @@ async function resolveSchedule(story, speech) {
117
117
  requireCondition(other.start_ms >= item.end_ms, 'MEDIA_NAVIGATION', `Slide ${other.id} interrupts media ${item.id}`);
118
118
  }
119
119
  }
120
- const annotations = (story.annotations ?? []).map(annotation => {
120
+ const annotations = story.annotations.map(annotation => {
121
121
  const { time, segment, context, cue_span } = phrase(annotation, annotation.target);
122
122
  const end = time + annotation.duration_ms;
123
123
  const range = sceneRanges.get(annotation.scene);
@@ -155,7 +155,7 @@ async function resolveSchedule(story, speech) {
155
155
  return { id, src, box, opacity, visible, hidden };
156
156
  });
157
157
  return {
158
- version: story.version, ...(story.version === 2 ? { annotations } : {}),
158
+ version: 1, annotations,
159
159
  duration_ms: cursor, actions, media: media.map(({ id, src, duration_ms, has_audio }) => ({ id, src, duration_ms, has_audio })),
160
160
  ...(overlays.length ? { overlays } : {}),
161
161
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidevideo/cli",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Turn a slide deck into a narrated video.",
5
5
  "license": "SEE LICENSE IN LICENSE-TERMS.md",
6
6
  "type": "module",
@@ -112,10 +112,8 @@
112
112
  "schemas/revoked-keys.schema.json",
113
113
  "schemas/run-manifest.v1.json",
114
114
  "schemas/schedule.v1.json",
115
- "schemas/schedule.v2.json",
116
115
  "schemas/speech.v1.json",
117
116
  "schemas/storyboard.v1.json",
118
- "schemas/storyboard.v2.json",
119
117
  "schemas/timing-evidence.v1.json",
120
118
  "skills/slidevideo/SKILL.md",
121
119
  "skills/slidevideo/references/production.md",