popost 4.6.6 → 4.6.8

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 (95) hide show
  1. package/SKILL.md +6 -6
  2. package/assets/canvas/assets/{dist-BmD8AP0A.js → dist-CX2mxpwq.js} +1 -1
  3. package/assets/canvas/assets/{es-CC29Cabv.js → es-BFnFFu6P.js} +1 -1
  4. package/assets/canvas/assets/{index-DS6BKqT0.css → index-C5rz5H21.css} +1 -1
  5. package/assets/canvas/assets/{index-DhwyFpu2.js → index-CwqBT_rk.js} +1 -1
  6. package/assets/canvas/assets/{jszip.min-Bwf_yCrF.js → jszip.min-DqfCBLrH.js} +1 -1
  7. package/assets/canvas/build-info.json +7 -7
  8. package/assets/canvas/index.html +2 -2
  9. package/assets/video/examples/catalogue.json +114 -0
  10. package/assets/video/examples/list-cards.html +155 -0
  11. package/assets/video/examples/page-flip.html +163 -0
  12. package/assets/video/times.js +59 -0
  13. package/dist/cli.js +2772 -1280
  14. package/dist/index.js +2243 -846
  15. package/dist/types/cloud/service.d.ts +2 -0
  16. package/dist/types/device-login.d.ts +6 -1
  17. package/dist/types/device-pending.d.ts +11 -0
  18. package/dist/types/editor/handoff.d.ts +1 -1
  19. package/dist/types/runtime.d.ts +5 -1
  20. package/dist/types/system-browser.d.ts +17 -0
  21. package/dist/types/version.d.ts +1 -1
  22. package/dist/types/video/commands/replication-books.d.ts +2 -0
  23. package/dist/types/video/compile/footage.d.ts +2 -0
  24. package/dist/types/video/compile/index.d.ts +2 -0
  25. package/dist/types/video/compile/page-bundle.d.ts +1 -1
  26. package/dist/types/video/compile/page.d.ts +1 -0
  27. package/dist/types/video/describe/parts.d.ts +3 -1
  28. package/dist/types/video/eval/readback-kept.d.ts +10 -0
  29. package/dist/types/video/eval/readback-run.d.ts +5 -1
  30. package/dist/types/video/generate/cast.d.ts +4 -0
  31. package/dist/types/video/media/footage.d.ts +1 -0
  32. package/dist/types/video/page/apply.d.ts +1 -1
  33. package/dist/types/video/page/contract.d.ts +16 -0
  34. package/dist/types/video/page/dom.d.ts +5 -0
  35. package/dist/types/video/page/times.d.ts +31 -0
  36. package/dist/types/video/preview/protocol.d.ts +1 -0
  37. package/dist/types/video/preview/reference.d.ts +9 -0
  38. package/dist/types/video/preview/shell/dom.d.ts +9 -0
  39. package/dist/types/video/preview/shell/footage.d.ts +1 -0
  40. package/dist/types/video/preview/shell/i18n.d.ts +1 -0
  41. package/dist/types/video/preview/shell/studio/copy.d.ts +1 -0
  42. package/dist/types/video/preview/shell/studio/style.d.ts +2 -2
  43. package/dist/types/video/preview/shell/studio/ui.d.ts +2 -0
  44. package/dist/types/video/preview/shell-bundle.d.ts +1 -1
  45. package/dist/types/video/project/check-sound.d.ts +3 -0
  46. package/dist/types/video/render/chunked.d.ts +29 -0
  47. package/dist/types/video/render/chunks.d.ts +39 -0
  48. package/dist/types/video/render/encode.d.ts +5 -0
  49. package/dist/types/video/render/index.d.ts +26 -0
  50. package/dist/types/video/render/record.d.ts +1 -1
  51. package/dist/types/video/render/session.d.ts +17 -0
  52. package/dist/types/video/render/shots.d.ts +11 -0
  53. package/dist/types/video/replication/books.d.ts +64 -0
  54. package/dist/types/video/replication/production.d.ts +5 -0
  55. package/dist/types/video/replication/retiming.d.ts +16 -0
  56. package/dist/types/video/replication/review.d.ts +50 -0
  57. package/dist/types/video/retarget/fps.d.ts +3 -5
  58. package/dist/types/video/retarget/index.d.ts +10 -2
  59. package/dist/types/video/retarget/speak.d.ts +2 -0
  60. package/dist/types/video/retarget/takes.d.ts +66 -0
  61. package/dist/types/video/retarget/tempo.d.ts +2 -0
  62. package/dist/types/video/speech/types.d.ts +5 -0
  63. package/dist/types/video/template/fill.d.ts +2 -0
  64. package/dist/types/video/template/save.d.ts +2 -0
  65. package/dist/types/video/template/structure.d.ts +1 -0
  66. package/dist/types/video/voice/cache.d.ts +10 -0
  67. package/dist/types/video/voice/hosted.d.ts +10 -4
  68. package/dist/types/video/voice/index.d.ts +25 -1
  69. package/dist/types/video/wallet.d.ts +7 -0
  70. package/dist/types/workflow/post-bundle.d.ts +9 -2
  71. package/package.json +1 -1
  72. package/references/host-editor.md +2 -2
  73. package/references/image-workflow.md +1 -1
  74. package/references/onboarding.md +5 -3
  75. package/references/post-bundle.md +1 -1
  76. package/references/providers.md +1 -1
  77. package/references/video-editing.md +4 -0
  78. package/references/video-effects.md +9 -1
  79. package/references/video-performers.md +12 -2
  80. package/references/video-project.md +5 -3
  81. package/references/video-replication.md +32 -3
  82. package/references/video-scenes.md +52 -2
  83. package/references/video-sfx.md +1 -1
  84. package/references/video-sound.md +18 -3
  85. package/references/video-step-0-machine.md +61 -0
  86. package/references/video-step-1-read.md +168 -0
  87. package/references/video-step-2-structure.md +24 -0
  88. package/references/video-step-3-content.md +117 -0
  89. package/references/video-step-4-lines.md +88 -0
  90. package/references/video-step-5-scenes.md +126 -0
  91. package/references/video-step-6-voice.md +53 -0
  92. package/references/video-step-7-deliver.md +92 -0
  93. package/references/video-templates.md +17 -7
  94. package/references/video-tools.md +8 -6
  95. package/references/video.md +50 -666
