@phil65/demoreel 0.5.1 → 0.7.1

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 (39) hide show
  1. package/README.md +39 -5
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/args.js +3 -0
  4. package/dist/cli.js +32 -1
  5. package/dist/compose.d.ts +15 -1
  6. package/dist/compose.js +46 -2
  7. package/dist/idle.d.ts +2 -1
  8. package/dist/idle.js +3 -1
  9. package/dist/index.d.ts +3 -2
  10. package/dist/index.js +2 -1
  11. package/dist/marks.d.ts +2 -1
  12. package/dist/marks.js +9 -0
  13. package/dist/mcp.js +40 -2
  14. package/dist/project.d.ts +247 -11
  15. package/dist/project.js +244 -8
  16. package/dist/record.d.ts +5 -1
  17. package/dist/record.js +26 -6
  18. package/dist/render.d.ts +2 -0
  19. package/dist/render.js +35 -2
  20. package/dist/renderer/assets/{CanvasPool-PBu3bHFZ.js → CanvasPool-SkgMbnEH.js} +1 -1
  21. package/dist/renderer/assets/{CanvasRenderer-HmF-4gyW.js → CanvasRenderer-CEGuSdsG.js} +1 -1
  22. package/dist/renderer/assets/{RenderTargetSystem-Dk1U4wDJ.js → RenderTargetSystem-um8Nv1HQ.js} +1 -1
  23. package/dist/renderer/assets/{WebGLRenderer-C0v9HBel.js → WebGLRenderer-BnY2xfDL.js} +1 -1
  24. package/dist/renderer/assets/{WebGPURenderer-Ce0-U9Q1.js → WebGPURenderer-D9KI_sD9.js} +1 -1
  25. package/dist/renderer/assets/{browserAll-DhvWQ7nM.js → browserAll-vQt6iTAv.js} +1 -1
  26. package/dist/renderer/assets/{canvasUtils-KRroregW.js → canvasUtils-CZLntkW8.js} +1 -1
  27. package/dist/renderer/assets/{getTexelRangeRects-D3pwCyRt.js → getTexelRangeRects-CRAnqulP.js} +1 -1
  28. package/dist/renderer/assets/{index-CE-lli1m.js → index-41-d13J1.js} +4 -4
  29. package/dist/renderer/assets/{init-DfmWKarH.js → init-D6nA7FlC.js} +1 -1
  30. package/dist/renderer/assets/webworkerAll-BEIrFubI.js +1 -0
  31. package/dist/renderer/index.html +1 -1
  32. package/dist/scene.d.ts +132 -6
  33. package/dist/scene.js +279 -1
  34. package/dist/types.d.ts +97 -1
  35. package/dist/voice.d.ts +91 -0
  36. package/dist/voice.js +353 -0
  37. package/package.json +2 -1
  38. package/skills/demoreel/SKILL.md +9 -0
  39. package/dist/renderer/assets/webworkerAll-B41hok0-.js +0 -1
package/README.md CHANGED
@@ -84,7 +84,8 @@ Each run writes into `out/<name>/`:
84
84
 
85
85
  | file | what |
86
86
  | --- | --- |
87
- | `<name>.mp4` | the rendered video |
87
+ | `<name>.mp4` | the rendered video (with muxed AAC audio when `scene.say()` is used) |
88
+ | `<name>.vtt` | WebVTT subtitles aligned to the rendered video (when `scene.say()` is used) |
88
89
  | `<name>.openscreen` | OpenScreen v2 project: open it in the OpenScreen app to tweak by hand, then `demoreel render` |
