@slidevideo/cli 0.3.1 → 0.3.2
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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/adapters/edge.d.ts +1 -0
- package/dist/adapters/edge.js +4 -3
- package/dist/adapters/elevenlabs.d.ts +1 -0
- package/dist/adapters/elevenlabs.js +4 -3
- package/dist/assembly.js +143 -37
- package/dist/cli.js +20 -3
- package/dist/compositor.d.ts +17 -2
- package/dist/compositor.js +57 -23
- package/dist/contracts.d.ts +1 -0
- package/dist/media.js +24 -1
- package/dist/pipeline.js +3 -2
- package/dist/preview/contracts.d.ts +1 -0
- package/dist/preview/player.js +4 -1
- package/dist/preview/server.d.ts +1 -1
- package/dist/preview/server.js +3 -3
- package/dist/speech.d.ts +3 -2
- package/dist/speech.js +147 -44
- package/dist/timing.d.ts +3 -2
- package/dist/timing.js +46 -4
- package/dist/update-check-worker.js +43 -11
- package/dist/update-check.js +14 -10
- package/package.json +1 -1
- package/skills/slidevideo/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.3.2
|
|
6
|
+
|
|
7
|
+
- Render the free-tier `slidevideo.io` export watermark in bundled Plus Jakarta Sans with adaptive dark-or-light ink based on corner brightness so it stays crisp and transparent on bright and dark slides alike.
|
|
8
|
+
- Check `slidevideo.io/release.json` (with an npm registry fallback) during the 24-hour background update check and honor `DO_NOT_TRACK=1` alongside `SLIDEVIDEO_NO_UPDATE_CHECK=1`.
|
|
9
|
+
- Replace per-segment FFmpeg `adelay`/`amix` narration fan-out in assembly with sequential PCM audio placement so open inputs and memory stay bounded on long storyboards.
|
|
10
|
+
- Bound concurrent TTS synthesis requests per provider, stream-count PCM bytes in `audioDuration` without retaining audio buffers, and skip redundant speech decode passes within a single run.
|
|
11
|
+
- Estimate approximate character-proportional phrase-cue and `follow` timing in `slidevideo play` for uncached segments while clearly labeling approximate cues in CLI, `--json`, and browser status output.
|
|
12
|
+
|
|
5
13
|
## 0.3.1
|
|
6
14
|
|
|
7
15
|
- Export speech-aligned `final.vtt` and `final.srt` captions by default on narrated `build` and `assemble` runs, with `--captions <vtt|srt|both|none>` to configure or export during `resolve`.
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ A completed build writes `final.mp4` (plus `final.vtt` and `final.srt` captions
|
|
|
20
20
|
|
|
21
21
|
To draft or edit a storyboard with a coding agent, run `slidevideo skill --install` to link the bundled skill into `~/.agents/skills/slidevideo` and `~/.claude/skills/slidevideo` when Claude Code is detected, or ask the agent to run `slidevideo skill`. For non-interactive setup, run `slidevideo setup --install --json` and see `slidevideo setup --help` and `slidevideo skill --help` for provider and project flags. Use `slidevideo inspect --deck <file> --json` to list slide names, click counts, media IDs, and highlight targets before creating `slidevideo.yaml`. The CLI includes the skill and its storyboard, deck-compatibility, and recording references.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
CLI commands check `https://slidevideo.io/release.json` (falling back to npm) in the background at most once every 24 hours and show cached update notices on later interactive calls. Stable installations use `latest`; existing alpha installations use `alpha`. Notices include an exact-version upgrade command. If you installed with `--prefix`, add the same `--prefix` option to that command so npm updates the copy on your `PATH`. Set `SLIDEVIDEO_NO_UPDATE_CHECK=1` or `DO_NOT_TRACK=1` to disable checks and notices. CI, `--version`, `--help`, `setup --manual`, read-only `skill` views, `license`, and `impressum` skip both, and `--json` and `--quiet` suppress notices.
|
|
24
24
|
|
|
25
25
|
See the [user manual](https://slidevideo.io/guide.html) for host prerequisites and a first build, and the [changelog](CHANGELOG.md) for release notes. Run `slidevideo --help` for the installed command reference.
|
|
26
26
|
|
package/dist/adapters/edge.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Narration, SpeechAsset, TtsAdapter, Voice } from '../contracts.js'
|
|
|
2
2
|
export declare class EdgeAdapter implements TtsAdapter {
|
|
3
3
|
id: string;
|
|
4
4
|
version: string;
|
|
5
|
+
concurrency: number;
|
|
5
6
|
validate(voice: Voice): void;
|
|
6
7
|
synthesize(segment: Narration, voice: Voice, destination: string): Promise<Omit<SpeechAsset, 'key'>>;
|
|
7
8
|
}
|
package/dist/adapters/edge.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { rm } from 'node:fs/promises';
|
|
2
|
-
import { execute, saveJson, probe,
|
|
2
|
+
import { execute, saveJson, probe, hashFile, audioDuration } from '../media.js';
|
|
3
3
|
import { ProductionError, requireCondition } from '../errors.js';
|
|
4
4
|
import { packagePath } from '../installation.js';
|
|
5
5
|
import { executable } from '../executables.js';
|
|
6
6
|
export class EdgeAdapter {
|
|
7
7
|
id = 'edge-tts';
|
|
8
8
|
version = '7.3.1-adapter-1';
|
|
9
|
+
concurrency = 3;
|
|
9
10
|
validate(voice) {
|
|
10
11
|
for (const [key, value] of Object.entries(voice.options ?? {})) {
|
|
11
12
|
requireCondition(['rate', 'volume', 'pitch'].includes(key), 'VOICE_OPTION', `Edge TTS does not support option ${key}`, 3);
|
|
@@ -33,11 +34,11 @@ export class EdgeAdapter {
|
|
|
33
34
|
cursor = start + word.text.length;
|
|
34
35
|
return { ...word, start, end: cursor };
|
|
35
36
|
});
|
|
36
|
-
await decode(destination);
|
|
37
37
|
const properties = await probe(destination);
|
|
38
38
|
requireCondition(properties.has_audio && properties.duration_ms > 0, 'TTS_AUDIO', `Edge returned invalid audio for ${segment.id}`, 4);
|
|
39
|
+
const duration_ms = await audioDuration(destination);
|
|
39
40
|
return {
|
|
40
|
-
id: segment.id, audio: destination, sha256: await hashFile(destination), format: 'mp3', duration_ms
|
|
41
|
+
id: segment.id, audio: destination, sha256: await hashFile(destination), format: 'mp3', duration_ms,
|
|
41
42
|
transcript: { original: segment.text, normalized: segment.text },
|
|
42
43
|
alignment: { form: 'original', granularity: 'word', text: segment.text, units },
|
|
43
44
|
provenance: { adapter: this.id, version: this.version, provider: this.id, voice: voice.voice, options: voice.options ?? {}, generated_at: new Date().toISOString() },
|
|
@@ -3,6 +3,7 @@ export declare function elevenLabsApiKey(environment?: NodeJS.ProcessEnv): strin
|
|
|
3
3
|
export declare class ElevenLabsAdapter implements TtsAdapter {
|
|
4
4
|
id: string;
|
|
5
5
|
version: string;
|
|
6
|
+
concurrency: number;
|
|
6
7
|
validate(voice: Voice): void;
|
|
7
8
|
synthesize(segment: Narration, voice: Voice, destination: string): Promise<Omit<SpeechAsset, 'key'>>;
|
|
8
9
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises';
|
|
2
2
|
import { configuredElevenLabsKey } from '../executables.js';
|
|
3
3
|
import { requireCondition, ProductionError } from '../errors.js';
|
|
4
|
-
import {
|
|
4
|
+
import { hashFile, probe, executionSignal, audioDuration } from '../media.js';
|
|
5
5
|
export function elevenLabsApiKey(environment = process.env) {
|
|
6
6
|
return environment.ELEVENLABS_API_KEY ?? environment.ELEVENLABS_KEY ?? configuredElevenLabsKey();
|
|
7
7
|
}
|
|
8
8
|
export class ElevenLabsAdapter {
|
|
9
9
|
id = 'elevenlabs';
|
|
10
10
|
version = '1';
|
|
11
|
+
concurrency = 2;
|
|
11
12
|
validate(voice) {
|
|
12
13
|
const options = voice.options ?? {};
|
|
13
14
|
for (const key of Object.keys(options))
|
|
@@ -50,11 +51,11 @@ export class ElevenLabsAdapter {
|
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
await writeFile(destination, Buffer.from(data.audio_base64, 'base64'));
|
|
53
|
-
await decode(destination);
|
|
54
54
|
const properties = await probe(destination);
|
|
55
55
|
requireCondition(properties.has_audio && properties.duration_ms > 0, 'TTS_AUDIO', `Invalid generated speech ${segment.id}`, 4);
|
|
56
|
+
const duration_ms = await audioDuration(destination);
|
|
56
57
|
return {
|
|
57
|
-
id: segment.id, audio: destination, sha256: await hashFile(destination), format: 'mp3', duration_ms
|
|
58
|
+
id: segment.id, audio: destination, sha256: await hashFile(destination), format: 'mp3', duration_ms,
|
|
58
59
|
transcript: { original: segment.text, normalized: data.normalized_alignment?.characters.join('') ?? segment.text }, alignment,
|
|
59
60
|
provenance: { adapter: this.id, version: this.version, provider: this.id, voice: voice.voice, options, generated_at: new Date().toISOString() },
|
|
60
61
|
};
|
package/dist/assembly.js
CHANGED
|
@@ -1,10 +1,107 @@
|
|
|
1
1
|
import { join, dirname } from 'node:path';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { createWriteStream } from 'node:fs';
|
|
2
4
|
import { lstat, mkdir, mkdtemp, link, rm, copyFile, writeFile } from 'node:fs/promises';
|
|
3
5
|
import { defaultVideoOutput } from './contracts.js';
|
|
4
|
-
import { execute, ffmpegFilterScriptFlags, hashFile, probe, decode, saveJson } from './media.js';
|
|
5
|
-
import { requireCondition } from './errors.js';
|
|
6
|
-
import { configuredLicense } from './executables.js';
|
|
6
|
+
import { execute, executionScope, executionSignal, ffmpegFilterScriptFlags, hashFile, probe, decode, saveJson } from './media.js';
|
|
7
|
+
import { ProductionError, requireCondition } from './errors.js';
|
|
8
|
+
import { configuredLicense, executable } from './executables.js';
|
|
7
9
|
import { annotationApplications, verifyAnnotations } from './annotations.js';
|
|
10
|
+
const NARRATION_SAMPLE_RATE = 48000;
|
|
11
|
+
const NARRATION_CHANNELS = 2;
|
|
12
|
+
const NARRATION_BYTES_PER_SAMPLE = 4 * NARRATION_CHANNELS; // f32le stereo
|
|
13
|
+
const ZERO_CHUNK = Buffer.alloc(65536);
|
|
14
|
+
async function writeChunk(stream, chunk) {
|
|
15
|
+
executionSignal()?.throwIfAborted();
|
|
16
|
+
if (stream.write(chunk))
|
|
17
|
+
return;
|
|
18
|
+
await new Promise((resolve, reject) => {
|
|
19
|
+
const onDrain = () => { cleanup(); resolve(); };
|
|
20
|
+
const onError = (error) => { cleanup(); reject(error); };
|
|
21
|
+
const cleanup = () => { stream.off('drain', onDrain); stream.off('error', onError); };
|
|
22
|
+
stream.once('drain', onDrain);
|
|
23
|
+
stream.once('error', onError);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async function appendDecodedNarration(stream, audioPath, maxBytes) {
|
|
27
|
+
const command = executable('ffmpeg');
|
|
28
|
+
const context = executionScope.getStore();
|
|
29
|
+
const signal = context?.signal;
|
|
30
|
+
signal?.throwIfAborted();
|
|
31
|
+
const child = spawn(command, ['-v', 'error', '-xerror', '-i', audioPath, '-vn', '-ac', String(NARRATION_CHANNELS), '-ar', String(NARRATION_SAMPLE_RATE), '-f', 'f32le', '-'], {
|
|
32
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
33
|
+
signal,
|
|
34
|
+
killSignal: 'SIGKILL',
|
|
35
|
+
windowsHide: true,
|
|
36
|
+
});
|
|
37
|
+
const err = [];
|
|
38
|
+
const limit = context?.bounded ? undefined : 120000;
|
|
39
|
+
const timer = limit !== undefined ? setTimeout(() => { child.kill('SIGKILL'); }, limit) : undefined;
|
|
40
|
+
child.stderr.on('data', data => err.push(data));
|
|
41
|
+
const exit = new Promise((resolve, reject) => {
|
|
42
|
+
child.on('error', error => { clearTimeout(timer); reject(new ProductionError('DEPENDENCY', `${command}: ${error.message}`, 3)); });
|
|
43
|
+
child.on('close', code => {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
if (code !== 0)
|
|
46
|
+
reject(new ProductionError('SUBPROCESS', `${command} exited ${code}: ${Buffer.concat(err).toString().slice(-4000)}`, 3));
|
|
47
|
+
else
|
|
48
|
+
resolve();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
let written = 0;
|
|
52
|
+
try {
|
|
53
|
+
for await (const chunk of child.stdout) {
|
|
54
|
+
const remaining = maxBytes - written;
|
|
55
|
+
if (remaining <= 0)
|
|
56
|
+
continue;
|
|
57
|
+
const slice = chunk.length <= remaining ? chunk : chunk.subarray(0, remaining);
|
|
58
|
+
if (slice.length > 0) {
|
|
59
|
+
await writeChunk(stream, slice);
|
|
60
|
+
written += slice.length;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
await exit;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
child.kill('SIGKILL');
|
|
67
|
+
await exit.catch(() => { });
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
return written;
|
|
71
|
+
}
|
|
72
|
+
async function writeNarrationTrack(destination, items, audioOrigin) {
|
|
73
|
+
const stream = createWriteStream(destination);
|
|
74
|
+
let writtenSamples = 0;
|
|
75
|
+
try {
|
|
76
|
+
for (const { item, asset } of items) {
|
|
77
|
+
executionSignal()?.throwIfAborted();
|
|
78
|
+
const targetStartSample = Math.round(((item.start_ms + audioOrigin) * NARRATION_SAMPLE_RATE) / 1000);
|
|
79
|
+
requireCondition(targetStartSample >= writtenSamples, 'ASSEMBLY', `Narration segment ${item.id} overlaps an earlier segment`, 7);
|
|
80
|
+
let gapBytes = (targetStartSample - writtenSamples) * NARRATION_BYTES_PER_SAMPLE;
|
|
81
|
+
while (gapBytes > 0) {
|
|
82
|
+
const size = Math.min(gapBytes, ZERO_CHUNK.length);
|
|
83
|
+
await writeChunk(stream, size === ZERO_CHUNK.length ? ZERO_CHUNK : ZERO_CHUNK.subarray(0, size));
|
|
84
|
+
gapBytes -= size;
|
|
85
|
+
}
|
|
86
|
+
writtenSamples = targetStartSample;
|
|
87
|
+
const maxSamples = Math.round((asset.duration_ms * NARRATION_SAMPLE_RATE) / 1000);
|
|
88
|
+
const writtenBytes = await appendDecodedNarration(stream, asset.audio, maxSamples * NARRATION_BYTES_PER_SAMPLE);
|
|
89
|
+
const remainder = writtenBytes % NARRATION_BYTES_PER_SAMPLE;
|
|
90
|
+
if (remainder !== 0) {
|
|
91
|
+
await writeChunk(stream, ZERO_CHUNK.subarray(0, NARRATION_BYTES_PER_SAMPLE - remainder));
|
|
92
|
+
}
|
|
93
|
+
writtenSamples += Math.ceil(writtenBytes / NARRATION_BYTES_PER_SAMPLE);
|
|
94
|
+
}
|
|
95
|
+
await new Promise((resolve, reject) => {
|
|
96
|
+
stream.once('error', reject);
|
|
97
|
+
stream.end(() => resolve());
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
stream.destroy();
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
8
105
|
export async function assemble(schedule, speech, visual, directory, output, options = { verify_timing: false, output: defaultVideoOutput }) {
|
|
9
106
|
const video = options.output;
|
|
10
107
|
const licensed = options.licensed ?? configuredLicense();
|
|
@@ -52,7 +149,7 @@ export async function assemble(schedule, speech, visual, directory, output, opti
|
|
|
52
149
|
const frameCount = Math.ceil(duration * video.fps - 1e-9);
|
|
53
150
|
const annotations = annotationApplications(video, schedule, visual, audioOrigin);
|
|
54
151
|
const renderer = annotations.length || schedule.overlays?.length || !licensed ? await import('./compositor.js') : undefined;
|
|
55
|
-
const layers = await renderer?.frameLayers(video, schedule,
|
|
152
|
+
const layers = await renderer?.frameLayers(video, schedule, options.inputHashes) ?? [];
|
|
56
153
|
const { canvasLayers, staticTopLayers } = renderer ? renderer.splitFrameLayers(layers) : { canvasLayers: [], staticTopLayers: [] };
|
|
57
154
|
const plan = renderer ? renderer.planCompositor(frameCount, video.fps, audioOrigin, annotations, canvasLayers) : { kind: 'none' };
|
|
58
155
|
let layerImage;
|
|
@@ -60,62 +157,69 @@ export async function assemble(schedule, speech, visual, directory, output, opti
|
|
|
60
157
|
layerImage = join(temporaryDirectory, 'overlays.png');
|
|
61
158
|
await renderer.writeStaticFrameLayers(layerImage, video, staticTopLayers);
|
|
62
159
|
}
|
|
160
|
+
let watermarkImage;
|
|
161
|
+
let watermarkRect;
|
|
162
|
+
if (!licensed) {
|
|
163
|
+
watermarkImage = join(temporaryDirectory, 'watermark.png');
|
|
164
|
+
watermarkRect = await renderer.writeWatermarkMask(watermarkImage, video);
|
|
165
|
+
}
|
|
166
|
+
const hasPostLayers = Boolean(layerImage || watermarkImage);
|
|
167
|
+
const stageOut = hasPostLayers ? 'stage_v' : 'v';
|
|
63
168
|
let input = 1;
|
|
64
169
|
switch (plan.kind) {
|
|
65
170
|
case 'none':
|
|
66
171
|
args.push('-i', visual.file);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
filters.push(`[0:v]${baseFilter}[base]`, '[base][1:v]overlay=eof_action=repeat,format=yuv420p[v]');
|
|
70
|
-
input = 2;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
filters.push(`[0:v]${baseFilter}[v]`);
|
|
74
|
-
input = 1;
|
|
75
|
-
}
|
|
172
|
+
filters.push(`[0:v]${baseFilter}[${stageOut}]`);
|
|
173
|
+
input = 1;
|
|
76
174
|
break;
|
|
77
175
|
case 'sparse':
|
|
78
176
|
args.push('-i', visual.file);
|
|
79
177
|
args.push('-f', 'rawvideo', '-pixel_format', 'rgba', '-video_size', `${video.width}x${video.height}`, '-framerate', String(video.fps), '-i', 'pipe:0');
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
filters.push(`[0:v]${baseFilter}[base]`, `[1:v]setpts='${plan.ptsExpr}'[comp_in]`, `[base][comp_in]overlay=eof_action=pass:format=rgb:enable='${plan.betweenExpr}'[comp]`, '[comp][2:v]overlay=eof_action=repeat,format=yuv420p[v]');
|
|
83
|
-
input = 3;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
filters.push(`[0:v]${baseFilter}[base]`, `[1:v]setpts='${plan.ptsExpr}'[comp_in]`, `[base][comp_in]overlay=eof_action=pass:format=rgb:enable='${plan.betweenExpr}',format=yuv420p[v]`);
|
|
87
|
-
input = 2;
|
|
88
|
-
}
|
|
178
|
+
filters.push(`[0:v]${baseFilter}[base]`, `[1:v]setpts='${plan.ptsExpr}'[comp_in]`, `[base][comp_in]overlay=eof_action=pass:format=rgb:enable='${plan.betweenExpr}',format=yuv420p[${stageOut}]`);
|
|
179
|
+
input = 2;
|
|
89
180
|
break;
|
|
90
181
|
case 'full':
|
|
91
182
|
args.push('-f', 'rawvideo', '-pixel_format', 'rgba', '-video_size', `${video.width}x${video.height}`, '-framerate', String(video.fps), '-i', 'pipe:0');
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
filters.push('[0:v]format=yuv420p[base]', '[base][1:v]overlay=eof_action=repeat,format=yuv420p[v]');
|
|
95
|
-
input = 2;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
filters.push('[0:v]format=yuv420p[v]');
|
|
99
|
-
input = 1;
|
|
100
|
-
}
|
|
183
|
+
filters.push(`[0:v]format=yuv420p[${stageOut}]`);
|
|
184
|
+
input = 1;
|
|
101
185
|
break;
|
|
102
186
|
default: {
|
|
103
187
|
const _exhaustive = plan;
|
|
104
188
|
throw new Error(`Unhandled compositor plan: ${String(_exhaustive)}`);
|
|
105
189
|
}
|
|
106
190
|
}
|
|
191
|
+
let currentStream = stageOut;
|
|
192
|
+
if (layerImage) {
|
|
193
|
+
args.push('-i', layerImage);
|
|
194
|
+
const nextStream = watermarkImage ? 'topped_v' : 'v';
|
|
195
|
+
filters.push(`[${currentStream}][${input}:v]overlay=eof_action=repeat,format=yuv420p[${nextStream}]`);
|
|
196
|
+
currentStream = nextStream;
|
|
197
|
+
input++;
|
|
198
|
+
}
|
|
199
|
+
if (watermarkImage && watermarkRect) {
|
|
200
|
+
args.push('-i', watermarkImage);
|
|
201
|
+
filters.push(...renderer.watermarkFilters(currentStream, input, 'v', watermarkRect));
|
|
202
|
+
input++;
|
|
203
|
+
}
|
|
107
204
|
if (annotations.length)
|
|
108
205
|
await saveJson(join(directory, 'annotations-applied.json'), { version: 1, annotations });
|
|
206
|
+
const narrationItems = [];
|
|
109
207
|
for (const item of schedule.actions) {
|
|
110
208
|
if (item.action.type === 'speak') {
|
|
111
209
|
const segment = item.action.segment;
|
|
112
210
|
const asset = speech.assets.find(a => a.id === segment);
|
|
113
|
-
|
|
114
|
-
filters.push(`[${input}:a]atrim=duration=${asset.duration_ms / 1000},asetpts=PTS-STARTPTS,adelay=${item.start_ms + audioOrigin}:all=1[a${input}]`);
|
|
115
|
-
tracks.push(`[a${input}]`);
|
|
211
|
+
narrationItems.push({ item, asset });
|
|
116
212
|
transformations.push({ id: item.id, kind: 'narration', start_ms: item.start_ms, duration_ms: asset.duration_ms });
|
|
117
|
-
input++;
|
|
118
213
|
}
|
|
214
|
+
}
|
|
215
|
+
if (narrationItems.length) {
|
|
216
|
+
const narrationPath = join(temporaryDirectory, 'narration.pcm');
|
|
217
|
+
await writeNarrationTrack(narrationPath, narrationItems, audioOrigin);
|
|
218
|
+
args.push('-f', 'f32le', '-ar', String(NARRATION_SAMPLE_RATE), '-ac', String(NARRATION_CHANNELS), '-i', narrationPath);
|
|
219
|
+
tracks.push(`[${input}:a]`);
|
|
220
|
+
input++;
|
|
221
|
+
}
|
|
222
|
+
for (const item of schedule.actions) {
|
|
119
223
|
if (item.action.type === 'play' && item.action.audio === 'source') {
|
|
120
224
|
const action = item.action;
|
|
121
225
|
const media = schedule.media.find(m => m.id === action.media);
|
|
@@ -126,7 +230,9 @@ export async function assemble(schedule, speech, visual, directory, output, opti
|
|
|
126
230
|
input++;
|
|
127
231
|
}
|
|
128
232
|
}
|
|
129
|
-
if (tracks.length)
|
|
233
|
+
if (tracks.length === 1)
|
|
234
|
+
filters.push(`${tracks[0]}apad,atrim=duration=${duration}[a]`);
|
|
235
|
+
else if (tracks.length > 1)
|
|
130
236
|
filters.push(`${tracks.join('')}amix=inputs=${tracks.length}:normalize=0,apad,atrim=duration=${duration}[a]`);
|
|
131
237
|
const filterScript = join(temporaryDirectory, 'filter-complex.txt');
|
|
132
238
|
await writeFile(filterScript, filters.join(';'));
|
|
@@ -152,7 +258,7 @@ export async function assemble(schedule, speech, visual, directory, output, opti
|
|
|
152
258
|
let annotationEvidence;
|
|
153
259
|
if (annotations.length && options.verify_timing) {
|
|
154
260
|
try {
|
|
155
|
-
annotationEvidence = await verifyAnnotations(temporary, visual.file, baseFilter, annotations, video, directory, output, frame => renderer.visibleFrameLayerBounds(layers, frame, video.fps, audioOrigin), outputSha256);
|
|
261
|
+
annotationEvidence = await verifyAnnotations(temporary, visual.file, baseFilter, annotations, video, directory, output, frame => renderer.visibleFrameLayerBounds(layers, frame, video.fps, audioOrigin, watermarkRect), outputSha256);
|
|
156
262
|
}
|
|
157
263
|
catch (error) {
|
|
158
264
|
await copyFile(temporary, join(directory, 'failed-composite.mp4'));
|
package/dist/cli.js
CHANGED
|
@@ -104,7 +104,13 @@ try {
|
|
|
104
104
|
json: { type: 'boolean' }, quiet: { type: 'boolean' }, resume: { type: 'boolean' }, 'no-cache': { type: 'boolean' }, 'verify-timing': { type: 'boolean' }, help: { type: 'boolean', short: 'h' }, version: { type: 'boolean' },
|
|
105
105
|
}, allowPositionals: true });
|
|
106
106
|
command = positionals[0] ?? 'help';
|
|
107
|
-
|
|
107
|
+
const skipUpdateCheck = Boolean(values.version || values.help)
|
|
108
|
+
|| ['help', 'license', 'impressum'].includes(command)
|
|
109
|
+
|| (command === 'setup' && Boolean(values.manual))
|
|
110
|
+
|| (command === 'skill' && !values.install);
|
|
111
|
+
if (!skipUpdateCheck) {
|
|
112
|
+
notifyUpdate(Boolean(values.json), Boolean(values.quiet));
|
|
113
|
+
}
|
|
108
114
|
if (values.version) {
|
|
109
115
|
const { version } = JSON.parse(await readFile(packagePath('package.json'), 'utf8'));
|
|
110
116
|
console.log(values.json ? JSON.stringify({ version: 1, package_version: version }) : version);
|
|
@@ -284,9 +290,20 @@ impressum displays the provider's contact details.
|
|
|
284
290
|
requireCondition(values.run === undefined && values['timeout-minutes'] === undefined, 'OPTION', 'play takes --storyboard, --cache-dir, --no-cache, --port, --width and --height; Ctrl+C stops the server');
|
|
285
291
|
const port = Number(values.port ?? 0);
|
|
286
292
|
requireCondition(values.port === undefined || /^\d+$/.test(values.port) && Number.isInteger(port) && port <= 65535, 'PREVIEW_PORT', '--port must be between 0 and 65535');
|
|
287
|
-
await servePreview(values.storyboard, cache, port, viewport, (url, approximate) => {
|
|
293
|
+
await servePreview(values.storyboard, cache, port, viewport, (url, approximate, approximateCues) => {
|
|
288
294
|
previewReady = true;
|
|
289
|
-
|
|
295
|
+
if (values.json) {
|
|
296
|
+
console.log(JSON.stringify({ version: 1, command, status: 'ready', url, approximate, approximate_cues: approximateCues, timing_status: 'not_evaluated' }));
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
console.log(`Open ${url} to preview the storyboard. Press Ctrl+C to stop.`);
|
|
300
|
+
if (approximate.length) {
|
|
301
|
+
const cueNote = approximateCues.length
|
|
302
|
+
? `; approximate phrase cues (not synthesized alignment): ${approximateCues.join(', ')}. Run tts or build for synthesized alignment.`
|
|
303
|
+
: '.';
|
|
304
|
+
console.log(`Estimated timing (150 words/min, uncached speech): ${approximate.join(', ')}${cueNote}`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
290
307
|
});
|
|
291
308
|
}
|
|
292
309
|
else {
|
package/dist/compositor.d.ts
CHANGED
|
@@ -30,9 +30,24 @@ export type CompositorPlan = {
|
|
|
30
30
|
selectedReadbackFrames: number;
|
|
31
31
|
canvasLayers: FrameLayer[];
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type WatermarkLayout = {
|
|
34
|
+
text: string;
|
|
35
|
+
font: string;
|
|
36
|
+
textX: number;
|
|
37
|
+
textY: number;
|
|
38
|
+
maxTextWidth: number;
|
|
39
|
+
rectangle: Rectangle;
|
|
40
|
+
};
|
|
41
|
+
export declare function frameLayers(output: VideoOutput, schedule: Schedule, hashes?: Record<string, string>): Promise<FrameLayer[]>;
|
|
42
|
+
export declare function watermarkLayout(output: VideoOutput): WatermarkLayout;
|
|
43
|
+
export declare function renderWatermarkCanvas(output: VideoOutput, fillStyle?: string): {
|
|
44
|
+
canvas: Canvas;
|
|
45
|
+
layout: WatermarkLayout;
|
|
46
|
+
};
|
|
47
|
+
export declare function writeWatermarkMask(file: string, output: VideoOutput): Promise<Rectangle>;
|
|
48
|
+
export declare function watermarkFilters(inputStream: string, maskInput: number, outputStream: string, rectangle: Rectangle): string[];
|
|
34
49
|
export declare function writeStaticFrameLayers(file: string, output: VideoOutput, layers: FrameLayer[]): Promise<void>;
|
|
35
|
-
export declare function visibleFrameLayerBounds(layers: FrameLayer[], frame: number, fps: number, audioOrigin: number): Rectangle[];
|
|
50
|
+
export declare function visibleFrameLayerBounds(layers: FrameLayer[], frame: number, fps: number, audioOrigin: number, extraRectangle?: Rectangle): Rectangle[];
|
|
36
51
|
export declare function splitFrameLayers(layers: FrameLayer[]): {
|
|
37
52
|
canvasLayers: FrameLayer[];
|
|
38
53
|
staticTopLayers: FrameLayer[];
|
package/dist/compositor.js
CHANGED
|
@@ -8,7 +8,7 @@ import { executable } from './executables.js';
|
|
|
8
8
|
import { ProductionError, requireCondition } from './errors.js';
|
|
9
9
|
import { loadOverlayImage } from './overlay-assets.js';
|
|
10
10
|
import { ensureStampFonts } from './stamp-fonts.js';
|
|
11
|
-
export async function frameLayers(output, schedule,
|
|
11
|
+
export async function frameLayers(output, schedule, hashes) {
|
|
12
12
|
const layers = [];
|
|
13
13
|
const images = new Map();
|
|
14
14
|
for (const overlay of schedule.overlays ?? []) {
|
|
@@ -37,30 +37,61 @@ export async function frameLayers(output, schedule, licensed, hashes) {
|
|
|
37
37
|
};
|
|
38
38
|
layers.push({ image, rectangle, opacity: overlay.opacity, opacityAt });
|
|
39
39
|
}
|
|
40
|
-
if (!licensed)
|
|
41
|
-
layers.push(watermark(output));
|
|
42
40
|
return layers;
|
|
43
41
|
}
|
|
44
|
-
function
|
|
42
|
+
export function watermarkLayout(output) {
|
|
43
|
+
ensureStampFonts();
|
|
45
44
|
const text = 'slidevideo.io';
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
45
|
+
const fontSize = Math.max(1, Math.round(output.height * 0.0204));
|
|
46
|
+
const font = `700 ${fontSize}px SlideVideoSans`;
|
|
47
|
+
const measure = createCanvas(16, 16).getContext('2d');
|
|
48
|
+
measure.font = font;
|
|
49
|
+
const metrics = measure.measureText(text);
|
|
50
|
+
const ascent = Math.ceil(metrics.actualBoundingBoxAscent || fontSize * 0.78);
|
|
51
|
+
const descent = Math.ceil(metrics.actualBoundingBoxDescent || 0);
|
|
52
|
+
const pad = Math.max(1, Math.min(4, Math.floor(Math.min(output.width, output.height) * 0.05)));
|
|
53
|
+
const marginX = Math.max(1, Math.min(Math.max(1, Math.floor(output.width * 0.1)), Math.round(Math.min(output.width, output.height) * 0.0204)));
|
|
54
|
+
const marginY = Math.max(1, Math.min(Math.max(1, Math.floor(output.height * 0.1)), Math.round(Math.min(output.width, output.height) * 0.0185)));
|
|
55
|
+
const maxWidth = Math.max(1, output.width - marginX);
|
|
56
|
+
const maxHeight = Math.max(1, output.height - marginY);
|
|
57
|
+
const rawWidth = Math.min(Math.ceil(metrics.width) + pad * 2, maxWidth);
|
|
58
|
+
const rawHeight = Math.min(ascent + descent + pad * 2, maxHeight);
|
|
59
|
+
const width = rawWidth % 2 === 1 && rawWidth + 1 <= maxWidth ? rawWidth + 1 : rawWidth;
|
|
60
|
+
const height = rawHeight % 2 === 1 && rawHeight + 1 <= maxHeight ? rawHeight + 1 : rawHeight;
|
|
61
|
+
const rawX = Math.max(0, Math.min(output.width - width, output.width - marginX - width + pad));
|
|
62
|
+
const rawY = Math.max(0, Math.min(output.height - height, output.height - marginY - height + pad + descent));
|
|
63
|
+
const x = rawX % 2 === 1 && rawX > 0 ? rawX - 1 : rawX;
|
|
64
|
+
const y = rawY % 2 === 1 && rawY > 0 ? rawY - 1 : rawY;
|
|
65
|
+
const textX = Math.max(1, width - pad);
|
|
66
|
+
const textY = Math.max(1, height - pad - descent);
|
|
67
|
+
const maxTextWidth = Math.max(1, width - Math.min(pad * 2, width - 1));
|
|
68
|
+
return { text, font, textX, textY, maxTextWidth, rectangle: { x, y, width, height } };
|
|
69
|
+
}
|
|
70
|
+
export function renderWatermarkCanvas(output, fillStyle = 'rgba(255, 255, 255, 0.38)') {
|
|
71
|
+
const layout = watermarkLayout(output);
|
|
72
|
+
const canvas = createCanvas(layout.rectangle.width, layout.rectangle.height);
|
|
73
|
+
const context = canvas.getContext('2d');
|
|
74
|
+
context.font = layout.font;
|
|
53
75
|
context.textAlign = 'right';
|
|
54
|
-
context.textBaseline = '
|
|
55
|
-
context.
|
|
56
|
-
context.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
context.textBaseline = 'alphabetic';
|
|
77
|
+
context.fillStyle = fillStyle;
|
|
78
|
+
context.fillText(layout.text, layout.textX, layout.textY, layout.maxTextWidth);
|
|
79
|
+
return { canvas, layout };
|
|
80
|
+
}
|
|
81
|
+
export async function writeWatermarkMask(file, output) {
|
|
82
|
+
const { canvas, layout } = renderWatermarkCanvas(output);
|
|
83
|
+
await writeFile(file, canvas.toBuffer('image/png'));
|
|
84
|
+
return layout.rectangle;
|
|
85
|
+
}
|
|
86
|
+
export function watermarkFilters(inputStream, maskInput, outputStream, rectangle) {
|
|
87
|
+
const { x, y, width, height } = rectangle;
|
|
88
|
+
return [
|
|
89
|
+
`[${inputStream}]split[wm_bg][wm_probe]`,
|
|
90
|
+
`[wm_probe]crop=${width}:${height}:${x}:${y},format=gray,scale=1:1:flags=area,format=rgb24,lutrgb=r='if(gte(val,116),20,236)':g='if(gte(val,116),28,242)':b='if(gte(val,116),36,248)',scale=${width}:${height}:flags=neighbor[wm_ink]`,
|
|
91
|
+
`[${maskInput}:v]alphaextract[wm_alpha]`,
|
|
92
|
+
'[wm_ink][wm_alpha]alphamerge[wm_patch]',
|
|
93
|
+
`[wm_bg][wm_patch]overlay=x=${x}:y=${y}:eof_action=repeat,format=yuv420p[${outputStream}]`,
|
|
94
|
+
];
|
|
64
95
|
}
|
|
65
96
|
function paintFrameLayers(context, layers, time) {
|
|
66
97
|
for (const layer of layers) {
|
|
@@ -78,9 +109,12 @@ export async function writeStaticFrameLayers(file, output, layers) {
|
|
|
78
109
|
paintFrameLayers(canvas.getContext('2d'), layers, 0);
|
|
79
110
|
await writeFile(file, canvas.toBuffer('image/png'));
|
|
80
111
|
}
|
|
81
|
-
export function visibleFrameLayerBounds(layers, frame, fps, audioOrigin) {
|
|
112
|
+
export function visibleFrameLayerBounds(layers, frame, fps, audioOrigin, extraRectangle) {
|
|
82
113
|
const time = Math.max(0, frame * 1000 / fps - audioOrigin);
|
|
83
|
-
|
|
114
|
+
const bounds = layers.filter(layer => (layer.opacityAt?.(time) ?? layer.opacity) > 0).map(layer => layer.rectangle);
|
|
115
|
+
if (extraRectangle)
|
|
116
|
+
bounds.push(extraRectangle);
|
|
117
|
+
return bounds;
|
|
84
118
|
}
|
|
85
119
|
function completion(child, operation) {
|
|
86
120
|
let diagnostic = '';
|
package/dist/contracts.d.ts
CHANGED
|
@@ -585,6 +585,7 @@ export type VisualArtifact = {
|
|
|
585
585
|
export interface TtsAdapter {
|
|
586
586
|
id: string;
|
|
587
587
|
version: string;
|
|
588
|
+
readonly concurrency?: number;
|
|
588
589
|
validate(voice: Voice): void;
|
|
589
590
|
synthesize(segment: Narration, voice: Voice, destination: string): Promise<Omit<SpeechAsset, 'key'>>;
|
|
590
591
|
}
|
package/dist/media.js
CHANGED
|
@@ -92,7 +92,30 @@ export function ffmpegFilterScriptFlags(ffmpegPath = executable('ffmpeg')) {
|
|
|
92
92
|
}
|
|
93
93
|
return cached;
|
|
94
94
|
}
|
|
95
|
-
export async function audioDuration(path) {
|
|
95
|
+
export async function audioDuration(path) {
|
|
96
|
+
const command = executable('ffmpeg');
|
|
97
|
+
const args = ['-v', 'error', '-xerror', '-i', path, '-vn', '-ac', '1', '-ar', '48000', '-f', 's16le', '-'];
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
const context = executionScope.getStore();
|
|
100
|
+
const signal = context?.signal;
|
|
101
|
+
signal?.throwIfAborted();
|
|
102
|
+
const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'], signal, killSignal: 'SIGKILL', windowsHide: true });
|
|
103
|
+
let bytes = 0;
|
|
104
|
+
const err = [];
|
|
105
|
+
const limit = context?.bounded ? undefined : 120000;
|
|
106
|
+
const timer = limit !== undefined ? setTimeout(() => { child.kill('SIGKILL'); }, limit) : undefined;
|
|
107
|
+
child.stdout.on('data', (data) => { bytes += data.length; });
|
|
108
|
+
child.stderr.on('data', (data) => err.push(data));
|
|
109
|
+
child.on('error', error => { clearTimeout(timer); reject(new ProductionError('DEPENDENCY', `${command}: ${error.message}`, 3)); });
|
|
110
|
+
child.on('close', code => {
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
if (code !== 0)
|
|
113
|
+
reject(new ProductionError('SUBPROCESS', `${command} exited ${code}: ${Buffer.concat(err).toString().slice(-4000)}`, 3));
|
|
114
|
+
else
|
|
115
|
+
resolve(bytes / 96);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
96
119
|
export async function videoFramePeriod(path) {
|
|
97
120
|
const data = JSON.parse((await execute('ffprobe', ['-v', 'error', '-select_streams', 'v:0', '-show_frames', '-show_entries', 'frame=best_effort_timestamp_time,duration_time', '-of', 'json', path])).toString());
|
|
98
121
|
const frames = data.frames;
|
package/dist/pipeline.js
CHANGED
|
@@ -213,8 +213,9 @@ export async function produce(options) {
|
|
|
213
213
|
const visualPath = join(directory, 'recording/visual.json');
|
|
214
214
|
const reportPath = join(directory, 'assembly/report.json');
|
|
215
215
|
const resolveViewport = ['build', 'record', 'assemble'].includes(options.command) ? video : undefined;
|
|
216
|
+
const verifiedSpeech = new Map();
|
|
216
217
|
const resolveSchedule = async () => {
|
|
217
|
-
const schedule = await resolveTiming(story, await json(speechPath));
|
|
218
|
+
const schedule = await resolveTiming(story, await json(speechPath), verifiedSpeech);
|
|
218
219
|
await adapter.validate(story, inspection, { ...(resolveViewport ? { viewport: resolveViewport } : {}), schedule });
|
|
219
220
|
return schedule;
|
|
220
221
|
};
|
|
@@ -290,7 +291,7 @@ export async function produce(options) {
|
|
|
290
291
|
const prehashed = {};
|
|
291
292
|
const operation = async () => {
|
|
292
293
|
if (stage === 'tts') {
|
|
293
|
-
const speech = await generateSpeech(story, join(directory, 'speech'), ttsAdapters, resolveSpeechCache(source, options.cache), options.progress);
|
|
294
|
+
const speech = await generateSpeech(story, join(directory, 'speech'), ttsAdapters, resolveSpeechCache(source, options.cache), options.progress, verifiedSpeech);
|
|
294
295
|
artifacts.push(speechPath, ...speech.assets.map(asset => asset.audio));
|
|
295
296
|
}
|
|
296
297
|
if (stage === 'resolve') {
|
package/dist/preview/player.js
CHANGED
|
@@ -566,7 +566,10 @@ try {
|
|
|
566
566
|
timeline.setAttribute('aria-valuemax', String(Math.round(durationMs)));
|
|
567
567
|
if (config.approximate.length) {
|
|
568
568
|
const pacing = document.getElementById('pacing');
|
|
569
|
-
|
|
569
|
+
const cues = config.approximate_cues ?? [];
|
|
570
|
+
pacing.textContent = cues.length
|
|
571
|
+
? `Estimated preview timing (150 words/min, uncached): ${config.approximate.join(', ')} · Approximate phrase cues (not synthesized alignment): ${cues.join(', ')}`
|
|
572
|
+
: `Estimated narration timing (150 words/min): ${config.approximate.join(', ')}`;
|
|
570
573
|
pacing.hidden = false;
|
|
571
574
|
}
|
|
572
575
|
audioSync = createAudioSync(config.audio ?? []);
|
package/dist/preview/server.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Viewport } from '../contracts.js';
|
|
2
|
-
export declare function servePreview(storyboard: string, cache: string | false | undefined, port: number, viewport: Viewport | undefined, ready: (url: string, approximate: string[]) => void): Promise<void>;
|
|
2
|
+
export declare function servePreview(storyboard: string, cache: string | false | undefined, port: number, viewport: Viewport | undefined, ready: (url: string, approximate: string[], approximateCues: string[]) => void): Promise<void>;
|
package/dist/preview/server.js
CHANGED
|
@@ -163,7 +163,7 @@ export async function servePreview(storyboard, cache, port, viewport = defaultVi
|
|
|
163
163
|
requireCondition(adapter.startPreview, 'PREVIEW_CAPABILITY', `Adapter ${adapter.id} does not support preview`, 3);
|
|
164
164
|
const inspection = await adapter.inspect(story.deck);
|
|
165
165
|
await adapter.validate(story, inspection, { viewport });
|
|
166
|
-
const { schedule, approximate, audio: verifiedAudio } = await resolvePreviewTiming(story, ttsAdapters, resolveSpeechCache(source, cache));
|
|
166
|
+
const { schedule, approximate, approximateCues, audio: verifiedAudio } = await resolvePreviewTiming(story, ttsAdapters, resolveSpeechCache(source, cache));
|
|
167
167
|
audioFiles = verifiedAudio;
|
|
168
168
|
await adapter.validate(story, inspection, { viewport, schedule });
|
|
169
169
|
controller.signal.throwIfAborted();
|
|
@@ -201,9 +201,9 @@ export async function servePreview(storyboard, cache, port, viewport = defaultVi
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
config = { deck: basename(story.deck), width: viewport.width, height: viewport.height,
|
|
204
|
-
duration: schedule.duration_ms, approximate, scenes, audio,
|
|
204
|
+
duration: schedule.duration_ms, approximate, approximate_cues: approximateCues, scenes, audio,
|
|
205
205
|
stage: 'url' in session ? { url: session.url } : { annotations: schedule.annotations } };
|
|
206
|
-
ready(origin, approximate);
|
|
206
|
+
ready(origin, approximate, approximateCues);
|
|
207
207
|
await new Promise(resolve => controller.signal.addEventListener('abort', () => resolve(), { once: true }));
|
|
208
208
|
});
|
|
209
209
|
}
|
package/dist/speech.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ export type RetainedSpeech = {
|
|
|
11
11
|
audio?: VerifiedSpeechAudio;
|
|
12
12
|
};
|
|
13
13
|
export declare function retainedSpeechTiming(segment: Narration, voice: Voice, adapter: TtsAdapter, cache?: string): Promise<RetainedSpeech | undefined>;
|
|
14
|
-
export
|
|
15
|
-
export declare function
|
|
14
|
+
export type VerifiedSpeech = Map<string, number>;
|
|
15
|
+
export declare function checkSpeech(asset: SpeechAsset, verified?: VerifiedSpeech): Promise<void>;
|
|
16
|
+
export declare function generateSpeech(story: Storyboard, directory: string, adapters: Map<string, TtsAdapter>, cache?: string, progress?: ProgressReporter, verified?: VerifiedSpeech): Promise<SpeechManifest>;
|
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,
|
|
4
|
+
import { digest, json, saveJson, probe, hashFile, executionScope, 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);
|
|
@@ -72,7 +72,7 @@ export async function retainedSpeechTiming(segment, voice, adapter, cache) {
|
|
|
72
72
|
}
|
|
73
73
|
return { timing: { id: segment.id, duration_ms: asset.duration_ms, transcript: asset.transcript, alignment: asset.alignment }, ...(audio ? { audio } : {}) };
|
|
74
74
|
}
|
|
75
|
-
export async function checkSpeech(asset) {
|
|
75
|
+
export async function checkSpeech(asset, verified) {
|
|
76
76
|
requireCondition(/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(asset.format), 'SPEECH_FORMAT', `Invalid speech file format for ${asset.id}`);
|
|
77
77
|
let hash;
|
|
78
78
|
try {
|
|
@@ -82,63 +82,166 @@ export async function checkSpeech(asset) {
|
|
|
82
82
|
throw new ProductionError('SPEECH_INPUT', `Cannot read speech audio for ${asset.id}: ${asset.audio}`);
|
|
83
83
|
}
|
|
84
84
|
requireCondition(hash === asset.sha256, 'SPEECH_INTEGRITY', `Speech asset changed: ${asset.id}`);
|
|
85
|
-
const
|
|
86
|
-
|
|
85
|
+
const knownDuration = verified?.get(hash);
|
|
86
|
+
if (knownDuration !== undefined) {
|
|
87
|
+
requireCondition(Math.abs(knownDuration - asset.duration_ms) < 1, 'SPEECH_DURATION', `Speech duration mismatch: ${asset.id}`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const properties = await probe(asset.audio);
|
|
91
|
+
const durationMs = await audioDuration(asset.audio);
|
|
92
|
+
requireCondition(properties.has_audio && properties.duration_ms > 0 && Math.abs(durationMs - asset.duration_ms) < 1, 'SPEECH_DURATION', `Speech duration mismatch: ${asset.id}`);
|
|
93
|
+
verified?.set(hash, durationMs);
|
|
94
|
+
}
|
|
87
95
|
checkAlignment(asset);
|
|
88
96
|
}
|
|
89
|
-
|
|
97
|
+
class ConcurrencyLimiter {
|
|
98
|
+
limit;
|
|
99
|
+
active = 0;
|
|
100
|
+
queue = [];
|
|
101
|
+
constructor(limit) {
|
|
102
|
+
this.limit = limit;
|
|
103
|
+
}
|
|
104
|
+
async run(signal, fn) {
|
|
105
|
+
signal.throwIfAborted();
|
|
106
|
+
if (this.active >= this.limit) {
|
|
107
|
+
await new Promise((resolve, reject) => {
|
|
108
|
+
const onAbort = () => {
|
|
109
|
+
const index = this.queue.indexOf(release);
|
|
110
|
+
if (index >= 0)
|
|
111
|
+
this.queue.splice(index, 1);
|
|
112
|
+
reject(signal.reason);
|
|
113
|
+
};
|
|
114
|
+
const release = () => {
|
|
115
|
+
signal.removeEventListener('abort', onAbort);
|
|
116
|
+
resolve();
|
|
117
|
+
};
|
|
118
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
119
|
+
this.queue.push(release);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
signal.throwIfAborted();
|
|
123
|
+
this.active++;
|
|
124
|
+
try {
|
|
125
|
+
return await fn();
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
this.active--;
|
|
129
|
+
const next = this.queue.shift();
|
|
130
|
+
if (next)
|
|
131
|
+
next();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export async function generateSpeech(story, directory, adapters, cache, progress, verified) {
|
|
90
136
|
await mkdir(directory, { recursive: true });
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
137
|
+
const total = story.narration.length;
|
|
138
|
+
const assets = new Array(total);
|
|
139
|
+
progress?.(`Speech: ${total} segments`);
|
|
140
|
+
const prepared = story.narration.map((segment, index) => {
|
|
95
141
|
const voice = segment.voice ?? story.voice;
|
|
96
142
|
requireCondition(voice, 'VOICE_REQUIRED', `Narration ${segment.id} needs a voice`);
|
|
97
143
|
const adapter = adapters.get(voice.provider);
|
|
98
144
|
requireCondition(adapter, 'TTS_ADAPTER', `Unsupported TTS provider ${voice.provider}`, 3);
|
|
99
145
|
adapter.validate(voice);
|
|
100
146
|
const key = speechKey(segment, voice, adapter);
|
|
101
|
-
let asset;
|
|
102
147
|
const cached = cache ? join(resolve(cache), `${key}.json`) : undefined;
|
|
103
|
-
|
|
104
|
-
|
|
148
|
+
return { index, segment, voice, adapter, key, cached };
|
|
149
|
+
});
|
|
150
|
+
const parentScope = executionScope.getStore();
|
|
151
|
+
parentScope?.signal.throwIfAborted();
|
|
152
|
+
const local = new AbortController();
|
|
153
|
+
const onParentAbort = () => local.abort(parentScope.signal.reason);
|
|
154
|
+
parentScope?.signal.addEventListener('abort', onParentAbort, { once: true });
|
|
155
|
+
const providerLimiters = new Map();
|
|
156
|
+
const limiterFor = (adapter) => {
|
|
157
|
+
let limiter = providerLimiters.get(adapter.id);
|
|
158
|
+
if (!limiter) {
|
|
159
|
+
limiter = new ConcurrencyLimiter(Math.max(1, adapter.concurrency ?? 2));
|
|
160
|
+
providerLimiters.set(adapter.id, limiter);
|
|
161
|
+
}
|
|
162
|
+
return limiter;
|
|
163
|
+
};
|
|
164
|
+
const cacheLimiter = new ConcurrencyLimiter(4);
|
|
165
|
+
const inFlightByKey = new Map();
|
|
166
|
+
let started = 0;
|
|
167
|
+
let firstError;
|
|
168
|
+
const recordError = (error) => {
|
|
169
|
+
if (firstError === undefined)
|
|
170
|
+
firstError = error;
|
|
171
|
+
if (!local.signal.aborted)
|
|
172
|
+
local.abort(error);
|
|
173
|
+
};
|
|
174
|
+
try {
|
|
175
|
+
const tasks = prepared.map(({ index, segment, voice, adapter, key, cached }) => executionScope.run({ signal: local.signal, bounded: parentScope?.bounded ?? false }, async () => {
|
|
105
176
|
try {
|
|
106
|
-
|
|
177
|
+
local.signal.throwIfAborted();
|
|
178
|
+
let cachedAsset;
|
|
179
|
+
if (cached && !inFlightByKey.has(key)) {
|
|
180
|
+
let entry;
|
|
181
|
+
try {
|
|
182
|
+
entry = await json(cached);
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
if (error.code !== 'ENOENT')
|
|
186
|
+
throw new ProductionError('CACHE_INPUT', `Cannot read speech cache entry ${cached}`);
|
|
187
|
+
}
|
|
188
|
+
if (entry !== undefined) {
|
|
189
|
+
const manifest = { version: 1, assets: [entry] };
|
|
190
|
+
requireCondition(validateSpeech(manifest), 'CACHE_INPUT', `Invalid speech cache entry for ${segment.id}: ${cached}`);
|
|
191
|
+
cachedAsset = manifest.assets[0];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (cachedAsset) {
|
|
195
|
+
const asset = await cacheLimiter.run(local.signal, async () => {
|
|
196
|
+
progress?.(`Reusing cached speech ${segment.id} (${++started}/${total})`);
|
|
197
|
+
const resolvedAudio = resolve(dirname(cached), cachedAsset.audio);
|
|
198
|
+
const candidate = { ...cachedAsset, audio: resolvedAudio };
|
|
199
|
+
requireCondition(matchesSpeechCache(candidate, segment, voice, adapter), 'CACHE_MISMATCH', `Cache does not match ${segment.id}`);
|
|
200
|
+
await checkSpeech(candidate, verified);
|
|
201
|
+
const destination = speechPath(directory, segment.id, candidate.format);
|
|
202
|
+
await copyFile(candidate.audio, destination);
|
|
203
|
+
return { ...candidate, id: segment.id, audio: destination };
|
|
204
|
+
});
|
|
205
|
+
assets[index] = asset;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const existing = inFlightByKey.get(key);
|
|
209
|
+
if (existing) {
|
|
210
|
+
const source = await existing;
|
|
211
|
+
local.signal.throwIfAborted();
|
|
212
|
+
const destination = speechPath(directory, segment.id, source.format);
|
|
213
|
+
await copyFile(source.audio, destination);
|
|
214
|
+
assets[index] = { ...source, id: segment.id, audio: destination };
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const synthPromise = limiterFor(adapter).run(local.signal, async () => {
|
|
218
|
+
progress?.(`Generating speech ${segment.id} (${++started}/${total})`);
|
|
219
|
+
const generated = await adapter.synthesize(segment, voice, speechPath(directory, segment.id, 'mp3'));
|
|
220
|
+
const asset = { ...generated, key };
|
|
221
|
+
await checkSpeech(asset, verified);
|
|
222
|
+
if (cached) {
|
|
223
|
+
const cachedAudio = speechPath(resolve(cache), key, asset.format);
|
|
224
|
+
await mkdir(resolve(cache), { recursive: true });
|
|
225
|
+
await copyFile(asset.audio, cachedAudio);
|
|
226
|
+
await saveJson(cached, { ...asset, audio: `${key}.${asset.format}` });
|
|
227
|
+
}
|
|
228
|
+
return asset;
|
|
229
|
+
});
|
|
230
|
+
inFlightByKey.set(key, synthPromise);
|
|
231
|
+
assets[index] = await synthPromise;
|
|
107
232
|
}
|
|
108
233
|
catch (error) {
|
|
109
|
-
|
|
110
|
-
throw new ProductionError('CACHE_INPUT', `Cannot read speech cache entry ${cached}`);
|
|
111
|
-
}
|
|
112
|
-
if (entry !== undefined) {
|
|
113
|
-
const manifest = { version: 1, assets: [entry] };
|
|
114
|
-
requireCondition(validateSpeech(manifest), 'CACHE_INPUT', `Invalid speech cache entry for ${segment.id}: ${cached}`);
|
|
115
|
-
asset = manifest.assets[0];
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (asset) {
|
|
119
|
-
progress?.(`Reusing cached speech ${segment.id} (${assets.length + 1}/${story.narration.length})`);
|
|
120
|
-
asset.audio = resolve(dirname(cached), asset.audio);
|
|
121
|
-
requireCondition(matchesSpeechCache(asset, segment, voice, adapter), 'CACHE_MISMATCH', `Cache does not match ${segment.id}`);
|
|
122
|
-
await checkSpeech(asset);
|
|
123
|
-
await decode(asset.audio);
|
|
124
|
-
const destination = speechPath(directory, segment.id, asset.format);
|
|
125
|
-
await copyFile(asset.audio, destination);
|
|
126
|
-
asset = { ...asset, id: segment.id, audio: destination };
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
progress?.(`Generating speech ${segment.id} (${assets.length + 1}/${story.narration.length})`);
|
|
130
|
-
const generated = await adapter.synthesize(segment, voice, speechPath(directory, segment.id, 'mp3'));
|
|
131
|
-
asset = { ...generated, key };
|
|
132
|
-
await checkSpeech(asset);
|
|
133
|
-
if (cached) {
|
|
134
|
-
const cachedAudio = speechPath(resolve(cache), key, asset.format);
|
|
135
|
-
await mkdir(resolve(cache), { recursive: true });
|
|
136
|
-
await copyFile(asset.audio, cachedAudio);
|
|
137
|
-
await saveJson(cached, { ...asset, audio: `${key}.${asset.format}` });
|
|
234
|
+
recordError(error);
|
|
138
235
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
236
|
+
}));
|
|
237
|
+
await Promise.allSettled(tasks);
|
|
238
|
+
}
|
|
239
|
+
finally {
|
|
240
|
+
parentScope?.signal.removeEventListener('abort', onParentAbort);
|
|
141
241
|
}
|
|
242
|
+
if (firstError !== undefined)
|
|
243
|
+
throw firstError;
|
|
244
|
+
executionSignal()?.throwIfAborted();
|
|
142
245
|
const manifest = { version: 1, assets };
|
|
143
246
|
await saveJson(join(directory, 'manifest.json'), manifest);
|
|
144
247
|
return manifest;
|
package/dist/timing.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Schedule, SpeechManifest, Storyboard, TtsAdapter } from './contracts.js';
|
|
2
|
-
import { type VerifiedSpeechAudio } from './speech.js';
|
|
3
|
-
export declare function resolveTiming(story: Storyboard, speech: SpeechManifest): Promise<Schedule>;
|
|
2
|
+
import { type VerifiedSpeech, type VerifiedSpeechAudio } from './speech.js';
|
|
3
|
+
export declare function resolveTiming(story: Storyboard, speech: SpeechManifest, verified?: VerifiedSpeech): Promise<Schedule>;
|
|
4
4
|
export declare function resolvePreviewTiming(story: Storyboard, adapters: ReadonlyMap<string, TtsAdapter>, cache?: string): Promise<{
|
|
5
5
|
schedule: Schedule;
|
|
6
6
|
approximate: string[];
|
|
7
|
+
approximateCues: string[];
|
|
7
8
|
audio: Map<string, VerifiedSpeechAudio>;
|
|
8
9
|
}>;
|
package/dist/timing.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { requireCondition } from './errors.js';
|
|
2
2
|
import { probe } from './media.js';
|
|
3
3
|
import { checkSpeech, retainedSpeechTiming } from './speech.js';
|
|
4
|
-
export async function resolveTiming(story, speech) {
|
|
4
|
+
export async function resolveTiming(story, speech, verified) {
|
|
5
5
|
for (const asset of speech.assets)
|
|
6
|
-
await checkSpeech(asset);
|
|
6
|
+
await checkSpeech(asset, verified);
|
|
7
7
|
return resolveSchedule(story, speech.assets);
|
|
8
8
|
}
|
|
9
|
+
function approximateAlignment(text, durationMs) {
|
|
10
|
+
if (text.length === 0)
|
|
11
|
+
return null;
|
|
12
|
+
const units = Array.from({ length: text.length }, (_, index) => ({
|
|
13
|
+
text: text[index],
|
|
14
|
+
start: index,
|
|
15
|
+
end: index + 1,
|
|
16
|
+
start_ms: (index / text.length) * durationMs,
|
|
17
|
+
end_ms: ((index + 1) / text.length) * durationMs,
|
|
18
|
+
}));
|
|
19
|
+
return { form: 'original', granularity: 'character', text, units };
|
|
20
|
+
}
|
|
9
21
|
export async function resolvePreviewTiming(story, adapters, cache) {
|
|
10
22
|
const assets = [];
|
|
11
23
|
const approximate = [];
|
|
@@ -25,10 +37,40 @@ export async function resolvePreviewTiming(story, adapters, cache) {
|
|
|
25
37
|
else {
|
|
26
38
|
approximate.push(segment.id);
|
|
27
39
|
const words = segment.text.trim().split(/\s+/).filter(Boolean).length;
|
|
28
|
-
|
|
40
|
+
const durationMs = Math.max(1000, words * 60000 / 150);
|
|
41
|
+
assets.push({
|
|
42
|
+
id: segment.id,
|
|
43
|
+
duration_ms: durationMs,
|
|
44
|
+
transcript: { original: segment.text, normalized: segment.text },
|
|
45
|
+
alignment: approximateAlignment(segment.text, durationMs),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const schedule = await resolveSchedule(story, assets);
|
|
50
|
+
const approximateSet = new Set(approximate);
|
|
51
|
+
const seenCues = new Set();
|
|
52
|
+
const approximateCues = [];
|
|
53
|
+
const recordCue = (id) => {
|
|
54
|
+
if (!seenCues.has(id)) {
|
|
55
|
+
seenCues.add(id);
|
|
56
|
+
approximateCues.push(id);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
for (const item of schedule.actions) {
|
|
60
|
+
if (item.cue_span && approximateSet.has(item.cue_span.segment))
|
|
61
|
+
recordCue(item.id);
|
|
62
|
+
}
|
|
63
|
+
for (const annotation of schedule.annotations) {
|
|
64
|
+
if (annotation.cue_span && approximateSet.has(annotation.cue_span.segment))
|
|
65
|
+
recordCue(annotation.source_id ?? annotation.id);
|
|
66
|
+
}
|
|
67
|
+
for (const overlay of story.overlays ?? []) {
|
|
68
|
+
if (overlay.visible?.some(interval => (typeof interval.start !== 'number' && approximateSet.has(interval.start.segment))
|
|
69
|
+
|| (typeof interval.end !== 'number' && approximateSet.has(interval.end.segment)))) {
|
|
70
|
+
recordCue(overlay.id);
|
|
29
71
|
}
|
|
30
72
|
}
|
|
31
|
-
return { schedule
|
|
73
|
+
return { schedule, approximate, approximateCues, audio };
|
|
32
74
|
}
|
|
33
75
|
async function resolveSchedule(story, speech) {
|
|
34
76
|
const media = await Promise.all(story.media.map(async (item) => ({ ...item, ...await probe(item.src) })));
|
|
@@ -1,23 +1,55 @@
|
|
|
1
|
-
import { renameSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { mkdirSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { gt, valid } from 'semver';
|
|
3
4
|
import { userDataDirectory } from './installation.js';
|
|
4
5
|
import { updateVersion } from './update-check.js';
|
|
5
6
|
const channel = process.argv[2];
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const rawInstalled = process.argv[3];
|
|
8
|
+
const installed = typeof rawInstalled === 'string' && valid(rawInstalled) ? rawInstalled : '0.0.0';
|
|
9
|
+
const userAgent = `slidevideo-cli/${installed} (${process.platform}; ${process.arch})`;
|
|
10
|
+
async function fetchReleaseVersion(targetChannel) {
|
|
11
|
+
let siteVersion;
|
|
8
12
|
try {
|
|
9
|
-
const
|
|
13
|
+
const url = targetChannel === 'alpha'
|
|
14
|
+
? 'https://slidevideo.io/release.json?channel=alpha'
|
|
15
|
+
: 'https://slidevideo.io/release.json';
|
|
16
|
+
const response = await fetch(url, {
|
|
17
|
+
headers: { 'user-agent': userAgent, accept: 'application/json' },
|
|
10
18
|
signal: AbortSignal.timeout(3000),
|
|
11
19
|
});
|
|
12
20
|
if (response.ok) {
|
|
13
21
|
const result = await response.json();
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
siteVersion = updateVersion(result?.version, targetChannel);
|
|
23
|
+
if (siteVersion && gt(siteVersion, installed))
|
|
24
|
+
return siteVersion;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch { }
|
|
28
|
+
try {
|
|
29
|
+
const fallback = await fetch(`https://registry.npmjs.org/@slidevideo%2fcli/${targetChannel}`, {
|
|
30
|
+
headers: { 'user-agent': userAgent, accept: 'application/json' },
|
|
31
|
+
signal: AbortSignal.timeout(3000),
|
|
32
|
+
});
|
|
33
|
+
if (fallback.ok) {
|
|
34
|
+
const result = await fallback.json();
|
|
35
|
+
const npmVersion = updateVersion(result?.version, targetChannel);
|
|
36
|
+
if (npmVersion)
|
|
37
|
+
return siteVersion && gt(siteVersion, npmVersion) ? siteVersion : npmVersion;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch { }
|
|
41
|
+
return siteVersion;
|
|
42
|
+
}
|
|
43
|
+
if (channel === 'latest' || channel === 'alpha') {
|
|
44
|
+
const deadline = setTimeout(() => process.exit(0), 6500);
|
|
45
|
+
try {
|
|
46
|
+
const version = await fetchReleaseVersion(channel);
|
|
47
|
+
if (version) {
|
|
48
|
+
const directory = join(userDataDirectory(), 'updates');
|
|
49
|
+
mkdirSync(directory, { recursive: true });
|
|
50
|
+
const pending = join(directory, `${channel}.${process.pid}.tmp`);
|
|
51
|
+
writeFileSync(pending, JSON.stringify(version), { mode: 0o600 });
|
|
52
|
+
renameSync(pending, join(directory, `${channel}.json`));
|
|
21
53
|
}
|
|
22
54
|
}
|
|
23
55
|
catch { }
|
package/dist/update-check.js
CHANGED
|
@@ -21,11 +21,13 @@ export function updateVersion(value, channel) {
|
|
|
21
21
|
return version && updateChannel(version) === channel ? version : undefined;
|
|
22
22
|
}
|
|
23
23
|
export function notifyUpdate(json, quiet) {
|
|
24
|
-
if (
|
|
24
|
+
if (process.env.SLIDEVIDEO_NO_UPDATE_CHECK === '1'
|
|
25
|
+
|| process.env.DO_NOT_TRACK === '1'
|
|
25
26
|
|| (process.env.CI && process.env.CI !== 'false')
|
|
26
27
|
|| process.env.GITHUB_ACTIONS || process.env.TF_BUILD || process.env.BUILD_NUMBER
|
|
27
|
-
||
|
|
28
|
+
|| process.env.NODE_TEST_CONTEXT)
|
|
28
29
|
return;
|
|
30
|
+
const interactive = !json && !quiet && Boolean(process.stdin.isTTY && process.stdout.isTTY && process.stderr.isTTY);
|
|
29
31
|
try {
|
|
30
32
|
const { version: installed } = JSON.parse(readFileSync(packagePath('package.json'), 'utf8'));
|
|
31
33
|
if (typeof installed !== 'string')
|
|
@@ -34,13 +36,15 @@ export function notifyUpdate(json, quiet) {
|
|
|
34
36
|
if (!channel)
|
|
35
37
|
return;
|
|
36
38
|
const directory = join(userDataDirectory(), 'updates');
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
if (interactive) {
|
|
40
|
+
let available;
|
|
41
|
+
try {
|
|
42
|
+
available = updateVersion(JSON.parse(readFileSync(join(directory, `${channel}.json`), 'utf8')), channel);
|
|
43
|
+
}
|
|
44
|
+
catch { }
|
|
45
|
+
if (available && gt(available, installed)) {
|
|
46
|
+
process.stderr.write(`[slidevideo] Update available: ${installed} → ${available}\nRun npm install -g @slidevideo/cli@${available}\nFor a custom install prefix, add the original --prefix option to this command.\n`);
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
mkdirSync(directory, { recursive: true });
|
|
46
50
|
const attempt = join(directory, 'attempt.json');
|
|
@@ -69,7 +73,7 @@ export function notifyUpdate(json, quiet) {
|
|
|
69
73
|
release();
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
const child = spawn(process.execPath, [fileURLToPath(new URL('./update-check-worker.js', import.meta.url)), channel], {
|
|
76
|
+
const child = spawn(process.execPath, [fileURLToPath(new URL('./update-check-worker.js', import.meta.url)), channel, installed], {
|
|
73
77
|
detached: true, stdio: 'ignore', windowsHide: true,
|
|
74
78
|
});
|
|
75
79
|
child.on('error', () => { });
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ Use the `annotations` array for `highlight`, `underline`, `spotlight`, `zoom`, `
|
|
|
41
41
|
|
|
42
42
|
Add, change or remove only the requested annotation and preserve unrelated annotations, narration, scene actions, media, IDs and settings. A new video after an annotation-only edit needs a new run and can reuse matching speech. Validate the draft through the real CLI. Required phrase alignment and actual target geometry are checked during resolution and capture. Highlights are composited into the final MP4, so ordinary deck playback and the raw recording remain unannotated.
|
|
43
43
|
|
|
44
|
-
When the creator wants to watch the storyboard, run `slidevideo play --storyboard <file>` and give them the local URL. It automatically reads matching speech timing and synchronized cached narration audio (with a Mute/Unmute toggle) from `.slidevideo/speech` beside the storyboard; pass `--cache-dir <directory>` to use another cache or `--no-cache` to disable cache reads. The browser player shows live highlights and supports Play, Pause, Replay, timeline scrubbing, and scene jumping. Restart the command after a YAML edit.
|
|
44
|
+
When the creator wants to watch the storyboard, run `slidevideo play --storyboard <file>` and give them the local URL. It automatically reads matching speech timing and synchronized cached narration audio (with a Mute/Unmute toggle) from `.slidevideo/speech` beside the storyboard; pass `--cache-dir <directory>` to use another cache or `--no-cache` to disable cache reads. For uncached segments, preview estimates durations at 150 words/min and approximates phrase-cue and `follow` alignment (labeled clearly as approximate in CLI and browser output), while `resolve` and `build` still require synthesized provider alignment. The browser player shows live highlights and supports Play, Pause, Replay, timeline scrubbing, and scene jumping. Restart the command after a YAML edit. [Preview and recording commands](references/production.md#choose-the-operation)
|
|
45
45
|
|
|
46
46
|
For an authoring or review request, deliver the YAML and a readable outline of the narration, slide changes, reveals, holds, media and voice. Point out assumptions, unsupported requests and choices that affect pacing. A compact table is useful when several scenes or cues need review. Do not generate speech or record a video merely to review a text draft.
|
|
47
47
|
|