@@ -1,5 +1,6 @@
1
1
  import type { Runtime } from '../../runtime';
2
2
  import { type MusicBreak } from '../sound/breaks';
3
+ import { type FootageTable } from '../timeline/resolve';
3
4
  import type { Problem, Project, Resolved } from '../types';
4
5
  /** The record beside the voice a spoken fill mixed (retarget/speak.ts): <voice file>.mix.json with the file's hash. */
5
6
  export declare const VOICE_RECEIPT = ".mix.json";
@@ -24,6 +25,8 @@ export declare const clipMusicRecords: (rt: Runtime, dir: string, r: Resolved) =
24
25
  * mouth that is half another picture. Refused: a transition whose frames lie on a line a person says on camera.
25
26
  */
26
27
  export declare const speakingCuts: (r: Resolved) => Problem[];
28
+ /** Check what the mix actually plays, including native audio that runs under another picture as a bed. */
29
+ export declare const nativeSpeechSplices: (r: Resolved, project: Project, footage: FootageTable) => Problem[];
27
30
  /** Every audio track of a project made from a reference names a sound with a record; dir: the project directory. */
28
31
  export declare const soundRecords: (rt: Runtime, dir: string, project: Project) => Promise<Problem[]>;
29
32
  /** Seconds of the end of a video that its music may leave without: the fade of a track cut to the video, frame rounding. */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A whole render in chunks (render/chunks.ts): the chunks whose key the project keeps are copied, the others drawn
