@anvpx/motion-cli 0.1.0 → 0.1.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/README.md +1 -1
- package/dist/approval/hash.js +18 -5
- package/dist/plugin/install.d.ts +2 -2
- package/dist/plugin/install.js +1 -1
- package/dist/preview/command.js +125 -16
- package/dist/preview/manifest.d.ts +9 -0
- package/dist/scene/author.js +37 -18
- package/dist/voice/command.js +32 -4
- package/dist/voice/run.d.ts +8 -0
- package/dist/voice/run.js +35 -11
- package/dist/workflow/draft.js +18 -4
- package/dist/workflow/render.js +20 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ Add to the repo-root `package.json`:
|
|
|
105
105
|
|
|
106
106
|
## Install qualification (DL-01)
|
|
107
107
|
|
|
108
|
-
Install is the npm package install plus `mk doctor` hints; `mk plugin install --out <dir>` stays a separate explicit step, never part of npm install. Qualify with `node scripts/qualify-pack.mjs --json`: fresh pack records full inventory/SHA (`tarball.members`, `sha256`, bytes, `node`/`pnpm`/`npm`/`tar` versions, packed `hyperframes` pin vs root pin, `unpublishedInternals`), installs in an empty external consumer with no workspace fallback (`pnpm-workspace.yaml`/`packages/` absent), then runs native `doctor`/`catalog`/`template list`/`template validate explain` plus `new`/`validate`/`build`/`preview --stills 1 --budget-sec 20`/`approve` smoke with missing-target negatives; final `gated-render`/`verify` stay `NOT_RUN` without an explicit yes (do not render). Registry/marketplace stay `NOT_RUN`; isolated install is currently `BLOCKED` (`404` on unpublished `0.0.0` internals, `base: BLOCKED`; see DISTRIBUTION MK-080 choices A/B). Missing guide/index/font/icon/bed, source fallback reachable, wrong pin, broken install, missing venv/WAV all fail closed with actionable nonzero diagnostics (`reinstall @anvpx/motion`, `
|
|
108
|
+
Install is the npm package install plus `mk doctor` hints; `mk plugin install --out <dir>` stays a separate explicit step, never part of npm install. Qualify with `node scripts/qualify-pack.mjs --json`: fresh pack records full inventory/SHA (`tarball.members`, `sha256`, bytes, `node`/`pnpm`/`npm`/`tar` versions, packed `hyperframes` pin vs root pin, `unpublishedInternals`), installs in an empty external consumer with no workspace fallback (`pnpm-workspace.yaml`/`packages/` absent), then runs native `doctor`/`catalog`/`template list`/`template validate explain` plus `new`/`validate`/`build`/`preview --stills 1 --budget-sec 20`/`approve` smoke with missing-target negatives; final `gated-render`/`verify` stay `NOT_RUN` without an explicit yes (do not render). Registry/marketplace stay `NOT_RUN`; isolated install is currently `BLOCKED` (`404` on unpublished `0.0.0` internals, `base: BLOCKED`; see DISTRIBUTION MK-080 choices A/B). Missing guide/index/font/icon/bed, source fallback reachable, wrong pin, broken install, missing venv/WAV all fail closed with actionable nonzero diagnostics (`reinstall @anvpx/motion`, `scaffold`, `mk doctor`, `py -3.12 -m venv .venv-voice`).
|
|
109
109
|
|
|
110
110
|
## Voice and music delivery (DL-01)
|
|
111
111
|
|
package/dist/approval/hash.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
-
import { AUDIO_DIR_NAME, normaliseRef as buildNormaliseRef, clipsFromManifest, isContiguous, parseAudioManifest, readRelativeClosure, resolveSceneDir, } from "@anvpx/motion-build";
|
|
4
|
+
import { AUDIO_DIR_NAME, normaliseRef as buildNormaliseRef, clipsFromManifest, isContiguous, parseAudioManifest, placementsFromTimeline, readRelativeClosure, resolveSceneDir, resolveTimeline, validateStoryboardFull, } from "@anvpx/motion-build";
|
|
5
5
|
import { parseMusicBed } from "@anvpx/motion-schema";
|
|
6
6
|
import { sceneContainment } from "../storyboard/containment.js";
|
|
7
7
|
export const MK_DIR = ".mk";
|
|
@@ -267,7 +267,7 @@ const readLedgerSha = async (host, ledgerPath) => {
|
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
269
|
/** Resolves --audio TimingManifest plus every sibling wav into refs + mix. Fails closed. */
|
|
270
|
-
const readAudioRefs = async (host, projectDir, audioManifestPath) => {
|
|
270
|
+
const readAudioRefs = async (host, projectDir, audioManifestPath, storyboardJson) => {
|
|
271
271
|
let text;
|
|
272
272
|
try {
|
|
273
273
|
text = await host.readText(audioManifestPath);
|
|
@@ -287,7 +287,20 @@ const readAudioRefs = async (host, projectDir, audioManifestPath) => {
|
|
|
287
287
|
throw new Error(`invalid --audio manifest ${audioManifestPath}: ${parsed.problems.join("; ")}`);
|
|
288
288
|
}
|
|
289
289
|
const audioDir = join(dirname(resolve(audioManifestPath)), AUDIO_DIR_NAME);
|
|
290
|
-
|
|
290
|
+
// The manifest is a non-overlapping voice sequence; the film may start a
|
|
291
|
+
// scene 0.5 s early for a transition. Bind the placement the renderer will
|
|
292
|
+
// actually use, not the voice sequence's cumulative start.
|
|
293
|
+
const valid = validateStoryboardFull(storyboardJson);
|
|
294
|
+
if (!valid.ok) {
|
|
295
|
+
throw new Error(`--audio manifest cannot be placed: the storyboard is invalid`);
|
|
296
|
+
}
|
|
297
|
+
const timeline = resolveTimeline(valid.value, parsed.manifest);
|
|
298
|
+
if (!timeline.ok) {
|
|
299
|
+
throw new Error(`--audio manifest ${audioManifestPath} does not fit the storyboard: ` +
|
|
300
|
+
timeline.errors.map((error) => error.message).join("; "));
|
|
301
|
+
}
|
|
302
|
+
const placements = placementsFromTimeline(timeline.value);
|
|
303
|
+
const clips = clipsFromManifest(parsed.manifest, audioDir, placements);
|
|
291
304
|
if (clips.length === 0) {
|
|
292
305
|
throw new Error(`--audio manifest ${audioManifestPath} has no scenes; nothing to mix`);
|
|
293
306
|
}
|
|
@@ -314,7 +327,7 @@ const readAudioRefs = async (host, projectDir, audioManifestPath) => {
|
|
|
314
327
|
throw new Error(`--audio manifest ${audioManifestPath} escapes the project (escape)`);
|
|
315
328
|
}
|
|
316
329
|
const audioManifest = { path: manifestRel, sha256: sha256(text) };
|
|
317
|
-
const mode = clips.length === 1 ? "single" : isContiguous(
|
|
330
|
+
const mode = clips.length === 1 ? "single" : isContiguous(clips) ? "concat" : "adelay";
|
|
318
331
|
return { audio, audioManifest, mix: { mode, clips: mixClips } };
|
|
319
332
|
};
|
|
320
333
|
/** Resolves --music bed wav plus volume and license-evidence receipt. Fails closed. */
|
|
@@ -392,7 +405,7 @@ export async function buildApprovalInputManifest(host, storyboard, opts = {}) {
|
|
|
392
405
|
audio: [],
|
|
393
406
|
};
|
|
394
407
|
}
|
|
395
|
-
const { audio, audioManifest, mix } = await readAudioRefs(host, projectDir, opts.audioManifest);
|
|
408
|
+
const { audio, audioManifest, mix } = await readAudioRefs(host, projectDir, opts.audioManifest, parsed);
|
|
396
409
|
const music = opts.music === undefined
|
|
397
410
|
? undefined
|
|
398
411
|
: await readMusicRefs(host, projectDir, opts.music, opts.musicVolume, opts.musicLicense);
|
package/dist/plugin/install.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ import type { Command } from "../types.ts";
|
|
|
12
12
|
* at real versions) or choiceB (bundle into one tarball); either lands with
|
|
13
13
|
* a version bump of core manifest + this pin + plugin.json together.
|
|
14
14
|
*/
|
|
15
|
-
export declare const PINNED_CORE_VERSION = "0.1.
|
|
16
|
-
export declare const PINNED_NPX = "npx -y @anvpx/motion@0.1.
|
|
15
|
+
export declare const PINNED_CORE_VERSION = "0.1.2";
|
|
16
|
+
export declare const PINNED_NPX = "npx -y @anvpx/motion@0.1.2";
|
|
17
17
|
/** Skill file whose sha256 must survive `plugin install` byte for byte. */
|
|
18
18
|
export declare const PLUGIN_SKILL: string;
|
|
19
19
|
export interface PluginEnv {
|
package/dist/plugin/install.js
CHANGED
|
@@ -17,7 +17,7 @@ import { EXIT } from "../exit-codes.js";
|
|
|
17
17
|
* at real versions) or choiceB (bundle into one tarball); either lands with
|
|
18
18
|
* a version bump of core manifest + this pin + plugin.json together.
|
|
19
19
|
*/
|
|
20
|
-
export const PINNED_CORE_VERSION = "0.1.
|
|
20
|
+
export const PINNED_CORE_VERSION = "0.1.2";
|
|
21
21
|
export const PINNED_NPX = `npx -y @anvpx/motion@${PINNED_CORE_VERSION}`;
|
|
22
22
|
/** Skill file whose sha256 must survive `plugin install` byte for byte. */
|
|
23
23
|
export const PLUGIN_SKILL = join("skills", "motion-kit", "SKILL.md");
|
package/dist/preview/command.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { basename, dirname, join, resolve } from "node:path";
|
|
3
3
|
import { validateMusicBed } from "@anvpx/motion-audio";
|
|
4
|
-
import { AUDIO_DIR_NAME, CUSTOM_SCENE_TYPE, clipsFromManifest, frozenClips, frozenCopyProblems, frozenMusic, isContiguous, mixAtDeliveryLevel, parseAudioManifest, readRelativeClosure, resolveSceneDir, resolveTimeline, validateStoryboardFull, } from "@anvpx/motion-build";
|
|
4
|
+
import { AUDIO_DIR_NAME, CUSTOM_SCENE_TYPE, clipsFromManifest, frozenClips, frozenCopyProblems, frozenMusic, isContiguous, mixAtDeliveryLevel, parseAudioManifest, placementsFromTimeline, readRelativeClosure, resolveSceneDir, resolveTimeline, validateStoryboardFull, } from "@anvpx/motion-build";
|
|
5
5
|
import { buildApprovalInputManifest, hashApprovalInput, storyboardHash, } from "../approval/hash.js";
|
|
6
6
|
import { parseFlags, requireStoryboard, textFlag, usageError } from "../args.js";
|
|
7
7
|
import { EXIT } from "../exit-codes.js";
|
|
@@ -18,25 +18,29 @@ import { CHECKLIST, defaultOut, PREVIEW_JSON, packDir, } from "./manifest.js";
|
|
|
18
18
|
import { clearPngs, contactSheet, listPngs, nameStills, } from "./pack.js";
|
|
19
19
|
import { CLIP_MAX_SEC, CLIP_SCENE_SEC, capClip, DARK_COUNT, distinctPicks, sceneInfos, shouldRunClip, stillCandidates, stillPlan, } from "./plan.js";
|
|
20
20
|
import { readProvenance, resolvePair } from "./provenance.js";
|
|
21
|
-
const USAGE = `mk preview <storyboard.json> [--stills 6 | --every] [--budget-sec 90] [--out <dir>] [--assets <dir>] [--ledger <assets.json>] [--audio <manifest>] [--music <bed.wav>] [--music-volume <n>] [--music-license <file>] [--json]
|
|
21
|
+
const USAGE = `mk preview <storyboard.json> [--stills 6 | --every] [--full] [--budget-sec 90] [--out <dir>] [--assets <dir>] [--ledger <assets.json>] [--audio <manifest>] [--allow-silent] [--music <bed.wav>] [--music-volume <n>] [--music-license <file>] [--json]
|
|
22
22
|
|
|
23
23
|
Build the proposal pack the user approves, into <out>/<name>.preview, <name> = the storyboard file name without .json (default <out> = <storyboard dir>/out):
|
|
24
24
|
preview.json hash, template, frame, scenes, stills, lint, estimate, approval checklist
|
|
25
25
|
contact.png one image tiling the stills (look at this, show it to the user)
|
|
26
26
|
stills/NN-<scene>-<theme>.png
|
|
27
|
-
clip.mp4
|
|
27
|
+
clip.mp4 --full: every scene at its real duration, 960 px, ${DRAFT_FPS} fps;
|
|
28
|
+
otherwise each scene capped at ${CLIP_SCENE_SEC} s and the whole trailer <= ${CLIP_MAX_SEC} s
|
|
28
29
|
Stills: first scene, last scene, each scene type once (an overlay off screen at its scene's still counts as a scene), then an even spread; ${DARK_COUNT} extra stills in the paired theme when
|
|
29
30
|
the template has one. Order of work: stills, contact sheet, clip. If --budget-sec runs out the clip is skipped
|
|
30
31
|
(preview.json says so, exit 0); stills are never skipped. Validation or lint errors exit 2.
|
|
31
32
|
--stills n base stills (1-24, default 6)
|
|
32
33
|
--every one still per base scene at 70% of it (instead of --stills); overlays show where they cover that moment
|
|
33
|
-
--
|
|
34
|
+
--full render the complete board as one continuous clip; no trailer sampling
|
|
35
|
+
--budget-sec n time budget (default 90; --full raises the default to 900)
|
|
34
36
|
--audio <manifest>
|
|
35
37
|
voice TimingManifest: mix each scene's wav (the manifest's sibling
|
|
36
38
|
audio/ dir, <id>.wav) under clip.mp4 with the same mix args as
|
|
37
39
|
the final render; absent means a silent clip (audible:false).
|
|
38
40
|
The audiovisual binding (manifest + wavs + mix) enters
|
|
39
41
|
inputManifestSha256.
|
|
42
|
+
--allow-silent permit a silent preview when the board has narration; only
|
|
43
|
+
when the user explicitly wants silent output
|
|
40
44
|
--music <bed.wav> opt-in CC0 bed ducked under narration (needs --audio);
|
|
41
45
|
same buildMusicMixArgs as final; volume via --music-volume,
|
|
42
46
|
license receipt via --music-license. Bed + volume + licenseEvidenceSha256
|
|
@@ -49,11 +53,13 @@ Scratch builds live in <out>/<name>.preview-work. Then show the pack and, after
|
|
|
49
53
|
const FLAGS = {
|
|
50
54
|
stills: { type: "string" },
|
|
51
55
|
every: { type: "boolean" },
|
|
56
|
+
full: { type: "boolean" },
|
|
52
57
|
"budget-sec": { type: "string" },
|
|
53
58
|
out: { type: "string" },
|
|
54
59
|
assets: { type: "string" },
|
|
55
60
|
ledger: { type: "string" },
|
|
56
61
|
audio: { type: "string" },
|
|
62
|
+
"allow-silent": { type: "boolean" },
|
|
57
63
|
music: { type: "string" },
|
|
58
64
|
"music-volume": { type: "string" },
|
|
59
65
|
"music-license": { type: "string" },
|
|
@@ -88,17 +94,20 @@ function stillCount(flags, every, io) {
|
|
|
88
94
|
}
|
|
89
95
|
function readOptions(flags, storyboard, io) {
|
|
90
96
|
const every = flags.every === true;
|
|
97
|
+
const full = flags.full === true;
|
|
91
98
|
const counted = stillCount(flags, every, io);
|
|
92
99
|
if ("code" in counted)
|
|
93
100
|
return counted.code;
|
|
94
101
|
const stills = counted.count;
|
|
95
|
-
const
|
|
102
|
+
const defaultBudget = full ? 900 : DEFAULT_BUDGET_SEC;
|
|
103
|
+
const budgetSec = Number(textFlag(flags, "budget-sec") ?? defaultBudget);
|
|
96
104
|
if (!Number.isFinite(budgetSec) || budgetSec <= 0) {
|
|
97
105
|
return usageError("preview", USAGE, "--budget-sec must be a positive number", io).code;
|
|
98
106
|
}
|
|
99
107
|
const assets = textFlag(flags, "assets");
|
|
100
108
|
const ledger = textFlag(flags, "ledger");
|
|
101
109
|
const audio = textFlag(flags, "audio");
|
|
110
|
+
const allowSilent = flags["allow-silent"] === true;
|
|
102
111
|
const music = textFlag(flags, "music");
|
|
103
112
|
const musicVolumeRaw = textFlag(flags, "music-volume");
|
|
104
113
|
const musicLicense = textFlag(flags, "music-license");
|
|
@@ -117,6 +126,7 @@ function readOptions(flags, storyboard, io) {
|
|
|
117
126
|
return {
|
|
118
127
|
stills,
|
|
119
128
|
every,
|
|
129
|
+
full,
|
|
120
130
|
budgetSec,
|
|
121
131
|
out: resolve(textFlag(flags, "out") ?? defaultOut(storyboard)),
|
|
122
132
|
extra: [
|
|
@@ -126,6 +136,7 @@ function readOptions(flags, storyboard, io) {
|
|
|
126
136
|
...(assets === undefined ? {} : { assetsDir: resolve(assets) }),
|
|
127
137
|
...(ledger === undefined ? {} : { ledgerPath: ledger }),
|
|
128
138
|
...(audio === undefined ? {} : { audioManifest: audio }),
|
|
139
|
+
allowSilent,
|
|
129
140
|
...(music === undefined ? {} : { musicPath: music }),
|
|
130
141
|
...(musicVolumeRaw === undefined ? {} : { musicVolume: Number(musicVolumeRaw) }),
|
|
131
142
|
...(musicLicense === undefined ? {} : { musicLicensePath: musicLicense }),
|
|
@@ -256,17 +267,22 @@ async function makeAudibleClip(io, board, projectDir, work, pack, extra, clock,
|
|
|
256
267
|
const fallback = resolveTimeline(board);
|
|
257
268
|
const sec = voiceSec ?? (fallback.ok ? fallback.value.total : 0);
|
|
258
269
|
return {
|
|
259
|
-
result: { status: "ok", file: "clip.mp4", sec },
|
|
270
|
+
result: { status: "ok", file: "clip.mp4", sec, full: true },
|
|
260
271
|
msPerFrame: ms / Math.max(1, Math.round(sec * DRAFT_FPS)),
|
|
261
272
|
};
|
|
262
273
|
}
|
|
263
|
-
async function makeClip(io, board, projectDir, work, pack, extra, clock, audioManifest, origin) {
|
|
264
|
-
// With --audio the clip is the full
|
|
265
|
-
// Without --audio keep the capped trailer: byte-identical to today.
|
|
274
|
+
async function makeClip(io, board, projectDir, work, pack, extra, clock, audioManifest, origin, full) {
|
|
275
|
+
// With --audio or --full the clip is the full review, not a capped trailer.
|
|
266
276
|
if (audioManifest !== undefined) {
|
|
267
277
|
return makeAudibleClip(io, board, projectDir, work, pack, extra, clock, audioManifest, origin);
|
|
268
278
|
}
|
|
269
|
-
const plan =
|
|
279
|
+
const plan = full
|
|
280
|
+
? (() => {
|
|
281
|
+
const stripped = stripNarration(board);
|
|
282
|
+
const timeline = resolveTimeline(stripped);
|
|
283
|
+
return { storyboard: stripped, totalSec: timeline.ok ? timeline.value.total : 0 };
|
|
284
|
+
})()
|
|
285
|
+
: capClip(board);
|
|
270
286
|
const clip = await scratch(io, work, "clip", plan.storyboard, projectDir, [], origin);
|
|
271
287
|
const quiet = captured(io);
|
|
272
288
|
const began = clock();
|
|
@@ -280,7 +296,7 @@ async function makeClip(io, board, projectDir, work, pack, extra, clock, audioMa
|
|
|
280
296
|
await io.host.copyFile(join(clip.project, "draft.mp4"), join(pack, "clip.mp4"));
|
|
281
297
|
const frames = Math.max(1, Math.round(plan.totalSec * DRAFT_FPS));
|
|
282
298
|
return {
|
|
283
|
-
result: { status: "ok", file: "clip.mp4", sec: plan.totalSec },
|
|
299
|
+
result: { status: "ok", file: "clip.mp4", sec: plan.totalSec, full },
|
|
284
300
|
msPerFrame: ms / frames,
|
|
285
301
|
};
|
|
286
302
|
}
|
|
@@ -289,13 +305,16 @@ const summary = (m, pack, storyboard, overlays) => {
|
|
|
289
305
|
const from = m.template === null
|
|
290
306
|
? "free storyboard"
|
|
291
307
|
: `template ${m.template} ${m.blueprint} style ${m.style}`;
|
|
292
|
-
const clip = m.clip.status === "ok" ? `clip ${m.clip.sec}s` : "clip skipped";
|
|
308
|
+
const clip = m.clip.status === "ok" ? `clip ${m.clip.sec}s${m.clip.full ? " full" : ""}` : "clip skipped";
|
|
309
|
+
const continuity = m.continuity.status === "warn"
|
|
310
|
+
? ` | continuity WARN jump ${m.continuity.maxJump ?? "?"} at ${m.continuity.atSec ?? "?"}s`
|
|
311
|
+
: "";
|
|
293
312
|
const est = m.estFullRenderSec === null
|
|
294
313
|
? "est render n/a"
|
|
295
314
|
: `est render ~${Math.max(1, Math.round(m.estFullRenderSec / 60))}m`;
|
|
296
315
|
return (`preview ok | ${from} | ${m.scenes.length} scenes + ${overlays} overlays ${m.totalSec}s ${m.frame.width}x${m.frame.height} | pack ${pack} | ` +
|
|
297
316
|
`contact.png ${m.stills.length - paired} stills (+${paired} paired) ${clip} | ${est} (estimate) | ` +
|
|
298
|
-
`lint ${m.lint.errors} err ${m.lint.warnings} warn | approve: mk approve ${storyboard}\n`);
|
|
317
|
+
`lint ${m.lint.errors} err ${m.lint.warnings} warn${continuity} | approve: mk approve ${storyboard}\n`);
|
|
299
318
|
};
|
|
300
319
|
const round = (value) => Math.round(value * 100) / 100;
|
|
301
320
|
/** Reads, validates and lints the storyboard; findings go to stderr with exit 2. */
|
|
@@ -365,8 +384,8 @@ async function clipOrSkip(ctx, stillsMs) {
|
|
|
365
384
|
const { io, pack, options, clock, began } = ctx;
|
|
366
385
|
await io.host.remove(join(pack, "clip.mp4"));
|
|
367
386
|
const elapsed = clock() - began;
|
|
368
|
-
if (shouldRunClip(elapsed, stillsMs, options.budgetSec * MS)) {
|
|
369
|
-
return makeClip(io, ctx.board, ctx.projectDir, ctx.work, pack, options.extra, clock, options.audioManifest, ctx.storyboard);
|
|
387
|
+
if (options.full || shouldRunClip(elapsed, stillsMs, options.budgetSec * MS)) {
|
|
388
|
+
return makeClip(io, ctx.board, ctx.projectDir, ctx.work, pack, options.extra, clock, options.audioManifest, ctx.storyboard, options.full);
|
|
370
389
|
}
|
|
371
390
|
const used = `${Math.round(elapsed / MS)} s used of ${options.budgetSec} s`;
|
|
372
391
|
return {
|
|
@@ -374,6 +393,71 @@ async function clipOrSkip(ctx, stillsMs) {
|
|
|
374
393
|
msPerFrame: undefined,
|
|
375
394
|
};
|
|
376
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* Best-effort luminance scan of the produced clip. A large jump at a cut or a
|
|
398
|
+
* near-white/near-black frame is a warning, not a hard failure: a deliberate
|
|
399
|
+
* hard cut can be valid, but the skill must design or justify it.
|
|
400
|
+
*/
|
|
401
|
+
async function measureContinuity(io, clipFile) {
|
|
402
|
+
const unknown = {
|
|
403
|
+
status: "unknown",
|
|
404
|
+
maxJump: null,
|
|
405
|
+
atSec: null,
|
|
406
|
+
brightFrames: 0,
|
|
407
|
+
darkFrames: 0,
|
|
408
|
+
};
|
|
409
|
+
const res = await io.run("ffmpeg", [
|
|
410
|
+
"-hide_banner",
|
|
411
|
+
"-nostats",
|
|
412
|
+
"-i",
|
|
413
|
+
clipFile,
|
|
414
|
+
"-vf",
|
|
415
|
+
"signalstats,metadata=print:key=lavfi.signalstats.YAVG",
|
|
416
|
+
"-f",
|
|
417
|
+
"null",
|
|
418
|
+
"-",
|
|
419
|
+
]);
|
|
420
|
+
const frames = [];
|
|
421
|
+
const lines = (res.stderr || res.stdout).split(/\r?\n/);
|
|
422
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
423
|
+
const time = /pts_time:([0-9.]+)/.exec(lines[i] ?? "");
|
|
424
|
+
if (time === null)
|
|
425
|
+
continue;
|
|
426
|
+
const avg = /YAVG=([0-9.]+)/.exec(lines[i + 1] ?? "");
|
|
427
|
+
if (avg === null)
|
|
428
|
+
continue;
|
|
429
|
+
frames.push({ t: Number(time[1]), y: Number(avg[1]) });
|
|
430
|
+
}
|
|
431
|
+
if (frames.length === 0)
|
|
432
|
+
return unknown;
|
|
433
|
+
let maxJump = 0;
|
|
434
|
+
let atSec = 0;
|
|
435
|
+
let brightFrames = 0;
|
|
436
|
+
let darkFrames = 0;
|
|
437
|
+
for (let i = 0; i < frames.length; i += 1) {
|
|
438
|
+
const frame = frames[i];
|
|
439
|
+
const previous = frames[i - 1];
|
|
440
|
+
if (frame.y >= 235)
|
|
441
|
+
brightFrames += 1;
|
|
442
|
+
if (frame.y <= 10)
|
|
443
|
+
darkFrames += 1;
|
|
444
|
+
if (previous !== undefined) {
|
|
445
|
+
const jump = Math.abs(frame.y - previous.y);
|
|
446
|
+
if (jump > maxJump) {
|
|
447
|
+
maxJump = jump;
|
|
448
|
+
atSec = frame.t;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
const status = maxJump > 70 || brightFrames > 0 || darkFrames > 0 ? "warn" : "ok";
|
|
453
|
+
return {
|
|
454
|
+
status,
|
|
455
|
+
maxJump: round(maxJump),
|
|
456
|
+
atSec: round(atSec),
|
|
457
|
+
brightFrames,
|
|
458
|
+
darkFrames,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
377
461
|
const stillRow = (s) => ({
|
|
378
462
|
file: `stills/${s.name}`,
|
|
379
463
|
scene: s.pick.id,
|
|
@@ -422,6 +506,7 @@ function manifestOf(ctx, facts) {
|
|
|
422
506
|
stills: facts.named.map(stillRow),
|
|
423
507
|
contact: "contact.png",
|
|
424
508
|
clip: clip.result,
|
|
509
|
+
continuity: facts.continuity,
|
|
425
510
|
estFullRenderSec: estimate,
|
|
426
511
|
estimateNote: ESTIMATE_NOTE,
|
|
427
512
|
lint: {
|
|
@@ -450,6 +535,11 @@ async function start(args, io, clock) {
|
|
|
450
535
|
const loaded = await loadBoard(storyboard, io);
|
|
451
536
|
if (typeof loaded === "number")
|
|
452
537
|
return loaded;
|
|
538
|
+
const narrated = loaded.board.scenes.some((scene) => scene.layer !== "overlay" && (scene.narration?.trim() ?? "") !== "");
|
|
539
|
+
if (narrated && options.audioManifest === undefined && !options.allowSilent) {
|
|
540
|
+
io.stderr("mk preview: this board has narration but no --audio. Run `mk voice <storyboard> --preset <id>`, then preview with --audio <manifest> --full; pass --allow-silent only when the user explicitly wants silent output.\n");
|
|
541
|
+
return EXIT.USAGE;
|
|
542
|
+
}
|
|
453
543
|
const ctx = {
|
|
454
544
|
...loaded,
|
|
455
545
|
io,
|
|
@@ -521,7 +611,13 @@ const mixPreviewClip = async (io, pack, work, audioManifest, storyboard, expecte
|
|
|
521
611
|
return EXIT.USAGE;
|
|
522
612
|
}
|
|
523
613
|
const audioDir = join(dirname(resolve(audioManifest)), AUDIO_DIR_NAME);
|
|
524
|
-
|
|
614
|
+
// Place the voice sequence on the film timeline (transitions start scenes
|
|
615
|
+
// early), not on the manifest's cumulative starts.
|
|
616
|
+
const boardLoaded = await readJsonFile(storyboard, io.host);
|
|
617
|
+
const validBoard = boardLoaded.ok ? validateStoryboardFull(boardLoaded.value) : undefined;
|
|
618
|
+
const timeline = validBoard?.ok === true ? resolveTimeline(validBoard.value, parsed.manifest) : undefined;
|
|
619
|
+
const placements = timeline?.ok === true ? placementsFromTimeline(timeline.value) : undefined;
|
|
620
|
+
const clips = clipsFromManifest(parsed.manifest, audioDir, placements);
|
|
525
621
|
if (clips.length === 0) {
|
|
526
622
|
io.stderr(`mk preview: --audio manifest has no scenes; nothing to mix; ${rerun}\n`);
|
|
527
623
|
return EXIT.USAGE;
|
|
@@ -685,6 +781,9 @@ export const makePreviewCommand = (env = defaultEnv, clock = () => performance.n
|
|
|
685
781
|
if (typeof started === "number")
|
|
686
782
|
return started;
|
|
687
783
|
const { ctx, json } = started;
|
|
784
|
+
// Never leave a stale manifest from an interrupted earlier run next to a
|
|
785
|
+
// different clip. The new manifest is written only after all media exists.
|
|
786
|
+
await io.host.remove(join(ctx.pack, PREVIEW_JSON));
|
|
688
787
|
const { storyboard } = ctx;
|
|
689
788
|
const provenance = await readProvenance(io.host, storyboard);
|
|
690
789
|
const pair = resolvePair(env(), io, provenance, ctx.board.meta.theme);
|
|
@@ -703,6 +802,15 @@ export const makePreviewCommand = (env = defaultEnv, clock = () => performance.n
|
|
|
703
802
|
if (packed !== EXIT.OK)
|
|
704
803
|
return packed;
|
|
705
804
|
const clip = await clipOrSkip(ctx, spent.ms);
|
|
805
|
+
const continuity = clip.result.status === "ok"
|
|
806
|
+
? await measureContinuity(io, join(ctx.pack, "clip.mp4"))
|
|
807
|
+
: {
|
|
808
|
+
status: "unknown",
|
|
809
|
+
maxJump: null,
|
|
810
|
+
atSec: null,
|
|
811
|
+
brightFrames: 0,
|
|
812
|
+
darkFrames: 0,
|
|
813
|
+
};
|
|
706
814
|
let audioMix;
|
|
707
815
|
if (ctx.options.audioManifest === undefined) {
|
|
708
816
|
audioMix = SILENT_AUDIO_MIX;
|
|
@@ -746,6 +854,7 @@ export const makePreviewCommand = (env = defaultEnv, clock = () => performance.n
|
|
|
746
854
|
pair,
|
|
747
855
|
named,
|
|
748
856
|
clip,
|
|
857
|
+
continuity,
|
|
749
858
|
audioMix,
|
|
750
859
|
});
|
|
751
860
|
const text = `${JSON.stringify(manifest, null, 2)}\n`;
|
|
@@ -11,6 +11,7 @@ export type ClipResult = {
|
|
|
11
11
|
status: "ok";
|
|
12
12
|
file: string;
|
|
13
13
|
sec: number;
|
|
14
|
+
full?: boolean;
|
|
14
15
|
} | {
|
|
15
16
|
status: "skipped";
|
|
16
17
|
reason: string;
|
|
@@ -69,6 +70,14 @@ export interface PreviewManifest {
|
|
|
69
70
|
stills: StillRow[];
|
|
70
71
|
contact: string | null;
|
|
71
72
|
clip: ClipResult;
|
|
73
|
+
/** Best-effort picture continuity scan of clip.mp4; unknown when no frames were read. */
|
|
74
|
+
continuity: {
|
|
75
|
+
status: "ok" | "warn" | "unknown";
|
|
76
|
+
maxJump: number | null;
|
|
77
|
+
atSec: number | null;
|
|
78
|
+
brightFrames: number;
|
|
79
|
+
darkFrames: number;
|
|
80
|
+
};
|
|
72
81
|
/** Audible binding: voice manifest + wav hashes the clip was mixed from. Silent packs record audible:false. */
|
|
73
82
|
audioMix: {
|
|
74
83
|
manifestSha: string | null;
|
package/dist/scene/author.js
CHANGED
|
@@ -20,7 +20,7 @@ const NEW_FLAGS = {
|
|
|
20
20
|
force: { type: "boolean" },
|
|
21
21
|
};
|
|
22
22
|
const SCENE_JS = `// @ts-check
|
|
23
|
-
import {
|
|
23
|
+
import { ease, interpolate, progress } from "../../runtime/compose.js";
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Authored scene: seek(t) must be a pure function of t.
|
|
@@ -29,33 +29,52 @@ import { mountTimeline } from "../../runtime/mount.js";
|
|
|
29
29
|
* @type {import("../../runtime/mount.js").CreateScene}
|
|
30
30
|
*/
|
|
31
31
|
export function createScene(root, config, ctx) {
|
|
32
|
-
|
|
32
|
+
const element = /** @type {HTMLElement | null} */ (root.querySelector(".authored-element"));
|
|
33
|
+
if (!element) throw new Error("authored scene: missing .authored-element");
|
|
34
|
+
// Replace the markup, layout and these values with the direction's composition.
|
|
35
|
+
// Derive every animated value on EVERY seek, including backward seeks.
|
|
36
|
+
const seek = (t) => {
|
|
37
|
+
const amount = ease("out", progress(t, 0, 0.8));
|
|
38
|
+
element.style.opacity = String(amount);
|
|
39
|
+
element.style.transform = "translateY(" + interpolate(24, 0, amount) + "px)";
|
|
40
|
+
};
|
|
41
|
+
seek(0);
|
|
42
|
+
return {
|
|
43
|
+
seek,
|
|
44
|
+
dispose() {
|
|
45
|
+
element.style.removeProperty("opacity");
|
|
46
|
+
element.style.removeProperty("transform");
|
|
47
|
+
},
|
|
48
|
+
ready: Promise.resolve(),
|
|
49
|
+
};
|
|
33
50
|
}
|
|
34
51
|
`;
|
|
35
|
-
const FRAGMENT_HTML = `<div class="authored-
|
|
36
|
-
<
|
|
37
|
-
<h1 class="authored-title" data-anim="rise" data-step="1" data-focus-key="title">Your scene</h1>
|
|
52
|
+
const FRAGMENT_HTML = `<div class="authored-composition">
|
|
53
|
+
<h1 class="authored-element" data-focus-key="subject">Your composition</h1>
|
|
38
54
|
</div>
|
|
39
55
|
`;
|
|
40
|
-
const STYLE_CSS =
|
|
41
|
-
#scene-root .authored-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
#scene-root .authored-title {
|
|
48
|
-
font-size: 96px;
|
|
49
|
-
line-height: 1.05;
|
|
50
|
-
font-weight: 800;
|
|
51
|
-
letter-spacing: -0.02em;
|
|
56
|
+
const STYLE_CSS = `/* A blank starting surface: design its grid, layers and type from the brief. */
|
|
57
|
+
#scene-root .authored-composition { display: grid; place-items: center; width: 100%; height: 100%; }
|
|
58
|
+
#scene-root .authored-element {
|
|
59
|
+
margin: 0;
|
|
60
|
+
font: inherit;
|
|
61
|
+
font-size: clamp(32px, 6vw, 96px);
|
|
62
|
+
color: var(--mk-color-fg);
|
|
52
63
|
}
|
|
53
64
|
`;
|
|
54
65
|
const notes = (id) => `# ${id}
|
|
55
66
|
|
|
56
67
|
Why this scene exists: <one line>.
|
|
57
68
|
|
|
58
|
-
|
|
69
|
+
Direction: <concept, composition, type, motion and sound decisions>.
|
|
70
|
+
|
|
71
|
+
The markup and motion are yours to replace. Shared \`runtime/compose.js\` offers
|
|
72
|
+
\`progress(t, start, duration)\`, \`interpolate(from, to, amount)\`,
|
|
73
|
+
\`stagger(index, step, start)\` and the existing \`ease(name, amount)\` functions.
|
|
74
|
+
All times are seconds. Progress clamps to 0..1; a zero duration is a cut.
|
|
75
|
+
Assign every animated property from t so seeking A -> B -> A restores A.
|
|
76
|
+
|
|
77
|
+
Promotion to the catalog (\`mk scene promote\`) is optional when reuse justifies it.
|
|
59
78
|
`;
|
|
60
79
|
const FILES = (id) => [
|
|
61
80
|
["scene.js", SCENE_JS],
|
package/dist/voice/command.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { voicePreset, voicePresetIds } from "@anvpx/motion-audio";
|
|
1
2
|
import { parseFlags, requireStoryboard, textFlag, usageError } from "../args.js";
|
|
2
3
|
import { runVoice, VOICE_ENV_NOTE, VOICE_MEASURED_QC_NOTE, VOICE_WAV_FALLBACK_NOTE, } from "./run.js";
|
|
3
|
-
const USAGE = `mk voice <storyboard.json> --voice <id> [--out <manifest>] [--audio-dir <dir>] [--python <bin>]
|
|
4
|
+
const USAGE = `mk voice <storyboard.json> (--voice <id> | --preset <id>) [--speed <n>] [--out <manifest>] [--audio-dir <dir>] [--python <bin>]
|
|
4
5
|
|
|
5
6
|
Kokoro local primary. Synthesize narration via the voice venv and write a voice TimingManifest.
|
|
6
7
|
Reads narration per base scene, probes the venv, synthesizes each scene, aligns
|
|
@@ -10,13 +11,17 @@ plus licences-style voice-provenance.json. Feed it to the build timing path
|
|
|
10
11
|
never silent fallback (fallback.ts is durations-only behind an explicit flag).
|
|
11
12
|
${VOICE_WAV_FALLBACK_NOTE} when env blocked. ${VOICE_MEASURED_QC_NOTE}.
|
|
12
13
|
${VOICE_ENV_NOTE}.
|
|
13
|
-
--voice <id>
|
|
14
|
+
--voice <id> raw Kokoro voice id (advanced; prefer --preset)
|
|
15
|
+
--preset <id> curated voice/style preset: ${voicePresetIds().join(", ")}
|
|
16
|
+
--speed <n> delivery speed 0.5-2.0 (overrides the preset speed)
|
|
14
17
|
--out <file> manifest path (default .mk/<stem>/voice-manifest.json)
|
|
15
18
|
--audio-dir <d> per-scene wav directory (default .mk/<stem>/audio)
|
|
16
19
|
--python <bin> explicit venv python (skips the probe)
|
|
17
20
|
`;
|
|
18
21
|
const FLAGS = {
|
|
19
22
|
voice: { type: "string" },
|
|
23
|
+
preset: { type: "string" },
|
|
24
|
+
speed: { type: "string" },
|
|
20
25
|
out: { type: "string" },
|
|
21
26
|
"audio-dir": { type: "string" },
|
|
22
27
|
python: { type: "string" },
|
|
@@ -31,15 +36,38 @@ export const voiceCommand = {
|
|
|
31
36
|
const storyboard = requireStoryboard("voice", USAGE, parsed.positionals, io);
|
|
32
37
|
if (typeof storyboard !== "string")
|
|
33
38
|
return storyboard.code;
|
|
34
|
-
const
|
|
39
|
+
const presetId = textFlag(parsed.flags, "preset");
|
|
40
|
+
const rawVoice = textFlag(parsed.flags, "voice");
|
|
41
|
+
const speedRaw = textFlag(parsed.flags, "speed");
|
|
42
|
+
if (presetId !== undefined && rawVoice !== undefined) {
|
|
43
|
+
return usageError("voice", USAGE, "--voice and --preset conflict", io).code;
|
|
44
|
+
}
|
|
45
|
+
let voice = rawVoice;
|
|
46
|
+
let speed;
|
|
47
|
+
if (presetId !== undefined) {
|
|
48
|
+
const preset = voicePreset(presetId);
|
|
49
|
+
if (preset === undefined) {
|
|
50
|
+
return usageError("voice", USAGE, `unknown preset "${presetId}"; use one of: ${voicePresetIds().join(", ")}`, io).code;
|
|
51
|
+
}
|
|
52
|
+
voice = preset.voice;
|
|
53
|
+
speed = preset.speed;
|
|
54
|
+
}
|
|
35
55
|
if (voice === undefined || voice.trim() === "") {
|
|
36
|
-
return usageError("voice", USAGE, "--voice <id> is required", io).code;
|
|
56
|
+
return usageError("voice", USAGE, "--voice <id> or --preset <id> is required", io).code;
|
|
57
|
+
}
|
|
58
|
+
if (speedRaw !== undefined) {
|
|
59
|
+
const n = Number(speedRaw);
|
|
60
|
+
if (!Number.isFinite(n) || n < 0.5 || n > 2) {
|
|
61
|
+
return usageError("voice", USAGE, "--speed must be within 0.5-2.0", io).code;
|
|
62
|
+
}
|
|
63
|
+
speed = n;
|
|
37
64
|
}
|
|
38
65
|
const out = textFlag(parsed.flags, "out");
|
|
39
66
|
const audioDir = textFlag(parsed.flags, "audio-dir");
|
|
40
67
|
const python = textFlag(parsed.flags, "python");
|
|
41
68
|
return runVoice(storyboard, {
|
|
42
69
|
voice,
|
|
70
|
+
...(speed === undefined ? {} : { speed }),
|
|
43
71
|
...(out === undefined ? {} : { outPath: out }),
|
|
44
72
|
...(audioDir === undefined ? {} : { audioDir }),
|
|
45
73
|
...(python === undefined ? {} : { python }),
|
package/dist/voice/run.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { Io } from "../types.ts";
|
|
|
2
2
|
export interface VoiceRunOptions {
|
|
3
3
|
/** Voice id from the storyboard/adapters (never a hardcoded default). */
|
|
4
4
|
voice: string;
|
|
5
|
+
/** Delivery speed; omitted = Kokoro's 1.0 and the preset's own default. */
|
|
6
|
+
speed?: number;
|
|
5
7
|
/** Manifest path; defaults to `<dir>/.mk/<stem>/voice-manifest.json`. */
|
|
6
8
|
outPath?: string;
|
|
7
9
|
/** Directory for per-scene wavs; defaults to `<dir>/.mk/<stem>/audio`. */
|
|
@@ -13,6 +15,12 @@ export interface VoiceRunOptions {
|
|
|
13
15
|
export declare const VOICE_WAV_FALLBACK_NOTE = "pre-rendered WAV fallback in pack";
|
|
14
16
|
export declare const VOICE_MEASURED_QC_NOTE = "human QC via `mk qc` (pronunciation/intelligibility/pacing/alignment/no-silence)";
|
|
15
17
|
export declare const VOICE_ENV_NOTE = "BLOCKED_ENV stays NOT_RUN, never PASS";
|
|
18
|
+
/**
|
|
19
|
+
* Tokens the aligner cannot match: a number with no letters (`01`, `$480`,
|
|
20
|
+
* `1,200`). `mk voice` must fail before synthesis with a fix, not after the
|
|
21
|
+
* aligner reports `clean_word empty`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const unspokenNarrationTokens: (narration: string) => string[];
|
|
16
24
|
/**
|
|
17
25
|
* Synthesize every narrated base scene, align words, gate silence, and write
|
|
18
26
|
* `.mk/<stem>/voice-manifest.json` + licences-style provenance. Resolves to
|
package/dist/voice/run.js
CHANGED
|
@@ -41,8 +41,14 @@ async function pickPython(io, explicit) {
|
|
|
41
41
|
io.stderr(`mk voice: ${probe.hint}\n${doctorHint}\n`);
|
|
42
42
|
return { code: EXIT.MISSING_TOOL };
|
|
43
43
|
}
|
|
44
|
-
const synthDuration = async (io, sceneId, narration, voice, audioPath, python) => {
|
|
45
|
-
const synth = await synthesize(io.run, {
|
|
44
|
+
const synthDuration = async (io, sceneId, narration, voice, audioPath, python, speed) => {
|
|
45
|
+
const synth = await synthesize(io.run, {
|
|
46
|
+
text: narration,
|
|
47
|
+
voice,
|
|
48
|
+
outPath: audioPath,
|
|
49
|
+
python,
|
|
50
|
+
...(speed === undefined ? {} : { speed }),
|
|
51
|
+
});
|
|
46
52
|
if (synth.ok)
|
|
47
53
|
return { durationS: synth.durationS };
|
|
48
54
|
io.stderr(`mk voice: synth for "${sceneId}" failed: ${synth.hint}\n${doctorHint}\n`);
|
|
@@ -74,16 +80,24 @@ const gateSilence = async (io, sceneId, audioPath, words) => {
|
|
|
74
80
|
return { silences: silence.intervals };
|
|
75
81
|
};
|
|
76
82
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
83
|
+
* Tokens the aligner cannot match: a number with no letters (`01`, `$480`,
|
|
84
|
+
* `1,200`). `mk voice` must fail before synthesis with a fix, not after the
|
|
85
|
+
* aligner reports `clean_word empty`.
|
|
86
|
+
*/
|
|
87
|
+
export const unspokenNarrationTokens = (narration) => splitTokens(narration).filter((token) => /[0-9]/.test(token) && !/\p{L}/u.test(token));
|
|
88
|
+
/**
|
|
89
|
+
* A6: narration must fit the scene at 180 wpm before anything is synthesized,
|
|
90
|
+
* and numbers must be written as spoken. The render-time reading/narration
|
|
91
|
+
* checks then cannot fail for a length the voice command could have refused.
|
|
80
92
|
*/
|
|
81
93
|
function narrationFitProblems(board) {
|
|
82
94
|
const timeline = resolveTimeline(board.board);
|
|
83
95
|
if (!timeline.ok)
|
|
84
96
|
return timeline.errors.map((error) => `${error.path}: ${error.message}`);
|
|
85
97
|
const available = new Map(timeline.value.scenes.map((scene) => [scene.id, scene.duration]));
|
|
86
|
-
|
|
98
|
+
const unspoken = board.narrated.flatMap((scene) => unspokenNarrationTokens(scene.narration ?? "").map((token) => `"${scene.id}": token "${token}" has no letters; write numbers as spoken ` +
|
|
99
|
+
`(for example "zero one" or "four hundred eighty")`));
|
|
100
|
+
const lengths = board.narrated.flatMap((scene) => {
|
|
87
101
|
const count = splitTokens(scene.narration ?? "").length;
|
|
88
102
|
const needed = Math.ceil(count / WORDS_PER_SECOND);
|
|
89
103
|
const seconds = available.get(scene.id) ?? scene.duration ?? 0;
|
|
@@ -95,16 +109,17 @@ function narrationFitProblems(board) {
|
|
|
95
109
|
`scene is ${seconds}s; set duration >= ${needed} or cut ${excess} word(s)`,
|
|
96
110
|
];
|
|
97
111
|
});
|
|
112
|
+
return [...unspoken, ...lengths];
|
|
98
113
|
}
|
|
99
114
|
/** Synth + align + silence gate for one narrated scene; fails closed, never fakes.
|
|
100
115
|
* `j*` (Japanese-pipeline) voices are unaligned-only: the EN wav2vec2 aligner
|
|
101
116
|
* cannot honestly caption non-ASCII narration, so alignment is skipped and
|
|
102
117
|
* the scene keeps measured duration with no words (QC stays UNKNOWN, never FAIL).
|
|
103
118
|
*/
|
|
104
|
-
async function voiceScene(io, scene, voice, audioDir, python) {
|
|
119
|
+
async function voiceScene(io, scene, voice, audioDir, python, speed) {
|
|
105
120
|
const narration = scene.narration;
|
|
106
121
|
const audioPath = join(audioDir, `${scene.id}.wav`);
|
|
107
|
-
const synth = await synthDuration(io, scene.id, narration, voice, audioPath, python);
|
|
122
|
+
const synth = await synthDuration(io, scene.id, narration, voice, audioPath, python, speed);
|
|
108
123
|
if ("code" in synth)
|
|
109
124
|
return synth;
|
|
110
125
|
if (isJapaneseVoice(voice)) {
|
|
@@ -140,6 +155,7 @@ async function finishVoice(args) {
|
|
|
140
155
|
}
|
|
141
156
|
const provenance = {
|
|
142
157
|
voice: args.voice,
|
|
158
|
+
...(args.speed === undefined ? {} : { speed: args.speed }),
|
|
143
159
|
...VOICE_PROVENANCE,
|
|
144
160
|
scenes: args.rows.map((row) => row.id),
|
|
145
161
|
total: timeline.value.total,
|
|
@@ -160,7 +176,7 @@ export async function runVoice(storyboard, options, io) {
|
|
|
160
176
|
return board;
|
|
161
177
|
const misfit = narrationFitProblems(board);
|
|
162
178
|
if (misfit.length > 0) {
|
|
163
|
-
io.stderr(`mk voice: narration
|
|
179
|
+
io.stderr(`mk voice: narration cannot be synthesized yet:\n${misfit.map((line) => ` - ${line}`).join("\n")}\n`);
|
|
164
180
|
return EXIT.USAGE;
|
|
165
181
|
}
|
|
166
182
|
const picked = await pickPython(io, options.python);
|
|
@@ -172,10 +188,18 @@ export async function runVoice(storyboard, options, io) {
|
|
|
172
188
|
await io.host.mkdir?.(audioDir);
|
|
173
189
|
const rows = [];
|
|
174
190
|
for (const scene of board.narrated) {
|
|
175
|
-
const timed = await voiceScene(io, scene, options.voice, audioDir, picked.python);
|
|
191
|
+
const timed = await voiceScene(io, scene, options.voice, audioDir, picked.python, options.speed);
|
|
176
192
|
if ("code" in timed)
|
|
177
193
|
return timed.code;
|
|
178
194
|
rows.push(timed);
|
|
179
195
|
}
|
|
180
|
-
return finishVoice({
|
|
196
|
+
return finishVoice({
|
|
197
|
+
board: board.board,
|
|
198
|
+
storyboard,
|
|
199
|
+
rows,
|
|
200
|
+
voice: options.voice,
|
|
201
|
+
speed: options.speed,
|
|
202
|
+
outPath,
|
|
203
|
+
io,
|
|
204
|
+
});
|
|
181
205
|
}
|
package/dist/workflow/draft.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname, join, resolve } from "node:path";
|
|
2
2
|
import { validateMusicBed } from "@anvpx/motion-audio";
|
|
3
|
-
import { AUDIO_DIR_NAME, clipsFromManifest, missingMusic, mixAtDeliveryLevel, parseAudioManifest, } from "@anvpx/motion-build";
|
|
3
|
+
import { AUDIO_DIR_NAME, clipsFromManifest, missingMusic, mixAtDeliveryLevel, parseAudioManifest, placementsFromTimeline, resolveTimeline, validateStoryboardFull, } from "@anvpx/motion-build";
|
|
4
4
|
import { textFlag, usageError } from "../args.js";
|
|
5
5
|
import { EXIT } from "../exit-codes.js";
|
|
6
6
|
import { readJsonFile } from "../storyboard/load.js";
|
|
@@ -46,8 +46,19 @@ const downscale = (input, output) => [
|
|
|
46
46
|
"copy",
|
|
47
47
|
output,
|
|
48
48
|
];
|
|
49
|
+
/** Final-timeline start/duration per narrated scene; undefined when the board cannot resolve. */
|
|
50
|
+
async function voicePlacements(storyboard, manifest, io) {
|
|
51
|
+
const loaded = await readJsonFile(storyboard, io.host);
|
|
52
|
+
if (!loaded.ok)
|
|
53
|
+
return undefined;
|
|
54
|
+
const valid = validateStoryboardFull(loaded.value);
|
|
55
|
+
if (!valid.ok)
|
|
56
|
+
return undefined;
|
|
57
|
+
const timeline = resolveTimeline(valid.value, manifest);
|
|
58
|
+
return timeline.ok ? placementsFromTimeline(timeline.value) : undefined;
|
|
59
|
+
}
|
|
49
60
|
/** Loads a voice TimingManifest plus its sibling wavs; fails closed, never silent. */
|
|
50
|
-
async function loadNarration(audioPath, io) {
|
|
61
|
+
async function loadNarration(storyboard, audioPath, io) {
|
|
51
62
|
const loaded = await readJsonFile(audioPath, io.host);
|
|
52
63
|
if (!loaded.ok) {
|
|
53
64
|
io.stderr(`mk draft: cannot read --audio manifest: ${loaded.message}\n`);
|
|
@@ -59,7 +70,8 @@ async function loadNarration(audioPath, io) {
|
|
|
59
70
|
return { ok: false, code: EXIT.USAGE };
|
|
60
71
|
}
|
|
61
72
|
const audioDir = join(dirname(resolve(audioPath)), AUDIO_DIR_NAME);
|
|
62
|
-
const
|
|
73
|
+
const placements = await voicePlacements(storyboard, parsed.manifest, io);
|
|
74
|
+
const clips = clipsFromManifest(parsed.manifest, audioDir, placements);
|
|
63
75
|
if (clips.length === 0) {
|
|
64
76
|
io.stderr("mk draft: --audio manifest has no scenes; nothing to mix\n");
|
|
65
77
|
return { ok: false, code: EXIT.USAGE };
|
|
@@ -101,7 +113,9 @@ async function resolveDraftPlan(args, io) {
|
|
|
101
113
|
code: usageError("draft", USAGE, "--music needs --audio: the bed loops to the narration length", io).code,
|
|
102
114
|
};
|
|
103
115
|
}
|
|
104
|
-
const narration = audioPath === undefined
|
|
116
|
+
const narration = audioPath === undefined
|
|
117
|
+
? undefined
|
|
118
|
+
: await loadNarration(parsed.request.storyboard, audioPath, io);
|
|
105
119
|
if (narration !== undefined && !narration.ok)
|
|
106
120
|
return { code: narration.code };
|
|
107
121
|
const bedded = musicPath === undefined ? undefined : await loadMusic(musicPath, io);
|
package/dist/workflow/render.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname, join, resolve } from "node:path";
|
|
2
2
|
import { validateMusicBed } from "@anvpx/motion-audio";
|
|
3
|
-
import { AUDIO_DIR_NAME, clipsFromManifest, compiledAssetMismatches, frozenClips, frozenCopyProblems, frozenMusic, isContiguous, missingMusic, mixAtDeliveryLevel, parseAudioManifest, } from "@anvpx/motion-build";
|
|
3
|
+
import { AUDIO_DIR_NAME, clipsFromManifest, compiledAssetMismatches, frozenClips, frozenCopyProblems, frozenMusic, isContiguous, missingMusic, mixAtDeliveryLevel, parseAudioManifest, placementsFromTimeline, resolveTimeline, validateStoryboardFull, } from "@anvpx/motion-build";
|
|
4
4
|
import { approvalState, readApproval } from "../approval/approval.js";
|
|
5
5
|
import { buildApprovalInputManifest, hashApprovalInput, } from "../approval/hash.js";
|
|
6
6
|
import { textFlag, usageError } from "../args.js";
|
|
@@ -133,8 +133,19 @@ export async function exportArtifact(io, outDir, format) {
|
|
|
133
133
|
/** sha256 of zero bytes: a silent/empty wav can never qualify as audible proof. */
|
|
134
134
|
const EMPTY_SHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
135
135
|
const isFps = (text) => /^\d+$/.test(text) && Number(text) >= 1 && Number(text) <= MAX_FPS;
|
|
136
|
+
/** Final-timeline start/duration per narrated scene; undefined when the board cannot resolve. */
|
|
137
|
+
async function voicePlacements(storyboard, manifest, io) {
|
|
138
|
+
const loaded = await readJsonFile(storyboard, io.host);
|
|
139
|
+
if (!loaded.ok)
|
|
140
|
+
return undefined;
|
|
141
|
+
const valid = validateStoryboardFull(loaded.value);
|
|
142
|
+
if (!valid.ok)
|
|
143
|
+
return undefined;
|
|
144
|
+
const timeline = resolveTimeline(valid.value, manifest);
|
|
145
|
+
return timeline.ok ? placementsFromTimeline(timeline.value) : undefined;
|
|
146
|
+
}
|
|
136
147
|
/** Loads a voice TimingManifest plus its sibling wavs; fails closed, never silent. */
|
|
137
|
-
async function loadNarration(name, audioPath, io) {
|
|
148
|
+
async function loadNarration(name, storyboard, audioPath, io) {
|
|
138
149
|
const loaded = await readJsonFile(audioPath, io.host);
|
|
139
150
|
if (!loaded.ok) {
|
|
140
151
|
io.stderr(`mk ${name}: cannot read --audio manifest: ${loaded.message}\n`);
|
|
@@ -146,7 +157,10 @@ async function loadNarration(name, audioPath, io) {
|
|
|
146
157
|
return { ok: false, code: EXIT.USAGE };
|
|
147
158
|
}
|
|
148
159
|
const audioDir = join(dirname(resolve(audioPath)), AUDIO_DIR_NAME);
|
|
149
|
-
|
|
160
|
+
// The voice manifest is a non-overlapping audio sequence; the picture starts
|
|
161
|
+
// scenes early for transitions. Place each wav on the resolved film timeline.
|
|
162
|
+
const placements = await voicePlacements(storyboard, parsed.manifest, io);
|
|
163
|
+
const clips = clipsFromManifest(parsed.manifest, audioDir, placements);
|
|
150
164
|
if (clips.length === 0) {
|
|
151
165
|
io.stderr(`mk ${name}: --audio manifest has no scenes; nothing to mix\n`);
|
|
152
166
|
return { ok: false, code: EXIT.USAGE };
|
|
@@ -249,7 +263,9 @@ async function resolvePlan(args, io) {
|
|
|
249
263
|
code: usageError("render", USAGE, "--music needs --audio: the bed loops to the narration length", io).code,
|
|
250
264
|
};
|
|
251
265
|
}
|
|
252
|
-
const narration = audioPath === undefined
|
|
266
|
+
const narration = audioPath === undefined
|
|
267
|
+
? undefined
|
|
268
|
+
: await loadNarration("render", parsed.request.storyboard, audioPath, io);
|
|
253
269
|
if (narration !== undefined && !narration.ok)
|
|
254
270
|
return { code: narration.code };
|
|
255
271
|
const bedded = musicPath === undefined ? undefined : await loadMusic("render", musicPath, io, musicVolume);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvpx/motion-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "The mk CLI for @anvpx/motion: validate, preview, approve and render storyboards.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "anvpx",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"dist/**/*.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@anvpx/motion-audio": "0.1.
|
|
34
|
-
"@anvpx/motion-build": "0.1.
|
|
35
|
-
"@anvpx/motion-schema": "0.1.
|
|
36
|
-
"@anvpx/motion-templates": "0.1.
|
|
33
|
+
"@anvpx/motion-audio": "0.1.2",
|
|
34
|
+
"@anvpx/motion-build": "0.1.2",
|
|
35
|
+
"@anvpx/motion-schema": "0.1.2",
|
|
36
|
+
"@anvpx/motion-templates": "0.1.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"test:integration": "vitest run --config vitest.integration.config.ts"
|