89
90
  | `recording.mp4` + `.cursor.json` | raw CFR recording and cursor telemetry (OpenScreen's sidecar format) |
90
91
  | `timeline.json` | what happened when: actions with target boxes, zoom / trim regions, captions, timings |
@@ -105,9 +106,13 @@ Each run writes into `out/<name>/`:
105
106
  | `scroll(target \| { by: px })` | smooth scroll (the page's or the target's scroll container) |
106
107
  | `press(key, { show, duration })` | keyboard shortcut (Playwright syntax); optional keycap HUD pill |
107
108
  | `pause(ms)` | wait |
108
- | `caption(text, { duration, wait })` | caption overlay (an OpenScreen text annotation, sharp at any zoom) |
109
+ | `caption(text, { duration, wait, animation })` | caption overlay (an OpenScreen text annotation, sharp at any zoom; optional `fade` / `rise` / `pop` / `typewriter` animation) |
110
+ | `say(text, [opts], [fn])` | voiceover narration via `@phil65/anyvoice` (free Edge TTS by default, OpenAI, ElevenLabs, Gemini, Cartesia, Deepgram); supports `say(text, async (cue) => { await cue.at("word"); ... })` + `.vtt` subtitles |
109
111
  | `zoom(target, { depth, duration, context, wait })` | explicit zoom (integer tier `1..6`: 1.25x..5x) overriding auto zooms |
110
112
  | `highlight(target, { duration, color, dim, badge, zoom })` | outline with optional spotlight dim backdrop and callout badge |
113
+ | `blur(target, { type, shape, intensity, duration })` | blur or pixelate (`type: "mosaic"`) sensitive UI elements (alias `redact()`; defaults to blurring until video end) |
114
+ | `arrow(target, { direction, color, duration })` | draw a crisp OpenScreen vector arrow pointing at an element |
115
+ | `image(src, { x, y, width, height, duration })` | overlay a local PNG/JPG/SVG/WebP image or `data:image/...` URL on the rendered canvas |
111
116
 
112
117
  `target` is a structured accessibility-first spec (`{ role, name?, exact?, nth? }`,
113
118
  `{ label, exact?, nth? }`, `{ placeholder, exact?, nth? }`, `{ text, exact?, nth? }`,
@@ -120,9 +125,38 @@ Scenario options: `viewport`, `cssZoom` (crisper text: lay out at a smaller size
120
125
  up), `serve` (static dir served at `ctx.baseUrl`), `storageState` (Playwright storageState
121
126
  JSON, relative to the scenario file), `colorScheme`, `seed`, `pacing`
122
127
  (`speed`, `beforeAction`, `afterClick`, `typeDelay`, ...), `zoom` (see below), `look`
123
- (`wallpaper`, `padding`, `borderRadius`, `shadowIntensity`, `aspectRatio`,
124
- `captionPosition`, `showKeys`), `cursor` (`size`, `clickBounce`, `smoothing`, `motionBlur`,
125
- `show`), `clickRipple`, `trimIdle` (`true` or `{ minMs, keepMs, mode, speed, ignoreFrames }`).
128
+ (`wallpaper`, `padding`, `borderRadius`, `shadowIntensity`, `showBlur`, `crop`, `aspectRatio`,
129
+ `captionPosition`, `captionFontSize`, `captionAnimation`, `showKeys`, `watermark`), `cursor` (`size`, `clickBounce`, `smoothing`, `motionBlur`,
130
+ `show`), `clickRipple`, `trimIdle` (`true` or `{ minMs, keepMs, mode, speed, ignoreFrames }`),
131
+ `voice` (`{ provider: "edge" | "openai" | "elevenlabs" | "gemini" | "cartesia" | "deepgram", voice, model, language, speed, pitch, volume, instructions, gapMs, padMs, captions: "vtt" | "burned" | "off", cacheDir }`).
132
+
133
+ ### Voiceover narration (`scene.say`)
134
+
135
+ Add synced voiceover with zero API keys (defaults to free Microsoft Edge Neural TTS via `@phil65/anyvoice`, with SHA-256 disk caching so re-runs only synthesize edited lines):
136
+
137
+ ```ts
138
+ export default defineScenario({
139
+ name: "checkout",
140
+ voice: { provider: "edge", voice: "en-US-AndrewMultilingualNeural", speed: 1.05 },
141
+ async run(scene) {
142
+ await scene.goto("http://localhost:3000/");
143
+ // Standalone beat: holds automatically for the exact spoken duration
144
+ await scene.say("Welcome — let's check out in two clicks.");
145
+ // Narrate while acting: holds if actions finish faster than speech, never overlaps
146
+ await scene.say("Pick the Pro plan and click Checkout.", async (cue) => {
147
+ await cue.at("Pro", -150);
148
+ await scene.select({ label: "Plan" }, "pro");
149
+ await cue.at("Checkout", -150);
150
+ await scene.click({ role: "button", name: "Checkout" });
151
+ });
152
+ },
153
+ });
154
+ ```
155
+
156
+ - `demoreel run --dry-run` warms the SHA-256 voice cache and reports per-cue spoken durations before recording.
157
+ - `trimIdle` automatically keeps every voice cue intact while cutting dead silence between beats.
158
+ - `demoreel render` / `demoreel rezoom --render` stream-copy the OpenScreen H.264 video (`-c:v copy`), mux all cues into AAC audio at post-trim timestamps, and write `<name>.vtt`.
159
+ - Override provider or voice at run time without editing the scenario: `--voice-provider openai --voice nova` or `--no-voice`.
126
160
 
127
161
  Library: `recordScenario`, `dryRunScenario`, `resolveStorageState`, `deriveZoomRegions`,
128
162
  `deriveIdleRegions`, `buildProject`, `buildCursorData`, `buildMarks`, `renderProject`,
@@ -14,7 +14,7 @@ are listed in `vendor/openscreen/VENDORED.md` in the demoreel repository.
14
14
 
15
15
  | package | version | license | text | source |
16
16
  | --- | --- | --- | --- | --- |
17
- | colord | 2.14.0 | MIT | [licenses/colord.txt](licenses/colord.txt) | https://github.com/omgovich/colord |
17
+ | colord | 2.14.1 | MIT | [licenses/colord.txt](licenses/colord.txt) | https://github.com/omgovich/colord |
18
18
  | earcut | 3.2.4 | ISC | [licenses/earcut.txt](licenses/earcut.txt) | git://github.com/mapbox/earcut |
19
19
  | eventemitter3 | 5.0.4 | MIT | [licenses/eventemitter3.txt](licenses/eventemitter3.txt) | git://github.com/primus/eventemitter3 |
20
20
  | gif.js | 0.2.0 | MIT | [licenses/gif.js.txt](licenses/gif.js.txt) | https://github.com/jnordberg/gif.js |
package/dist/args.js CHANGED
@@ -24,6 +24,9 @@ export const COMMANDS = {
24
24
  viewport: { type: "string", value: "WxH", description: "override the scenario viewport, e.g. 1280x720" },
25
25
  state: { type: "string", value: "FILE", description: "Playwright storageState JSON (overrides scenario.storageState)" },
26
26
  "dry-run": { type: "boolean", description: "run the scenario fast without ffmpeg, recording, or writing files" },
27
+ "voice-provider": { type: "string", value: "NAME", description: "override voiceover TTS provider: edge (free) | openai | elevenlabs | gemini | cartesia | deepgram" },
28
+ voice: { type: "string", value: "ID", description: "override voiceover voice ID" },
29
+ "no-voice": { type: "boolean", description: "skip voiceover TTS synthesis for this run" },
27
30
  headed: { type: "boolean", description: "show the browser while recording" },
28
31
  frames,
29
32
  framesheet,
package/dist/cli.js CHANGED
@@ -13,6 +13,7 @@ import { PACKAGE_ROOT } from "./openscreen.js";
13
13
  import { dryRunScenario, recordScenario, resolveStorageState } from "./record.js";
14
14
  import { renderProject, validateProject } from "./render.js";
15
15
  import { extractFrame, findFramesheet, reviewSheet } from "./sheet.js";
16
+ import { formatDryRunVoiceSummary, formatVoiceSummary, VOICE_PROVIDERS } from "./voice.js";
16
17
  const fmt = (ms) => `${(ms / 1000).toFixed(1)}s`;
17
18
  const log = (msg) => console.error(msg);
18
19
  function progressPrinter(enabled) {
@@ -31,7 +32,9 @@ function progressPrinter(enabled) {
31
32
  };
32
33
  }
33
34
  function printRender(r) {
34
- log(` rendered ${r.width}x${r.height} ${(r.bytes / 1e6).toFixed(1)} MB in ${fmt(r.renderMs)} (${r.gpu ? "GPU" : "software"}, setup ${fmt(r.setupMs)}) -> ${r.outputPath}`);
35
+ log(` rendered ${r.width}x${r.height} ${(r.bytes / 1e6).toFixed(1)} MB in ${fmt(r.renderMs)} (${r.gpu ? "GPU" : "software"}, setup ${fmt(r.setupMs)})${r.audioMuxed ? " + audio" : ""} -> ${r.outputPath}`);
36
+ if (r.vttPath)
37
+ log(` subtitles: ${r.vttPath}`);
35
38
  if (r.warnings.length)
36
39
  log(` warnings: ${r.warnings.join("; ")}`);
37
40
  }
@@ -62,6 +65,21 @@ async function cmdRun({ positionals, flags }) {
62
65
  overrides.pacing = { ...scenario.pacing, speed: Number(flags.speed) };
63
66
  if (flags["trim-idle"] !== undefined)
64
67
  overrides.trimIdle = Boolean(flags["trim-idle"]) && (scenario.trimIdle || true);
68
+ if (flags["voice-provider"] !== undefined || flags.voice !== undefined || flags["no-voice"]) {
69
+ const voice = { ...scenario.voice };
70
+ if (flags["voice-provider"] !== undefined) {
71
+ const p = String(flags["voice-provider"]);
72
+ if (!VOICE_PROVIDERS.includes(p)) {
73
+ throw new UsageError(`--voice-provider must be ${VOICE_PROVIDERS.join(", ")}`);
74
+ }
75
+ voice.provider = p;
76
+ }
77
+ if (flags["no-voice"])
78
+ voice.enabled = false;
79
+ if (typeof flags.voice === "string")
80
+ voice.voice = flags.voice;
81
+ overrides.voice = voice;
82
+ }
65
83
  const storageState = flags.state ? String(flags.state) : undefined;
66
84
  if (flags["dry-run"]) {
67
85
  const res = await dryRunScenario(scenario, {
@@ -72,6 +90,9 @@ async function cmdRun({ positionals, flags }) {
72
90
  });
73
91
  for (const a of res.actions)
74
92
  console.log(formatActionLine(a));
93
+ if (res.voiceCues.length) {
94
+ console.log(formatDryRunVoiceSummary(res.voiceCues));
95
+ }
75
96
  if (!res.ok && res.error) {
76
97
  log(`FAIL action #${res.error.actionIndex}: ${res.error.message}`);
77
98
  process.exitCode = 1;
@@ -127,6 +148,9 @@ async function cmdRun({ positionals, flags }) {
127
148
  log(` contact sheet (${sheet.tool}): ${sheet.sheet}`);
128
149
  if (sheet.summary)
129
150
  console.log(sheet.summary);
151
+ if (timeline.voiceCues?.length) {
152
+ console.log(formatVoiceSummary(timeline.voiceCues, timeline.outputDurationMs, timeline.trimRegions, timeline.speedRegions));
153
+ }
130
154
  }
131
155
  async function cmdRender({ positionals, flags }) {
132
156
  const projectPath = path.resolve(positionals[0]);
@@ -203,6 +227,13 @@ async function cmdSheet({ positionals, flags }) {
203
227
  });
204
228
  if (sheet.summary)
205
229
  console.log(sheet.summary);
230
+ const tlDir = path.dirname(target);
231
+ if (fs.existsSync(path.join(tlDir, "timeline.json"))) {
232
+ const tl = readTimeline(tlDir);
233
+ if (tl.voiceCues?.length) {
234
+ console.log(formatVoiceSummary(tl.voiceCues, tl.outputDurationMs, tl.trimRegions, tl.speedRegions));
235
+ }
236
+ }
206
237
  log(`contact sheet (${sheet.tool}): ${sheet.sheet}`);
207
238
  console.log(sheet.sheet);
208
239
  if (sheet.report)
package/dist/compose.d.ts CHANGED
@@ -2,7 +2,8 @@ import { type IdleOptions } from "./idle.ts";
2
2
  import { type Marks } from "./marks.ts";
3
3
  import { buildProject, type LookOptions } from "./project.ts";
4
4
  import type { CursorStyle } from "./render.ts";
5
- import type { ActionRecord, Caption, CursorSample, SpeedRegion, TrimRegion, Viewport, ZoomRegion } from "./types.ts";
5
+ import type { ActionRecord, ArrowAnnotation, BlurAnnotation, Caption, CursorSample, ImageAnnotation, SpeedRegion, TrimRegion, Viewport, VoiceCue, ZoomRegion } from "./types.ts";
6
+ import type { VoiceConfig } from "./voice.ts";
6
7
  import { type ZoomOptions } from "./zoom.ts";
7
8
  export declare const TIMELINE_VERSION = 1;
8
9
  /** `timeline.json`: the agent-facing record of a run. Times in ms of the recording. */
@@ -21,12 +22,17 @@ export interface Timeline {
21
22
  look: Partial<LookOptions>;
22
23
  trimIdle: Partial<IdleOptions> | false;
23
24
  cursor?: CursorStyle;
25
+ voice?: Omit<VoiceConfig, "apiKey">;
24
26
  };
25
27
  actions: ActionRecord[];
26
28
  zoomRegions: ZoomRegion[];
27
29
  trimRegions: TrimRegion[];
28
30
  speedRegions: SpeedRegion[];
29
31
  captions: Caption[];
32
+ blurs?: BlurAnnotation[];
33
+ arrows?: ArrowAnnotation[];
34
+ images?: ImageAnnotation[];
35
+ voiceCues?: VoiceCue[];
30
36
  timings: Record<string, number>;
31
37
  files: {
32
38
  recording: string;
@@ -34,6 +40,7 @@ export interface Timeline {
34
40
  project: string;
35
41
  marks: string;
36
42
  video: string;
43
+ vtt?: string;
37
44
  };
38
45
  /** Recording-clock times of captured frames (visual changes). */
39
46
  frameTimes: number[];
@@ -41,6 +48,8 @@ export interface Timeline {
41
48
  export interface ComposeInput {
42
49
  name: string;
43
50
  outDir: string;
51
+ /** Base directory for resolving relative image/watermark paths (scenario file directory). */
52
+ baseDir?: string;
44
53
  videoPath: string;
45
54
  durationMs: number;
46
55
  frameCount: number;
@@ -48,6 +57,10 @@ export interface ComposeInput {
48
57
  frameSize: Viewport;
49
58
  actions: ActionRecord[];
50
59
  captions: Caption[];
60
+ blurs?: BlurAnnotation[];
61
+ arrows?: ArrowAnnotation[];
62
+ images?: ImageAnnotation[];
63
+ voiceCues?: VoiceCue[];
51
64
  samples: CursorSample[];
52
65
  frameTimes: number[];
53
66
  timings: Record<string, number>;
@@ -55,6 +68,7 @@ export interface ComposeInput {
55
68
  look?: Partial<LookOptions>;
56
69
  trimIdle?: Partial<IdleOptions> | boolean;
57
70
  cursor?: CursorStyle;
71
+ voice?: VoiceConfig;
58
72
  }
59
73
  export interface ComposeResult {
60
74
  timeline: Timeline;
package/dist/compose.js CHANGED
@@ -16,26 +16,49 @@ export function compose(input, opts = {}) {
16
16
  const layout = stageLayout(input.viewport, look);
17
17
  const zoomRegions = deriveZoomRegions(input.actions, input.viewport, input.durationMs, input.zoom, layout);
18
18
  const captions = placeCaptions(input.captions.map(({ position: _p, ...c }) => c), targetRects({ actions: input.actions, viewport: input.viewport, layout, zoomRegions }), look.captionPosition);
19
+ const voiceCues = input.voiceCues ?? [];
19
20
  const idleOpts = input.trimIdle === true ? {} : input.trimIdle || null;
20
21
  const { trimRegions, speedRegions } = idleOpts
21
22
  ? deriveIdleRegions({
22
23
  durationMs: input.durationMs,
23
24
  actions: input.actions,
24
25
  captions: input.captions,
26
+ voiceCues,
25
27
  samples: input.samples,
26
28
  zoomRegions,
27
29
  frameTimes: input.frameTimes,
28
30
  }, idleOpts)
29
31
  : { trimRegions: [], speedRegions: [] };
30
32
  const projectPath = path.join(input.outDir, `${input.name}.openscreen`);
33
+ const resolvedImages = (input.images ?? []).map((img) => ({
34
+ ...img,
35
+ src: img.src.startsWith("data:") || path.isAbsolute(img.src) ? img.src : path.resolve(input.baseDir ?? process.cwd(), img.src),
36
+ }));
37
+ const resolvedLook = look.watermark
38
+ ? {
39
+ ...look,
40
+ watermark: {
41
+ ...look.watermark,
42
+ src: look.watermark.src.startsWith("data:") || path.isAbsolute(look.watermark.src)
43
+ ? look.watermark.src
44
+ : path.resolve(input.baseDir ?? process.cwd(), look.watermark.src),
45
+ },
46
+ }
47
+ : look;
31
48
  let project = buildProject({
32
49
  videoPath: input.videoPath,
33
50
  zoomRegions,
34
51
  captions,
52
+ blurs: input.blurs,
53
+ arrows: input.arrows,
54
+ images: resolvedImages,
35
55
  actions: input.actions,
36
56
  trimRegions,
37
57
  speedRegions,
38
- look,
58
+ look: resolvedLook,
59
+ viewport: input.viewport,
60
+ durationMs: input.durationMs,
61
+ baseDir: input.baseDir,
39
62
  });
40
63
  if (opts.keepProjectFrom && fs.existsSync(opts.keepProjectFrom)) {
41
64
  // rezoom: keep edits made in OpenScreen, replace only the derived regions.
@@ -53,6 +76,7 @@ export function compose(input, opts = {}) {
53
76
  durationMs: input.durationMs,
54
77
  actions: input.actions,
55
78
  captions,
79
+ voiceCues,
56
80
  zoomRegions,
57
81
  trimRegions,
58
82
  speedRegions,
@@ -61,6 +85,8 @@ export function compose(input, opts = {}) {
61
85
  });
62
86
  const marksPath = path.join(input.outDir, "marks.json");
63
87
  fs.writeFileSync(marksPath, JSON.stringify(marks, null, 1));
88
+ // Never persist secret apiKey into timeline.json.
89
+ const safeVoice = input.voice ? (({ apiKey: _k, ...rest }) => rest)(input.voice) : undefined;
64
90
  const timeline = {
65
91
  version: TIMELINE_VERSION,
66
92
  scenario: input.name,
@@ -72,15 +98,27 @@ export function compose(input, opts = {}) {
72
98
  frameSize: input.frameSize,
73
99
  options: {
74
100
  zoom: input.zoom ?? {},
75
- look: input.look ?? {},
101
+ look: input.look
102
+ ? {
103
+ ...input.look,
104
+ ...(resolvedLook.watermark ? { watermark: resolvedLook.watermark } : {}),
105
+ }
106
+ : {},
76
107
  trimIdle: idleOpts ?? false,
77
108
  ...(input.cursor ? { cursor: input.cursor } : {}),
109
+ ...(safeVoice ? { voice: safeVoice } : {}),
78
110
  },
79
111
  actions: input.actions.map(roundAction),
80
112
  zoomRegions,
81
113
  trimRegions,
82
114
  speedRegions,
83
115
  captions: captions.map((c) => ({ ...c, startMs: Math.round(c.startMs), endMs: Math.round(c.endMs) })),
116
+ ...(input.blurs?.length ? { blurs: input.blurs } : {}),
117
+ ...(input.arrows?.length ? { arrows: input.arrows } : {}),
118
+ ...(resolvedImages.length ? { images: resolvedImages } : {}),
119
+ ...(voiceCues.length
120
+ ? { voiceCues: voiceCues.map((c) => ({ ...c, startMs: Math.round(c.startMs), endMs: Math.round(c.endMs) })) }
121
+ : {}),
84
122
  timings: input.timings,
85
123
  files: {
86
124
  recording: path.basename(input.videoPath),
@@ -88,6 +126,7 @@ export function compose(input, opts = {}) {
88
126
  project: path.basename(projectPath),
89
127
  marks: path.basename(marksPath),
90
128
  video: `${input.name}.mp4`,
129
+ ...(voiceCues.length && safeVoice?.captions !== "off" ? { vtt: `${input.name}.vtt` } : {}),
91
130
  },
92
131
  frameTimes: input.frameTimes,
93
132
  };
@@ -137,6 +176,10 @@ export function rezoom(dir, overrides = {}) {
137
176
  frameSize: tl.frameSize,
138
177
  actions: tl.actions,
139
178
  captions: tl.captions,
179
+ blurs: tl.blurs,
180
+ arrows: tl.arrows,
181
+ images: tl.images,
182
+ voiceCues: tl.voiceCues,
140
183
  samples,
141
184
  frameTimes: tl.frameTimes ?? [],
142
185
  timings: tl.timings,
@@ -144,5 +187,6 @@ export function rezoom(dir, overrides = {}) {
144
187
  look: { ...tl.options?.look, ...overrides.look },
145
188
  trimIdle: trimIdle ?? false,
146
189
  cursor,
190
+ voice: tl.options?.voice,
147
191
  }, { keepProjectFrom: overrides.look ? undefined : projectPath });
148
192
  }
package/dist/idle.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * with OpenScreen trim regions, or speeds them up with speed regions.
5
5
  * Also maps recording times to output times through those regions.
6
6
  */
7
- import type { ActionRecord, Caption, CursorSample, SpeedRegion, TrimRegion, ZoomRegion } from "./types.ts";
7
+ import type { ActionRecord, Caption, CursorSample, SpeedRegion, TrimRegion, VoiceCue, ZoomRegion } from "./types.ts";
8
8
  export interface IdleOptions {
9
9
  /** Idle stretches shorter than this are left alone. */
10
10
  minMs: number;
@@ -23,6 +23,7 @@ export interface IdleInput {
23
23
  durationMs: number;
24
24
  actions: ActionRecord[];
25
25
  captions: Caption[];
26
+ voiceCues?: VoiceCue[];
26
27
  samples: CursorSample[];
27
28
  zoomRegions: ZoomRegion[];
28
29
  /** Screencast frame times; bursts of frames (animation, page load) count as activity. */
package/dist/idle.js CHANGED
@@ -19,12 +19,14 @@ function mergeIntervals(list) {
19
19
  export function busyIntervals(input, opts = {}) {
20
20
  const busy = [];
21
21
  for (const a of input.actions) {
22
- if (a.kind === "pause" || a.kind === "caption")
22
+ if (a.kind === "pause" || a.kind === "caption" || a.kind === "say" || a.kind === "blur")
23
23
  continue;
24
24
  busy.push([a.startMs - 150, a.endMs + 250]);
25
25
  }
26
26
  for (const c of input.captions)
27
27
  busy.push([c.startMs - 200, c.endMs + 200]);
28
+ for (const v of input.voiceCues ?? [])
29
+ busy.push([v.startMs - 150, v.endMs + 250]);
28
30
  for (const z of input.zoomRegions) {
29
31
  busy.push([z.startMs - ZOOM_IN_BEFORE_MS, z.startMs + ZOOM_IN_AFTER_MS]);
30
32
  busy.push([z.endMs - 100, z.endMs + ZOOM_OUT_AFTER_MS]);
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /** demoreel: scripted product demo videos (videos as code), rendered by OpenScreen's exporter. */
2
2
  export { type DryRunError, type DryRunOptions, type DryRunResult, type RecordOptions, type RecordResult, type Scenario, type ScenarioContext, defineScenario, dryRunScenario, recordScenario, resolveStorageState, } from "./record.ts";
3
- export { type ActionOptions, applyZoomAnchor, type ClickRippleOptions, DEFAULT_PACING, describeTarget, type HighlightOptions, type PacingOptions, type PressOptions, resolveTarget, Scene, type SceneClock, type Target, type TargetSpec, ZOOM_ATTRIBUTE, type ZoomOptions as SceneZoomOptions, } from "./scene.ts";
3
+ export { type ActionOptions, applyZoomAnchor, type ArrowOptions, type BlurOptions, type ClickRippleOptions, DEFAULT_PACING, describeTarget, type HighlightOptions, type ImageOptions, type PacingOptions, type PressOptions, resolveTarget, type SayOptions, Scene, type SceneClock, type Target, type TargetSpec, type VoiceCueHandle, ZOOM_ATTRIBUTE, type ZoomOptions as SceneZoomOptions, } from "./scene.ts";
4
+ export { buildVoiceVtt, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, type SayDeliveryOptions, type SynthesizedCue, type VoiceConfig, type VoiceFinding, VOICE_PROVIDERS, type VoiceProviderName, type VoiceSynthesizer, } from "./voice.ts";
4
5
  export { DEFAULT_ZOOM_OPTIONS, DEPTH_SCALES, deriveZoomRegions, depthForBox, normalizeDepth, type ZoomOptions } from "./zoom.ts";
5
6
  export { DEFAULT_IDLE_OPTIONS, deriveIdleRegions, idleIntervals, type IdleOptions, sourceToOutputMs } from "./idle.ts";
6
- export { buildCursorData, buildProject, type BuildProjectOptions, captionAnnotations, DEFAULT_LOOK, formatKeycap, keycapAnnotations, type KeyHudOptions, type KeyHudPosition, keycapRect, type LookOptions, normalizeSamples, type OpenScreenProject, writeProject, } from "./project.ts";
7
+ export { arrowAnnotations, blurAnnotations, buildCursorData, buildProject, type BuildProjectOptions, captionAnnotations, DEFAULT_LOOK, formatKeycap, imageAnnotations, keycapAnnotations, type KeyHudOptions, type KeyHudPosition, keycapRect, type LookOptions, normalizeSamples, type OpenScreenProject, resolveImageDataUrl, type WatermarkOptions, type WatermarkPosition, writeProject, } from "./project.ts";
7
8
  export { exportGif, type GifOptions, type GifResult } from "./gif.ts";
8
9
  export { buildMarks, type Marks, type MarkPoint, type MarkRegion, type MarkSpan, type MarksInput } from "./marks.ts";
9
10
  export { stageLayout, type StageLayout } from "./layout.ts";
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  /** demoreel: scripted product demo videos (videos as code), rendered by OpenScreen's exporter. */
2
2
  export { defineScenario, dryRunScenario, recordScenario, resolveStorageState, } from "./record.js";
3
3
  export { applyZoomAnchor, DEFAULT_PACING, describeTarget, resolveTarget, Scene, ZOOM_ATTRIBUTE, } from "./scene.js";
4
+ export { buildVoiceVtt, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, VOICE_PROVIDERS, } from "./voice.js";
4
5
  export { DEFAULT_ZOOM_OPTIONS, DEPTH_SCALES, deriveZoomRegions, depthForBox, normalizeDepth } from "./zoom.js";
5
6
  export { DEFAULT_IDLE_OPTIONS, deriveIdleRegions, idleIntervals, sourceToOutputMs } from "./idle.js";
6
- export { buildCursorData, buildProject, captionAnnotations, DEFAULT_LOOK, formatKeycap, keycapAnnotations, keycapRect, normalizeSamples, writeProject, } from "./project.js";
7
+ export { arrowAnnotations, blurAnnotations, buildCursorData, buildProject, captionAnnotations, DEFAULT_LOOK, formatKeycap, imageAnnotations, keycapAnnotations, keycapRect, normalizeSamples, resolveImageDataUrl, writeProject, } from "./project.js";
7
8
  export { exportGif } from "./gif.js";
8
9
  export { buildMarks } from "./marks.js";
9
10
  export { stageLayout } from "./layout.js";
package/dist/marks.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type NormRect, type StageLayout } from "./layout.ts";
2
2
  import { type LookOptions } from "./project.ts";
3
- import type { ActionRecord, Caption, SpeedRegion, TrimRegion, Viewport, ZoomRegion } from "./types.ts";
3
+ import type { ActionRecord, Caption, SpeedRegion, TrimRegion, Viewport, VoiceCue, ZoomRegion } from "./types.ts";
4
4
  export interface MarkPoint {
5
5
  t: number;
6
6
  x: number;
@@ -36,6 +36,7 @@ export interface MarksInput {
36
36
  durationMs: number;
37
37
  actions: ActionRecord[];
38
38
  captions: Caption[];
39
+ voiceCues?: VoiceCue[];
39
40
  zoomRegions: ZoomRegion[];
40
41
  trimRegions?: TrimRegion[];
41
42
  speedRegions?: SpeedRegion[];
package/dist/marks.js CHANGED
@@ -132,6 +132,15 @@ export function buildMarks(input) {
132
132
  for (const s of input.speedRegions ?? []) {
133
133
  marks.regions.push({ start: out(s.startMs), end: out(s.endMs), label: `${s.speed}x`, kind: "speed" });
134
134
  }
135
+ for (const v of input.voiceCues ?? []) {
136
+ const start = out(v.startMs);
137
+ marks.regions.push({
138
+ start,
139
+ end: Math.max(start, Math.min(endS, out(v.endMs))),
140
+ label: `${v.id}: ${v.text}`,
141
+ kind: "voice",
142
+ });
143
+ }
135
144
  for (const cap of input.captions) {
136
145
  const c = captionRect(cap.position ?? input.look.captionPosition);
137
146
  const start = out(cap.startMs);
package/dist/mcp.js CHANGED
@@ -18,6 +18,7 @@ import { loadScenario } from "./load.js";
18
18
  import { dryRunScenario, recordScenario, resolveStorageState } from "./record.js";
19
19
  import { renderProject, validateProject } from "./render.js";
20
20
  import { extractFrame, findFramesheet, reviewSheet } from "./sheet.js";
21
+ import { formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues } from "./voice.js";
21
22
  function pngBlock(filePath) {
22
23
  if (!fs.existsSync(filePath))
23
24
  return null;
@@ -64,7 +65,7 @@ const logStderr = (msg) => console.error(msg);
64
65
  /** Creates a configured demoreel `McpServer` instance (connect to stdio or any MCP transport). */
65
66
  export function createMcpServer() {
66
67
  const server = new McpServer({ name: "demoreel", version: readPackageVersion() }, {
67
- instructions: "demoreel records scripted Playwright product demos with smooth cursor motion, auto-zoom, captions, keycap HUDs, and OpenScreen MP4/GIF rendering. Follow the loop: inspect_page -> write scenario -> dry_run_scenario -> run_scenario -> inspect contact sheet (and inspect_frame for dense UI) -> rezoom or refine.",
68
+ instructions: "demoreel records scripted Playwright product demos with smooth cursor motion, auto-zoom, captions, keycap HUDs, voiceover narration (scene.say), and OpenScreen MP4/GIF rendering. Follow the loop: inspect_page -> write scenario -> dry_run_scenario (validates selectors and warms voice cache) -> run_scenario -> inspect contact sheet + voice lint (and inspect_frame for dense UI) -> rezoom or refine.",
68
69
  });
69
70
  server.registerTool("doctor", {
70
71
  title: "Check demoreel environment",
@@ -174,14 +175,27 @@ export function createMcpServer() {
174
175
  scenarioPath: z.string().describe("Path to the scenario file (*.scenario.ts/.mts/.mjs)."),
175
176
  viewport: z.string().optional().describe("Optional WxH viewport override."),
176
177
  state: z.string().optional().describe("Optional Playwright storageState JSON file path."),
178
+ voiceProvider: z.enum(["edge", "openai", "elevenlabs", "gemini", "cartesia", "deepgram"]).optional().describe("Override voiceover TTS provider."),
179
+ voice: z.string().optional().describe("Override voiceover voice ID."),
180
+ noVoice: z.boolean().optional().describe("Skip TTS synthesis during dry-run."),
177
181
  }),
178
182
  annotations: { readOnlyHint: true, openWorldHint: true },
179
- }, async ({ scenarioPath, viewport, state }) => {
183
+ }, async ({ scenarioPath, viewport, state, voiceProvider, voice, noVoice }) => {
180
184
  const file = path.resolve(scenarioPath);
181
185
  const scenario = await loadScenario(file);
182
186
  const overrides = {};
183
187
  if (viewport)
184
188
  overrides.viewport = parseSize(viewport);
189
+ if (voiceProvider || voice || noVoice) {
190
+ const vc = { ...scenario.voice };
191
+ if (voiceProvider)
192
+ vc.provider = voiceProvider;
193
+ if (voice)
194
+ vc.voice = voice;
195
+ if (noVoice)
196
+ vc.enabled = false;
197
+ overrides.voice = vc;
198
+ }
185
199
  let failureAria = "";
186
200
  const tmpPng = path.join(os.tmpdir(), `demoreel-fail-${Date.now()}.png`);
187
201
  try {
@@ -195,6 +209,9 @@ export function createMcpServer() {
195
209
  },
196
210
  });
197
211
  const lines = res.actions.map((a, i) => `${i}: ok ${a.kind}${a.label ? ` ${a.label}` : ""}`);
212
+ if (res.voiceCues.length) {
213
+ lines.push("", formatDryRunVoiceSummary(res.voiceCues));
214
+ }
198
215
  if (!res.ok && res.error) {
199
216
  lines.push(`FAIL action #${res.error.actionIndex}: ${res.error.message}`);
200
217
  if (failureAria)
@@ -228,6 +245,9 @@ export function createMcpServer() {
228
245
  frames: z.number().int().min(4).max(32).optional().default(12).describe("Number of contact-sheet tiles (default 12)."),
229
246
  state: z.string().optional().describe("Optional Playwright storageState JSON file path."),
230
247
  render: z.boolean().optional().default(true).describe("Render MP4 after recording (default true)."),
248
+ voiceProvider: z.enum(["edge", "openai", "elevenlabs", "gemini", "cartesia", "deepgram"]).optional().describe("Override voiceover TTS provider."),
249
+ voice: z.string().optional().describe("Override voiceover voice ID."),
250
+ noVoice: z.boolean().optional().describe("Disable voiceover synthesis for this run."),
231
251
  }),
232
252
  annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
233
253
  }, async (args, ctx) => {
@@ -241,6 +261,16 @@ export function createMcpServer() {
241
261
  overrides.pacing = { ...scenario.pacing, speed: args.speed };
242
262
  if (args.trimIdle !== undefined)
243
263
  overrides.trimIdle = args.trimIdle && (scenario.trimIdle || true);
264
+ if (args.voiceProvider || args.voice || args.noVoice) {
265
+ const vc = { ...scenario.voice };
266
+ if (args.voiceProvider)
267
+ vc.provider = args.voiceProvider;
268
+ if (args.voice)
269
+ vc.voice = args.voice;
270
+ if (args.noVoice)
271
+ vc.enabled = false;
272
+ overrides.voice = vc;
273
+ }
244
274
  const outDir = path.resolve(args.outDir ?? path.join("out", scenario.name));
245
275
  progress(5, `Recording "${scenario.name}"...`);
246
276
  const rec = await recordScenario(scenario, {
@@ -282,6 +312,14 @@ export function createMcpServer() {
282
312
  summary.bytes = rendered.bytes;
283
313
  summary.gpu = rendered.gpu;
284
314
  summary.renderMs = rendered.renderMs;
315
+ if (rendered.audioMuxed)
316
+ summary.audioMuxed = true;
317
+ if (rendered.vttPath)
318
+ summary.vttPath = rendered.vttPath;
319
+ if (rec.timeline.voiceCues?.length) {
320
+ summary.voiceFindings = lintVoiceCues(rec.timeline.voiceCues, rec.timeline.outputDurationMs, rec.timeline.trimRegions, rec.timeline.speedRegions);
321
+ summary.voiceSummary = formatVoiceSummary(rec.timeline.voiceCues, rec.timeline.outputDurationMs, rec.timeline.trimRegions, rec.timeline.speedRegions);
322
+ }
285
323
  if (args.gif) {
286
324
  progress(92, "Exporting GIF...");
287
325
  const g = await exportGif(mp4);