3
+ * and kept, and the picture of all of them is put together with the sound in one last ffmpeg run that copies it.
4
+ */
5
+ import type { Runtime } from '../../runtime';
6
+ import type { ResolvedAudio } from '../types';
7
+ import type { ImageFormat, Session } from './session';
8
+ export interface ChunkedJob {
9
+ sessions: Session[];
10
+ /** The project directory, absolute. */
11
+ root: string;
12
+ image: ImageFormat;
13
+ quality: number;
14
+ crf: number;
15
+ threads?: number;
16
+ /** The sound of the whole video, each src absolute, and whether it is wanted. */
17
+ audio: readonly ResolvedAudio[];
18
+ audioEnabled?: boolean;
19
+ /** The file to write. */
20
+ out: string;
21
+ /** false: every chunk is drawn, in a folder of its own that goes when the render ends (no reuse, or caches off). */
22
+ keep: boolean;
23
+ onProgress?: (frame: number, total: number) => void;
24
+ }
25
+ /** Renders the whole video of the pages into job.out in chunks; says how many chunks there were and how many were kept ones. */
26
+ export declare const renderInChunks: (rt: Runtime, job: ChunkedJob) => Promise<{
27
+ total: number;
28
+ reused: number;
29
+ }>;
@@ -0,0 +1,39 @@
1
+ import type { Runtime } from '../../runtime';
2
+ import type { Resolved } from '../types';
3
+ import type { ImageFormat, Session } from './session';
4
+ export declare const CHUNK_DIR = ".cache/render-chunks";
5
+ /** Bound a long single scene so a local timeline edit need not invalidate the entire video. */
6
+ export declare const MAX_CHUNK_SECONDS = 4;
7
+ /** The frames of each chunk: per segment, split at four seconds; one shorter than a second joined to the next (the last to the one before). */
8
+ export declare const chunkRanges: (r: Resolved) => [number, number][];
9
+ /** What the keys of one render share, and the hashes of the files they name, read once each. */
10
+ export interface KeyContext {
11
+ /** The render's settings, the page code and the fonts. */
12
+ settings: string;
13
+ root: string;
14
+ /** Each segment's base as the timeline has it (a scene's file, its time offset, its slots). */
15
+ bases: string[];
16
+ /** Each segment's scene file, for a scene base. */
17
+ scenes: (string | undefined)[];
18
+ hashes: Map<string, Promise<string>>;
19
+ /** The files a scene can load besides its own HTML, read once when the render starts. */
20
+ shared: string;
21
+ }
22
+ /** What every key of a render shares; call it once the pages are open, before any frame is drawn. */
23
+ export declare const keyContext: (rt: Runtime, root: string, session: Session, o: {
24
+ image: ImageFormat;
25
+ quality: number;
26
+ crf: number;
27
+ }) => Promise<KeyContext>;
28
+ /** The key of one frame from the page's state (Session.state). */
29
+ export declare const frameKey: (rt: Runtime, c: KeyContext, state: {
30
+ markup: string;
31
+ scenes: {
32
+ segment: number;
33
+ seconds: number;
34
+ }[];
35
+ }) => Promise<string>;
36
+ /** The key of a chunk: the render's settings and the keys of its frames, in order. */
37
+ export declare const chunkKey: (c: KeyContext, frames: readonly string[]) => string;
38
+ /** Where the chunks of renders with these settings are kept. */
39
+ export declare const chunkDir: (rt: Runtime, c: KeyContext) => string;
@@ -47,3 +47,8 @@ export declare const heardSeconds: (a: ResolvedAudio, frames: number, fps: numbe
47
47
  */
48
48
  export declare const colourFilter: (image: ImageFormat) => string;
49
49
  export declare const encodeArgs: (job: EncodeJob) => string[];
50
+ /**
51
+ * ffmpeg arguments that put a picture encoded in chunks (list: a concat list of their files, render/chunks.ts) together
52
+ * with the sound of the job. The picture is copied as it is; the sound is mixed as encodeArgs mixes it.
53
+ */
54
+ export declare const muxArgs: (job: EncodeJob, list: string) => string[];
@@ -46,6 +46,11 @@ export interface RenderVideoResult {
46
46
  reused: number;
47
47
  /** What the finished sound lacks, for the answer (warnings): the music ending before the video. Whole renders with sound only. */
48
48
  problems: Problem[];
49
+ /** A whole render's chunks (render/chunked.ts), and how many were copied from the render before. */
50
+ chunks?: {
51
+ total: number;
52
+ reused: number;
53
+ };
49
54
  }
50
55
  /** A frame or a range that the video does not have: the caller asked for it, so the message says what it has. */
51
56
  export declare class RenderRangeError extends Error {
@@ -77,8 +82,29 @@ export interface Renderer {
77
82
  export declare const openRenderer: (rt: Runtime, projectDir: string, opts?: {
78
83
  scale?: number;
79
84
  reuse?: boolean;
85
+ lazyScenes?: boolean;
80
86
  }) => Promise<Renderer>;
81
87
  /** Writes one frame as PNG. projectDir and out: as the user typed them (against rt.cwd). */
88
+ /** The file of frame n in a directory of frames: f000045.png, so that names sort as the frames do. */
89
+ export declare const frameFileName: (n: number) => string;
90
+ /**
91
+ * Several frames of the project, drawn in one browser session (one page load instead of one a frame) into outDir as
92
+ * frameFileName(n), in frame order, each frame once. The page is a pure function of the frame number, so a frame
93
+ * reached by jumping is the one a render draws. A frame the video does not have stops it before anything is drawn.
94
+ */
95
+ export declare const renderFrames: (rt: Runtime, opts: {
96
+ projectDir: string;
97
+ frames: readonly number[];
98
+ outDir: string;
99
+ scale?: number;
100
+ }) => Promise<{
101
+ width: number;
102
+ height: number;
103
+ files: {
104
+ frame: number;
105
+ out: string;
106
+ }[];
107
+ }>;
82
108
  export declare const renderFrame: (rt: Runtime, opts: {
83
109
  projectDir: string;
84
110
  frame: number;
@@ -1,7 +1,7 @@
1
1
  import type { Runtime } from '../../runtime';
2
2
  /** Shot scores (0..1) this close in two rounds are the same: fixing what made a shot worst moves its score further. */
3
3
  export declare const SIMILAR = 0.05;
4
- /** Rounds the review asks for at least, and at most (references/video.md, step 7). */
4
+ /** Rounds the review asks for at least, and at most (references/video-step-7-deliver.md). */
5
5
  export declare const ROUNDS: {
6
6
  readonly least: 2;
7
7
  readonly most: 4;
@@ -39,6 +39,21 @@ export interface Session {
39
39
  }): Promise<SceneFact[]>;
40
40
  /** Errors the page and its scenes have thrown so far (a script error, a file that did not load). */
41
41
  errors(): string[];
42
+ /**
43
+ * Applies frame n without a screenshot and returns the page's state() (page/contract.ts): what a render keeps the
44
+ * pictures it drew by (chunks.ts). The next frame() takes a screenshot of its own.
45
+ */
46
+ state(n: number): Promise<{
47
+ markup: string;
48
+ scenes: {
49
+ segment: number;
50
+ seconds: number;
51
+ }[];
52
+ }>;
53
+ /** The browser that draws, name and version: another one may draw the same page otherwise. */
54
+ browser: string;
55
+ /** The files of the project the page and its scenes have asked for so far, relative to the project directory. */
56
+ served(): string[];
42
57
  close(): Promise<void>;
43
58
  }
44
59
  /** The project has errors, so nothing was opened. problems: all of them, warnings too, for whoever reports them. */
@@ -59,6 +74,8 @@ export interface SessionOptions {
59
74
  scale?: number;
60
75
  /** false: take a screenshot of every frame, also when the page says the picture did not change. */
61
76
  reuse?: boolean;
77
+ /** Interactive thumbnails prepare only their requested scene; exports still validate and prepare every scene. */
78
+ lazyScenes?: boolean;
62
79
  }
63
80
  /** projectDir: as the user typed it, against rt.cwd. The caller closes the session. */
64
81
  export declare const openSession: (rt: Runtime, projectDir: string, opts?: SessionOptions) => Promise<Session>;
@@ -0,0 +1,11 @@
1
+ /** The stream of screenshots a render pipes into ffmpeg (render/index.ts, render/chunked.ts). */
2
+ import type { ImageFormat, Session } from './session';
3
+ export declare const JPEG_QUALITY = 92;
4
+ /**
5
+ * The screenshots of frames from .. to-1, in order. Frame n is drawn by page (n - from) modulo the page count, and
6
+ * every page is asked a few frames ahead, so the pages draw side by side while the frames leave in order. A failure
7
+ * ends the stream (so ffmpeg sees its input end) and is kept in box.
8
+ */
9
+ export declare function screenshots(sessions: Session[], from: number, to: number, image: ImageFormat, box: {
10
+ error?: unknown;
11
+ }, onProgress?: (f: number, t: number) => void): AsyncGenerator<Buffer>;
@@ -0,0 +1,64 @@
1
+ import type { Runtime } from '../../runtime';
2
+ import { type ReplicationEvidence } from './contract';
3
+ type Media = NonNullable<ReplicationEvidence['media']>;
4
+ type Kind = ReplicationEvidence['kind'];
5
+ /** A mistake in what was asked (a file, a place), said to the user as it is. */
6
+ export declare class BooksError extends Error {
7
+ name: string;
8
+ }
9
+ /** The media kind of a file by its extension: a video, a picture (frame), a sound, or data (JSON, HTML, text …). */
10
+ export declare const mediaOf: (rt: Runtime, file: string) => Media;
11
+ export interface BoundEvidence {
12
+ evidence: ReplicationEvidence;
13
+ copied?: string;
14
+ }
15
+ /**
16
+ * The evidence entry of a file for dir (a reference, template or project directory): its path in dir, or a copy at
17
+ * replication-evidence/<sha256><ext> when it is outside (as template copies keep theirs); its SHA-256; its media kind.
18
+ * frame: a frame of a video; at: seconds of a video or a sound.
19
+ */
20
+ export declare const bindEvidence: (rt: Runtime, dir: string, file: string, o: {
21
+ detail: string;
22
+ kind?: Kind;
23
+ frame?: number;
24
+ at?: [number, number];
25
+ }) => Promise<BoundEvidence>;
26
+ /**
27
+ * A list of evidence with e in it: an entry of the same file with other bytes (a stale hash) goes, and so does one of
28
+ * the same file, frame and seconds (e replaces it).
29
+ */
30
+ export declare const withEvidence: (list: readonly ReplicationEvidence[], e: ReplicationEvidence) => ReplicationEvidence[];
31
+ /** The places --add knows, for messages. */
32
+ export declare const PLACES = "audio, visual, inventory, music, scope, event:<id> (replication.json); plan:visual, plan:event:<id> (replication.plan.json); review:audio, review:visual, review:event:<id> (replication.review.json)";
33
+ export interface BoundReference {
34
+ file: string;
35
+ sha256: string;
36
+ fps: number;
37
+ frames: number;
38
+ }
39
+ /**
40
+ * The copy of the bound reference that replication init keeps in the directory (replication-evidence/source-<sha>…),
41
+ * found by the contract's fingerprint among its evidence and that folder and checked against its bytes, with the
42
+ * contract's clock.
43
+ */
44
+ export declare const boundReference: (rt: Runtime, dir: string) => Promise<BoundReference>;
45
+ /**
46
+ * Binds every event of the contract that has a span and no evidence to the bound reference at those frames: the
47
+ * agent wrote the event after watching it; the CLI writes the entry (file, SHA-256, seconds). Events without a span
48
+ * are named with what to do.
49
+ */
50
+ export declare const bindEventSpans: (rt: Runtime, dir: string) => Promise<{
51
+ bound: string[];
52
+ skipped: {
53
+ id: string;
54
+ why: string;
55
+ }[];
56
+ }>;
57
+ /** The file of a place, relative to the directory. */
58
+ export declare const fileOfPlace: (where: string) => string;
59
+ /**
60
+ * Puts e at a place of one of the directory's files (PLACES) and writes the file; a stale entry of the same file goes
61
+ * (withEvidence). The file must exist: replication init, the plan the agent wrote, or replication review make them.
62
+ */
63
+ export declare const addEvidence: (rt: Runtime, dir: string, where: string, e: ReplicationEvidence) => Promise<string>;
64
+ export {};
@@ -161,3 +161,8 @@ export declare const artifactFacts: (rt: Runtime, file: string, clock: {
161
161
  fps: number;
162
162
  frames: number;
163
163
  }>;
164
+ /**
165
+ * What replication check --artifact finds before there is a video to review (preflight): the contract's evidence and
166
+ * readiness, the plan against the compiled timeline and the audio inventory. Nothing for a project without a contract.
167
+ */
168
+ export declare const preRenderProblems: (rt: Runtime, dir: string, r: Resolved | undefined) => Promise<Problem[]>;
@@ -0,0 +1,16 @@
1
+ import type { Runtime } from '../../runtime';
2
+ import type { Problem, Project, Resolved } from '../types';
3
+ import type { RetargetTiming } from '../retarget/index';
4
+ import type { ReplicationContract } from './contract';
5
+ export declare const RETIMING_FILE = "replication.timing.json";
6
+ /** Keep every integer input frame's mapped target frame, so serialization loses no rounding or beat boundary. */
7
+ export declare const writeRetimedClock: (rt: Runtime, dir: string, input: {
8
+ fps: number;
9
+ frames: number;
10
+ }, project: Project, timing?: RetargetTiming) => Promise<void>;
11
+ export interface EventClock {
12
+ map?: (sourceFrame: number) => number;
13
+ problems: Problem[];
14
+ }
15
+ /** An absent sidecar retains the original source clock; a stale or malformed one must never weaken validation. */
16
+ export declare const eventClock: (rt: Runtime, dir: string, c: ReplicationContract, r: Resolved) => Promise<EventClock>;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The review of a final video, bound by the CLI (`replication review`): replication.review.json gets the video's
3
+ * SHA-256 and clock, the source's fingerprint and revision, and for the sound, the look and every required event the
4
+ * frames of this very file to inspect: an event's lead-in, middle and resolved frame of its target span in the plan.
5
+ * A verdict stays the agent's: a finding bound to a new video, or to a changed source reading, is pending again.
6
+ */
7
+ import type { ReplicationAudioUse, ReplicationContract, ReplicationReview } from './contract';
8
+ import type { ReplicationPlan } from './production';
9
+ /** The final video as the review binds it: its path in the project, SHA-256 and clock. */
10
+ export interface ReviewedVideo {
11
+ file: string;
12
+ fingerprint: string;
13
+ fps: number;
14
+ frames: number;
15
+ }
16
+ export interface BuiltReview {
17
+ review: ReplicationReview;
18
+ /** The video or the source reading changed since the review before: every finding is pending again. */
19
+ changed: boolean;
20
+ /** The frames each finding binds (audio: none, it binds the whole sound). */
21
+ frames: {
22
+ name: string;
23
+ frames: number[];
24
+ }[];
25
+ /** Required events with no frames: not in the plan and not given. */
26
+ missing: string[];
27
+ }
28
+ /** n frames spread over total, one in the middle of each nth. */
29
+ export declare const spreadFrames: (total: number, n: number) => number[];
30
+ /** The lead-in, middle and resolved frame of a target span [a, b), inside the video; two at least where it has two. */
31
+ export declare const spanFrames: (span: readonly [number, number], total: number) => number[];
32
+ /**
33
+ * The review of v for contract c: old is the review before (its other evidence, verdicts and audio uses are kept
34
+ * while the video and the source reading are the same); visual and events are the frames to bind (events by id,
35
+ * given or from the plan); audioUses fill in what the old review did not have.
36
+ */
37
+ export declare const buildReview: (o: {
38
+ contract: ReplicationContract;
39
+ old?: ReplicationReview;
40
+ plan?: ReplicationPlan;
41
+ video: ReviewedVideo;
42
+ visual: number[];
43
+ events: Readonly<Record<string, number[]>>;
44
+ audioUses?: ReplicationAudioUse[];
45
+ }) => BuiltReview;
46
+ /** Verdicts given by name (audio, visual or an event id); a name the review does not have is the caller's mistake. */
47
+ export declare const withVerdicts: (r: ReplicationReview, passed: readonly string[], failed: readonly string[]) => {
48
+ review: ReplicationReview;
49
+ unknown: string[];
50
+ };
@@ -1,7 +1,5 @@
1
- /**
2
- * The frame rate of a project made from a reference. A reference at 50 or 60 frames a second (58.65 was seen) is
3
- * re-created at half its rate: twice the frames cost twice the drawing, reading and encoding, and what a re-creation
4
- * keeps (cuts, transitions, captions, the voice) does not need them. Every other rate is rounded to a whole number.
5
- */
1
+ /** Default output rate; an explicit target rate is validated separately. */
6
2
  export declare const HIGH_RATE = 40;
7
3
  export declare const projectFps: (sourceFps: number) => number;
4
+ /** Lock an output specification before converting any shots, events or speech to frames. */
5
+ export declare const targetFps: (sourceFps: number, requested?: number) => number;
@@ -129,6 +129,8 @@ export interface SoundBed {
129
129
  export declare const bedProblems: (beds: unknown, shots: number) => Problem[];
130
130
  export interface RetargetInput {
131
131
  measure: Measure;
132
+ /** An explicit output rate; a filled template keeps its already chosen canvas rate. */
133
+ fps?: number;
132
134
  text?: TextTrack;
133
135
  /** The reference's speech: roles follow it, and speech that no caption covers gets beats of its own. */
134
136
  transcript?: Transcript;
@@ -173,6 +175,12 @@ export interface RetargetInput {
173
175
  * rhythm. false (default): a beat takes the length of its spoken line, shorter or longer.
174
176
  */
175
177
  hold?: boolean;
178
+ /**
179
+ * next[i]: line i+1 follows line i in the same take of the voice (takes.ts), this many frames after line i starts.
180
+ * Beat i then lasts exactly that long and the next beat begins where its line does: the pause between them is
181
+ * the speaker's, not the reference's, and the picture follows the voice.
182
+ */
183
+ next?: readonly (number | undefined)[];
176
184
  };
177
185
  /** The words file of the plan's sound, relative to the project: the sound material names it and captions may follow it. */
178
186
  wordsFile?: string;
@@ -232,7 +240,7 @@ export declare const LINE_TAIL = 4;
232
240
  export declare const reflow: (beats: {
233
241
  start: number;
234
242
  end: number;
235
- }[], spoken: number[], total: number, hold?: boolean) => {
243
+ }[], spoken: number[], total: number, hold?: boolean, next?: readonly (number | undefined)[]) => {
236
244
  map: (frame: number) => number;
237
245
  starts: number[];
238
246
  ends: number[];
@@ -244,5 +252,5 @@ export declare const reflow: (beats: {
244
252
  * moved with its spoken line would count as wrong. Rhythm and the picture signature are tied to the old clock and
245
253
  * are left empty.
246
254
  */
247
- export declare const reflowMeasure: (m: Measure, map: (frame: number) => number, total: number) => Measure;
255
+ export declare const reflowMeasure: (m: Measure, map: (frame: number) => number, total: number, requestedFps?: number) => Measure;
248
256
  export declare const retarget: (input: RetargetInput) => RetargetOutput;
@@ -28,6 +28,8 @@ export interface SpeakOptions {
28
28
  language?: string;
29
29
  /** A beat keeps its reference length when its line is shorter (RetargetInput.spoken.hold). */
30
30
  hold?: boolean;
31
+ /** Preserve long silent reference holds between phrases; otherwise a take stays continuous. */
32
+ keepPauses?: boolean;
31
33
  /** A line that would run over its beat is sped up by at most this much (1.12: hardly heard); undefined: never. */
32
34
  fitTempo?: number;
33
35
  }
@@ -0,0 +1,66 @@
1
+ import type { SpokenTime } from '../voice/index';
2
+ /** The most characters a take holds; a longer narration is spoken in several, cut between lines. */
3
+ export declare const TAKE_MAX = 1000;
4
+ /**
5
+ * The most a narration in takes is sped up as a whole, by default, to keep the reference's length (pitch kept): the
6
+ * way a narrator reads a little faster to fit the cut. --fit-tempo may allow more (at most 1.5); --fit-tempo 1: never.
7
+ */
8
+ export declare const LENGTH_TEMPO = 1.25;
9
+ /** The cap of the length fit: max(--fit-tempo, LENGTH_TEMPO), or 1 when --fit-tempo 1 forbids any change of tempo. */
10
+ export declare const lengthCap: (fitTempo?: number) => number;
11
+ /**
12
+ * The one tempo that brings the narrated video within `target` frames: 1 when it fits as spoken, the least that fits
13
+ * up to `max`, else `max`. total(t): the video's frames with every take sped up t times (shorter as t grows).
14
+ */
15
+ export declare const lengthTempo: (total: (t: number) => number, target: number, max: number) => number;
16
+ /** A pause of the reference between two lines longer than this (seconds) is kept: the take is cut there. */
17
+ export declare const HELD_GAP_SECONDS = 1;
18
+ export interface Take {
19
+ lines: number[];
20
+ text: string;
21
+ }
22
+ /** Where a line is spoken in its take: seconds from the take's first sound. */
23
+ export interface Span {
24
+ start: number;
25
+ end: number;
26
+ }
27
+ /** The text of a take: its lines in order; a line without punctuation of its own at its end gets a light pause after it. */
28
+ export declare const takeText: (lines: readonly string[]) => string;
29
+ /** The takes of the lines the voice says, by beat ('' : the voice says nothing there). */
30
+ export declare const takesOf: (lines: readonly string[]) => Take[];
31
+ /**
32
+ * Where each line of a take is spoken in it, from the words the speaker timed (seconds from its first sound). The
33
+ * lines' words are matched to what was said (align/index.ts); a word that was said otherwise takes the time of what
34
+ * was said in its place, one nobody said shares the time around it. matched: the share of words said as written.
35
+ */
36
+ export declare const lineSpans: (lines: readonly string[], words: readonly SpokenTime[]) => {
37
+ spans: Span[];
38
+ matched: number;
39
+ };
40
+ /** Words of the lines spread evenly over a take of `seconds`: when nothing timed or heard them. */
41
+ export declare const spreadWords: (lines: readonly string[], seconds: number) => SpokenTime[];
42
+ /** The reference's beats on the project's clock: where beat i starts and how long it is. */
43
+ export interface BeatClock {
44
+ starts: readonly number[];
45
+ slots: readonly number[];
46
+ }
47
+ /** A stretch of a take laid where its first line's beat begins: its lines, and the seconds of the take it holds. */
48
+ export interface TakePiece {
49
+ lines: number[];
50
+ from: number;
51
+ to?: number;
52
+ why?: string;
53
+ }
54
+ /**
55
+ * A take stays whole unless keepPauses preserves a reference hold longer than HELD_GAP_SECONDS, or hold keeps a
56
+ * beat longer than the voice needs. Then cut in the middle of the pause between the two lines.
57
+ */
58
+ export declare const piecesOf: (take: Take, spans: readonly Span[], ref: BeatClock, fps: number, hold: boolean, keepPauses?: boolean) => TakePiece[];
59
+ /**
60
+ * What the re-flow needs from the pieces: frames[i], how long line i is spoken; next[i], how many frames after line
61
+ * i starts the next line of its piece starts (from the piece's first line, so that rounding does not add up).
62
+ */
63
+ export declare const flowOf: (pieces: readonly TakePiece[], spanOf: (i: number) => Span, fps: number, count: number) => {
64
+ frames: number[];
65
+ next: (number | undefined)[];
66
+ };
@@ -13,6 +13,8 @@ export declare const MAX_TEMPO = 1.5;
13
13
  export declare const tempoCapProblem: (max: number) => string | undefined;
14
14
  /** The tempo that brings a line of `spoken` frames (and its tail) into a beat of `slot` frames, at most `max`; 1 when it fits. */
15
15
  export declare const tempoFor: (spoken: number, slot: number, max: number) => number;
16
+ /** The clip of a line at a tempo, written over the clip and measured again; the speaker's word times are scaled with it. */
17
+ export declare const speedUp: (rt: Runtime, line: VoiceLine, tempo: number, fps: number) => Promise<VoiceLine>;
16
18
  export interface TempoNotes {
17
19
  /** The lines as written, their beats' frames, the frames each was spoken in before and after, and the tempos. */
18
20
  captions: string[];
@@ -30,6 +30,11 @@ export interface RawTranscript {
30
30
  export interface Transcriber {
31
31
  /** file: a 16 kHz mono WAV. language: a hint such as "zh" or "en", or undefined to detect. */
32
32
  transcribe(file: string, language?: string): Promise<RawTranscript>;
33
+ /**
34
+ * True when the recognising is done elsewhere (popost.ai): here it only cuts the WAV and waits, so it takes no
35
+ * processor of the CPU budget and runs beside the local parts at any budget (describe/parts.ts, eval/readback-run.ts).
36
+ */
37
+ remote?: boolean;
33
38
  }
34
39
  /** A stretch of speech between two pauses. */
35
40
  export interface Phrase {
@@ -29,6 +29,8 @@ export interface FillOptions {
29
29
  speaker?: Speaker;
30
30
  /** With speech: a beat keeps its reference length when its line is shorter, so the video is as long as the template unless a line runs over. */
31
31
  hold?: boolean;
32
+ /** Preserve long silent reference holds when reflowing a narration take. */
33
+ keepPauses?: boolean;
32
34
  /** With speech: a line that would run over its beat is sped up by at most this much (retarget/tempo.ts). */
33
35
  fitTempo?: number;
34
36
  /** Where the fill's files are (paths relative to it); they are copied into the project. Default: the project itself. */
@@ -11,6 +11,8 @@ import { type TemplatePackage } from './types';
11
11
  export declare const measureHash: (m: Measure) => string;
12
12
  export declare const jsonText: (v: unknown) => string;
13
13
  export interface SaveOptions {
14
+ /** Choose the output rate before converting the template's shots and beats. */
15
+ fps?: number;
14
16
  measure: Measure;
15
17
  text?: TextTrack;
16
18
  transcript?: Transcript;
@@ -21,6 +21,7 @@ export declare const sourceBeats: (m: Measure, text: TextTrack | undefined, tran
21
21
  /** The template of a measured reference (and its on-screen text and speech, and the frame around its content, when they were read). */
22
22
  export declare const templateFrom: (o: {
23
23
  measure: Measure;
24
+ fps?: number;
24
25
  text?: TextTrack;
25
26
  transcript?: Transcript;
26
27
  inset?: Inset;
@@ -0,0 +1,10 @@
1
+ import type { Runtime } from '../../runtime';
2
+ /** A kept line: the WAV as the platform made it, its word times (seconds) when it gave them, and the operation that made it. */
3
+ export interface KeptLine {
4
+ audio: Uint8Array;
5
+ words?: unknown[];
6
+ operationKey: string;
7
+ }
8
+ export declare const keptLine: (rt: Runtime, voiceId: string, text: string, speed: number) => Promise<KeptLine | undefined>;
9
+ /** Keeps a line just spoken. The record goes last: it names the audio's hash, so a half-written entry never matches. */
10
+ export declare const keepLine: (rt: Runtime, voiceId: string, text: string, speed: number, line: KeptLine) => Promise<void>;
@@ -24,13 +24,19 @@ export declare const quoteHostedVoice: (rt: Runtime, voiceId: string, text: stri
24
24
  */
25
25
  export declare const downloadVoiceAudio: (rt: Runtime, url: string, out: string, again?: string) => Promise<void>;
26
26
  export declare const hostedOperationKey: (voiceId: string, text: string, speed: number, out: string) => string;
27
+ /** How many lines popost.ai speaks for one command at once (and how many it prices at once); the order is kept. */
28
+ export declare const VOICE_JOBS = 4;
27
29
  /**
28
30
  * Speaks text into the WAV at out and returns the credits charged. The platform's word times go beside it, as
29
31
  * <out>.words.json { "words": [{ "text", "start", "end" }] } in seconds from the start of the WAV (speakLines reads
30
- * them); an answer without them removes an older file there, so a clip never keeps the words of another.
32
+ * them); an answer without them removes an older file there, so a clip never keeps the words of another. A line this
33
+ * machine already has in the same voice and speed (cache.ts) is written from there: nothing sent, nothing charged.
31
34
  */
32
35
  export declare const hostedSpeech: (rt: Runtime, voice: HostedVoice, text: string, out: string, wallet: Wallet, speed?: number, operationPath?: string) => Promise<number>;
33
- /** popost.ai's speaker: every line is quoted and paid within `wallet` (wallet.ts). */
36
+ /** popost.ai's speaker: the voice looked up once per selector, every line quoted and paid within `wallet` (wallet.ts). */
34
37
  export declare const hostedSpeaker: (rt: Runtime, wallet: Wallet) => Speaker;
35
- /** What speaking `lines` in `voice` costs (free quotes), one item a line that has words. */
36
- export declare const speechPrice: (rt: Runtime, lines: readonly string[], voice?: string) => Promise<PriceItem[]>;
38
+ /**
39
+ * What speaking `lines` in `voice` at `speed` costs (free quotes, VOICE_JOBS at once), one item a line that has
40
+ * words; a line this machine already has (cache.ts) costs nothing and says so.
41
+ */
42
+ export declare const speechPrice: (rt: Runtime, lines: readonly string[], voice?: string, speed?: number) => Promise<PriceItem[]>;
@@ -15,6 +15,13 @@ export interface Speaker {
15
15
  voice?: string;
16
16
  speed?: number;
17
17
  }): Promise<void>;
18
+ /** True when lines in `voice` are spoken elsewhere (popost.ai): speakLines then speaks several at once. */
19
+ remote?(voice?: string): boolean;
20
+ /**
21
+ * True when the speaker times every word it says in `voice` (<out>.words.json): a narration is then spoken in takes,
22
+ * several lines a call (retarget/takes.ts), and the lines are found in it by those times.
23
+ */
24
+ timed?(voice?: string): boolean;
18
25
  }
19
26
  /** Whether lines in `voice` are spoken by popost.ai: a `popost:` voice, or any voice without a speaker of the user's own. */
20
27
  export declare const speaksHosted: (rt: Runtime, voice?: string) => boolean;
@@ -42,7 +49,10 @@ export interface SpokenTime {
42
49
  start: number;
43
50
  end: number;
44
51
  }
45
- /** Speaks every non-empty line into dir/line-NN.wav (48 kHz mono, trimmed) and measures it. */
52
+ /**
53
+ * Speaks every non-empty line into dir/line-NN.wav (48 kHz mono, trimmed) and measures it. popost.ai speaks VOICE_JOBS
54
+ * lines at once (Speaker.remote); a speaker on this machine one at a time. The lines come back in their order.
55
+ */
46
56
  export declare const speakLines: (rt: Runtime, o: {
47
57
  lines: string[];
48
58
  dir: string;
@@ -50,7 +60,21 @@ export declare const speakLines: (rt: Runtime, o: {
50
60
  fps: number;
51
61
  voice?: string;
52
62
  speed?: number;
63
+ name?: string;
53
64
  }) => Promise<VoiceLine[]>;
65
+ /** A stretch of a clip laid on the track: seconds from .. to of file (to: its end), heard from second at of the track. */
66
+ export interface VoicePiece {
67
+ file: string;
68
+ from: number;
69
+ to?: number;
70
+ at: number;
71
+ }
72
+ /** Lays pieces of clips on one track of `seconds`. Writes AAC (or WAV, by the extension of out). */
73
+ export declare const mixPieces: (rt: Runtime, o: {
74
+ pieces: readonly VoicePiece[];
75
+ seconds: number;
76
+ out: string;
77
+ }) => Promise<void>;
54
78
  /** Lays the clips on one track: clip i starts at frame starts[i]. Writes AAC (or WAV, by the extension of out). */
55
79
  export declare const mixLines: (rt: Runtime, o: {
56
80
  lines: VoiceLine[];
@@ -33,6 +33,13 @@ export declare class Wallet {
33
33
  /** Throws, before anything is sent, when `credits` is more than what is left. what: the call, for the message. */
34
34
  check(credits: number, what: string): void;
35
35
  pay(credits: number): void;
36
+ /**
37
+ * check, then count `credits` as spent until settle says what was charged: calls that run side by side (lines spoken
38
+ * four at a time) cannot pass the ceiling together, each having seen the same credits left.
39
+ */
40
+ reserve(credits: number, what: string): void;
41
+ /** What a reserved call was charged in the end (0 when it failed before the platform spoke). */
42
+ settle(reserved: number, charged: number): void;
36
43
  }
37
44
  /** A wallet that pays nothing: what a hosted call gets when its command confirmed no spending. */
38
45
  export declare const NOTHING: () => Wallet;