@anvpx/motion-cli 0.1.1 → 0.1.3
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/dist/plugin/install.d.ts +2 -2
- package/dist/plugin/install.js +1 -1
- package/dist/preview/command.js +120 -14
- package/dist/preview/manifest.d.ts +9 -0
- package/dist/voice/command.js +32 -4
- package/dist/voice/run.d.ts +2 -0
- package/dist/voice/run.js +26 -6
- package/package.json +5 -5
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.3";
|
|
16
|
+
export declare const PINNED_NPX = "npx -y @anvpx/motion@0.1.3";
|
|
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.3";
|
|
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
|
@@ -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,
|
|
@@ -691,6 +781,9 @@ export const makePreviewCommand = (env = defaultEnv, clock = () => performance.n
|
|
|
691
781
|
if (typeof started === "number")
|
|
692
782
|
return started;
|
|
693
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));
|
|
694
787
|
const { storyboard } = ctx;
|
|
695
788
|
const provenance = await readProvenance(io.host, storyboard);
|
|
696
789
|
const pair = resolvePair(env(), io, provenance, ctx.board.meta.theme);
|
|
@@ -709,6 +802,18 @@ export const makePreviewCommand = (env = defaultEnv, clock = () => performance.n
|
|
|
709
802
|
if (packed !== EXIT.OK)
|
|
710
803
|
return packed;
|
|
711
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
|
+
};
|
|
814
|
+
if (continuity.status === "warn") {
|
|
815
|
+
io.stderr(`mk preview: continuity WARN (jump ${continuity.maxJump ?? "?"} at ${continuity.atSec ?? "?"}s); change the cut with a crossfade/match/bridge and re-preview --full before asking for approval\n`);
|
|
816
|
+
}
|
|
712
817
|
let audioMix;
|
|
713
818
|
if (ctx.options.audioManifest === undefined) {
|
|
714
819
|
audioMix = SILENT_AUDIO_MIX;
|
|
@@ -752,6 +857,7 @@ export const makePreviewCommand = (env = defaultEnv, clock = () => performance.n
|
|
|
752
857
|
pair,
|
|
753
858
|
named,
|
|
754
859
|
clip,
|
|
860
|
+
continuity,
|
|
755
861
|
audioMix,
|
|
756
862
|
});
|
|
757
863
|
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/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`. */
|
package/dist/voice/run.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { join } from "node:path";
|
|
2
3
|
import { alignWords, detectSilence, isJapaneseVoice, resolveVenvPython, synthesize, VOICE_PROVENANCE, wordsInSilence, } from "@anvpx/motion-audio";
|
|
3
4
|
import { resolveTimeline, validateStoryboardFull, WORDS_PER_SECOND } from "@anvpx/motion-build";
|
|
@@ -35,14 +36,24 @@ async function loadNarrated(storyboard, io) {
|
|
|
35
36
|
async function pickPython(io, explicit) {
|
|
36
37
|
if (explicit !== undefined)
|
|
37
38
|
return { python: explicit };
|
|
39
|
+
const shared = process.env.MOTION_VOICE_PYTHON?.trim();
|
|
40
|
+
if (shared !== undefined && shared !== "" && existsSync(shared)) {
|
|
41
|
+
return { python: shared };
|
|
42
|
+
}
|
|
38
43
|
const probe = await resolveVenvPython(io.run);
|
|
39
44
|
if (probe.ok)
|
|
40
45
|
return { python: probe.python };
|
|
41
46
|
io.stderr(`mk voice: ${probe.hint}\n${doctorHint}\n`);
|
|
42
47
|
return { code: EXIT.MISSING_TOOL };
|
|
43
48
|
}
|
|
44
|
-
const synthDuration = async (io, sceneId, narration, voice, audioPath, python) => {
|
|
45
|
-
const synth = await synthesize(io.run, {
|
|
49
|
+
const synthDuration = async (io, sceneId, narration, voice, audioPath, python, speed) => {
|
|
50
|
+
const synth = await synthesize(io.run, {
|
|
51
|
+
text: narration,
|
|
52
|
+
voice,
|
|
53
|
+
outPath: audioPath,
|
|
54
|
+
python,
|
|
55
|
+
...(speed === undefined ? {} : { speed }),
|
|
56
|
+
});
|
|
46
57
|
if (synth.ok)
|
|
47
58
|
return { durationS: synth.durationS };
|
|
48
59
|
io.stderr(`mk voice: synth for "${sceneId}" failed: ${synth.hint}\n${doctorHint}\n`);
|
|
@@ -110,10 +121,10 @@ function narrationFitProblems(board) {
|
|
|
110
121
|
* cannot honestly caption non-ASCII narration, so alignment is skipped and
|
|
111
122
|
* the scene keeps measured duration with no words (QC stays UNKNOWN, never FAIL).
|
|
112
123
|
*/
|
|
113
|
-
async function voiceScene(io, scene, voice, audioDir, python) {
|
|
124
|
+
async function voiceScene(io, scene, voice, audioDir, python, speed) {
|
|
114
125
|
const narration = scene.narration;
|
|
115
126
|
const audioPath = join(audioDir, `${scene.id}.wav`);
|
|
116
|
-
const synth = await synthDuration(io, scene.id, narration, voice, audioPath, python);
|
|
127
|
+
const synth = await synthDuration(io, scene.id, narration, voice, audioPath, python, speed);
|
|
117
128
|
if ("code" in synth)
|
|
118
129
|
return synth;
|
|
119
130
|
if (isJapaneseVoice(voice)) {
|
|
@@ -149,6 +160,7 @@ async function finishVoice(args) {
|
|
|
149
160
|
}
|
|
150
161
|
const provenance = {
|
|
151
162
|
voice: args.voice,
|
|
163
|
+
...(args.speed === undefined ? {} : { speed: args.speed }),
|
|
152
164
|
...VOICE_PROVENANCE,
|
|
153
165
|
scenes: args.rows.map((row) => row.id),
|
|
154
166
|
total: timeline.value.total,
|
|
@@ -181,10 +193,18 @@ export async function runVoice(storyboard, options, io) {
|
|
|
181
193
|
await io.host.mkdir?.(audioDir);
|
|
182
194
|
const rows = [];
|
|
183
195
|
for (const scene of board.narrated) {
|
|
184
|
-
const timed = await voiceScene(io, scene, options.voice, audioDir, picked.python);
|
|
196
|
+
const timed = await voiceScene(io, scene, options.voice, audioDir, picked.python, options.speed);
|
|
185
197
|
if ("code" in timed)
|
|
186
198
|
return timed.code;
|
|
187
199
|
rows.push(timed);
|
|
188
200
|
}
|
|
189
|
-
return finishVoice({
|
|
201
|
+
return finishVoice({
|
|
202
|
+
board: board.board,
|
|
203
|
+
storyboard,
|
|
204
|
+
rows,
|
|
205
|
+
voice: options.voice,
|
|
206
|
+
speed: options.speed,
|
|
207
|
+
outPath,
|
|
208
|
+
io,
|
|
209
|
+
});
|
|
190
210
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvpx/motion-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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.3",
|
|
34
|
+
"@anvpx/motion-build": "0.1.3",
|
|
35
|
+
"@anvpx/motion-schema": "0.1.3",
|
|
36
|
+
"@anvpx/motion-templates": "0.1.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"test:integration": "vitest run --config vitest.integration.config.ts"
|