@softure-ai/marketing-kit 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/README.md +135 -14
- package/dist/cli/footage.d.ts.map +1 -1
- package/dist/cli/footage.js +15 -6
- package/dist/cli/footage.js.map +1 -1
- package/dist/config/actions-schema.d.ts +14 -14
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +5 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/schema.d.ts +92 -69
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +40 -4
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shot-steps.d.ts +16 -16
- package/dist/footage/audio.d.ts +52 -0
- package/dist/footage/audio.d.ts.map +1 -0
- package/dist/footage/audio.js +100 -0
- package/dist/footage/audio.js.map +1 -0
- package/dist/footage/captions.d.ts +57 -0
- package/dist/footage/captions.d.ts.map +1 -0
- package/dist/footage/captions.js +112 -0
- package/dist/footage/captions.js.map +1 -0
- package/dist/footage/compose.d.ts +5 -5
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +31 -22
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/edl.d.ts +54 -16
- package/dist/footage/edl.d.ts.map +1 -1
- package/dist/footage/edl.js +204 -52
- package/dist/footage/edl.js.map +1 -1
- package/dist/footage/elevenlabs.d.ts +4 -1
- package/dist/footage/elevenlabs.d.ts.map +1 -1
- package/dist/footage/elevenlabs.js +18 -6
- package/dist/footage/elevenlabs.js.map +1 -1
- package/dist/footage/fake.d.ts +2 -0
- package/dist/footage/fake.d.ts.map +1 -1
- package/dist/footage/fake.js +2 -1
- package/dist/footage/fake.js.map +1 -1
- package/dist/footage/film.d.ts +35 -1
- package/dist/footage/film.d.ts.map +1 -1
- package/dist/footage/film.js +9 -1
- package/dist/footage/film.js.map +1 -1
- package/dist/footage/frames.d.ts +38 -0
- package/dist/footage/frames.d.ts.map +1 -0
- package/dist/footage/frames.js +40 -0
- package/dist/footage/frames.js.map +1 -0
- package/dist/footage/loudness.d.ts +49 -0
- package/dist/footage/loudness.d.ts.map +1 -0
- package/dist/footage/loudness.js +114 -0
- package/dist/footage/loudness.js.map +1 -0
- package/dist/footage/normalize.d.ts +6 -2
- package/dist/footage/normalize.d.ts.map +1 -1
- package/dist/footage/normalize.js +7 -9
- package/dist/footage/normalize.js.map +1 -1
- package/dist/footage/paid.d.ts +70 -0
- package/dist/footage/paid.d.ts.map +1 -0
- package/dist/footage/paid.js +172 -0
- package/dist/footage/paid.js.map +1 -0
- package/dist/footage/pipeline.d.ts +34 -10
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +294 -85
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/footage/probe.d.ts +18 -4
- package/dist/footage/probe.d.ts.map +1 -1
- package/dist/footage/probe.js +18 -13
- package/dist/footage/probe.js.map +1 -1
- package/dist/footage/process.d.ts +45 -0
- package/dist/footage/process.d.ts.map +1 -0
- package/dist/footage/process.js +109 -0
- package/dist/footage/process.js.map +1 -0
- package/dist/footage/providers.d.ts +49 -5
- package/dist/footage/providers.d.ts.map +1 -1
- package/dist/footage/providers.js +4 -0
- package/dist/footage/providers.js.map +1 -1
- package/dist/footage/publish.d.ts +62 -0
- package/dist/footage/publish.d.ts.map +1 -0
- package/dist/footage/publish.js +164 -0
- package/dist/footage/publish.js.map +1 -0
- package/dist/footage/render.d.ts +5 -4
- package/dist/footage/render.d.ts.map +1 -1
- package/dist/footage/render.js +29 -17
- package/dist/footage/render.js.map +1 -1
- package/dist/footage/sentences.d.ts +44 -0
- package/dist/footage/sentences.d.ts.map +1 -0
- package/dist/footage/sentences.js +102 -0
- package/dist/footage/sentences.js.map +1 -0
- package/dist/footage/tools.d.ts +33 -0
- package/dist/footage/tools.d.ts.map +1 -0
- package/dist/footage/tools.js +108 -0
- package/dist/footage/tools.js.map +1 -0
- package/dist/footage/words.d.ts +6 -0
- package/dist/footage/words.d.ts.map +1 -0
- package/dist/footage/words.js +14 -0
- package/dist/footage/words.js.map +1 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/docker/footage-worker.Dockerfile +29 -0
- package/package.json +2 -1
- package/schema/edl.schema.json +115 -0
- package/schema/marketing.schema.json +112 -5
- package/src/cli/footage.ts +13 -5
- package/src/config/config.ts +5 -0
- package/src/config/schema.ts +40 -4
- package/src/footage/audio.ts +123 -0
- package/src/footage/captions.ts +146 -0
- package/src/footage/compose.ts +32 -24
- package/src/footage/edl.ts +225 -56
- package/src/footage/elevenlabs.ts +21 -8
- package/src/footage/fake.ts +4 -1
- package/src/footage/film.ts +43 -2
- package/src/footage/frames.ts +65 -0
- package/src/footage/loudness.ts +143 -0
- package/src/footage/normalize.ts +7 -9
- package/src/footage/paid.ts +213 -0
- package/src/footage/pipeline.ts +344 -89
- package/src/footage/probe.ts +20 -12
- package/src/footage/process.ts +135 -0
- package/src/footage/providers.ts +56 -6
- package/src/footage/publish.ts +180 -0
- package/src/footage/render.ts +29 -19
- package/src/footage/sentences.ts +137 -0
- package/src/footage/tools.ts +119 -0
- package/src/footage/words.ts +15 -0
- package/src/index.ts +84 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { TimedWord } from "../voice/voiceover.js";
|
|
2
|
+
import { normalizeWord } from "./words.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The transcript as sentences with stable ids (`s1`, `s2`… in film order), and suggestions of the sentences an editor
|
|
6
|
+
* usually drops: a retake (the same sentence said again later), a false start (a sentence begun and begun again) and a
|
|
7
|
+
* cut-off sentence. The kit only suggests, with a reason; the caller decides what `buildEdl` keeps.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface Sentence {
|
|
11
|
+
/** `s<n>`, numbered across the film's talking clips in order. */
|
|
12
|
+
id: string;
|
|
13
|
+
/** The clip it is spoken in. */
|
|
14
|
+
clip: string;
|
|
15
|
+
/** Seconds in the trimmed clip. */
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
text: string;
|
|
19
|
+
words: TimedWord[];
|
|
20
|
+
/** It ends with `.`, `?`, `!` or `…`. */
|
|
21
|
+
isComplete: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type RetakeKind = "retake" | "false-start" | "cut-off";
|
|
25
|
+
|
|
26
|
+
export interface RetakeSuggestion {
|
|
27
|
+
/** The sentence to drop. */
|
|
28
|
+
sentence: string;
|
|
29
|
+
kind: RetakeKind;
|
|
30
|
+
/** The sentence that replaces it (the later, good take); absent for a cut-off sentence. */
|
|
31
|
+
of?: string;
|
|
32
|
+
reason: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A silence this long ends a sentence even without punctuation. */
|
|
36
|
+
const SENTENCE_PAUSE_SECONDS = 1;
|
|
37
|
+
/** How many later sentences a take is compared with. */
|
|
38
|
+
const RETAKE_WINDOW = 3;
|
|
39
|
+
/** The share of the longer sentence's words, in order, that makes two sentences one sentence said twice. */
|
|
40
|
+
const RETAKE_SIMILARITY = 0.6;
|
|
41
|
+
|
|
42
|
+
const ENDS_SENTENCE = /[.?!…]["'”’)\]]*$/u;
|
|
43
|
+
const ENDS_CUT_OFF = /(-|—|–|\.\.\.|…)["'”’)\]]*$/u;
|
|
44
|
+
|
|
45
|
+
/** One clip's words as sentences; `firstNumber` is the number of the first id. */
|
|
46
|
+
export function splitSentences(words: TimedWord[], clip: string, firstNumber = 1): Sentence[] {
|
|
47
|
+
const sorted = [...words].sort((a, b) => a.start - b.start);
|
|
48
|
+
const groups: TimedWord[][] = [];
|
|
49
|
+
let current: TimedWord[] = [];
|
|
50
|
+
sorted.forEach((word, index) => {
|
|
51
|
+
const previous = sorted[index - 1];
|
|
52
|
+
if (current.length > 0 && previous !== undefined && word.start - previous.end > SENTENCE_PAUSE_SECONDS) {
|
|
53
|
+
groups.push(current);
|
|
54
|
+
current = [];
|
|
55
|
+
}
|
|
56
|
+
current.push(word);
|
|
57
|
+
if (ENDS_SENTENCE.test(word.text.trim())) {
|
|
58
|
+
groups.push(current);
|
|
59
|
+
current = [];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (current.length > 0) groups.push(current);
|
|
63
|
+
return groups.map((group, index) => {
|
|
64
|
+
const last = group[group.length - 1] as TimedWord;
|
|
65
|
+
return {
|
|
66
|
+
id: `s${firstNumber + index}`,
|
|
67
|
+
clip,
|
|
68
|
+
start: (group[0] as TimedWord).start,
|
|
69
|
+
end: last.end,
|
|
70
|
+
text: group.map((word) => word.text.trim()).join(" "),
|
|
71
|
+
words: group,
|
|
72
|
+
isComplete: ENDS_SENTENCE.test(last.text.trim()) && !ENDS_CUT_OFF.test(last.text.trim()),
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The sentences of every talking clip, numbered across the film in clip order. */
|
|
78
|
+
export function splitFilmSentences(clips: { id: string; role: string; words: TimedWord[] }[]): Sentence[] {
|
|
79
|
+
const sentences: Sentence[] = [];
|
|
80
|
+
for (const clip of clips) {
|
|
81
|
+
if (clip.role !== "talk") continue;
|
|
82
|
+
sentences.push(...splitSentences(clip.words, clip.id, sentences.length + 1));
|
|
83
|
+
}
|
|
84
|
+
return sentences;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getTokens(sentence: Sentence): string[] {
|
|
88
|
+
return sentence.words.map((word) => normalizeWord(word.text)).filter((token) => token.length > 0);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The length of the longest common subsequence of two token lists. */
|
|
92
|
+
function getCommonLength(a: string[], b: string[]): number {
|
|
93
|
+
let previous = new Array<number>(b.length + 1).fill(0);
|
|
94
|
+
for (const token of a) {
|
|
95
|
+
const row = [0];
|
|
96
|
+
b.forEach((other, j) => row.push(token === other ? (previous[j] ?? 0) + 1 : Math.max(previous[j + 1] ?? 0, row[j] ?? 0)));
|
|
97
|
+
previous = row;
|
|
98
|
+
}
|
|
99
|
+
return previous[b.length] ?? 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function isPrefix(short: string[], long: string[]): boolean {
|
|
103
|
+
return short.length > 0 && short.length < long.length && short.every((token, index) => long[index] === token);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Sentences an editor would likely drop, each with the reason. Within one clip, a sentence is compared with the next
|
|
108
|
+
* three: a `false-start` when its words begin a later sentence, a `retake` when 60 % or more of the longer one's words
|
|
109
|
+
* match in order (the later take is kept). Otherwise a sentence that ends in a dash or an ellipsis, or ends its clip
|
|
110
|
+
* without a full stop, is `cut-off`.
|
|
111
|
+
*/
|
|
112
|
+
export function findRetakes(sentences: Sentence[]): RetakeSuggestion[] {
|
|
113
|
+
const suggestions: RetakeSuggestion[] = [];
|
|
114
|
+
sentences.forEach((sentence, index) => {
|
|
115
|
+
const tokens = getTokens(sentence);
|
|
116
|
+
const later = sentences.slice(index + 1, index + 1 + RETAKE_WINDOW).filter((other) => other.clip === sentence.clip);
|
|
117
|
+
for (const other of later) {
|
|
118
|
+
const otherTokens = getTokens(other);
|
|
119
|
+
if (isPrefix(tokens, otherTokens)) {
|
|
120
|
+
suggestions.push({ sentence: sentence.id, kind: "false-start", of: other.id, reason: `${other.id} starts with the same words and finishes the sentence` });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const longest = Math.max(tokens.length, otherTokens.length);
|
|
124
|
+
const similarity = longest === 0 ? 0 : getCommonLength(tokens, otherTokens) / longest;
|
|
125
|
+
if (tokens.length > 0 && similarity >= RETAKE_SIMILARITY) {
|
|
126
|
+
suggestions.push({ sentence: sentence.id, kind: "retake", of: other.id, reason: `${other.id} says it again (${Math.round(similarity * 100)} % of the words); the later take is kept` });
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const last = sentence.words.at(-1)?.text.trim() ?? "";
|
|
131
|
+
const next = sentences[index + 1];
|
|
132
|
+
const isLastOfClip = next === undefined || next.clip !== sentence.clip;
|
|
133
|
+
if (ENDS_CUT_OFF.test(last)) suggestions.push({ sentence: sentence.id, kind: "cut-off", reason: "it breaks off mid-sentence" });
|
|
134
|
+
else if (!sentence.isComplete && isLastOfClip) suggestions.push({ sentence: sentence.id, kind: "cut-off", reason: "the clip ends before the sentence does" });
|
|
135
|
+
});
|
|
136
|
+
return suggestions;
|
|
137
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
import { getHyperframesBin, getHyperframesEnv, HYPERFRAMES_VERSION } from "../render/hyperframes.js";
|
|
6
|
+
import { runProcess } from "./process.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The machine check before a footage run, so a worker image without the HEVC decoder or `zscale` fails at start
|
|
10
|
+
* instead of inside the first HDR iPhone clip's normalize. Nothing here downloads anything.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface FootageToolsOptions {
|
|
14
|
+
/** Check hyperframes and its browser too (a run that renders); true by default. */
|
|
15
|
+
needsRender?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Accept a machine without hyperframes' browser, which its first render downloads (a developer's machine); a
|
|
18
|
+
* worker image ships the browser, so the default is false.
|
|
19
|
+
*/
|
|
20
|
+
isBrowserDownloadAllowed?: boolean;
|
|
21
|
+
/** The environment the run sees (`HYPERFRAMES_BROWSER_PATH`, `PRODUCER_HEADLESS_SHELL_PATH`, `HOME`). */
|
|
22
|
+
env?: NodeJS.ProcessEnv;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** What the footage blocks need from ffmpeg: decoders and filters, by the name ffmpeg lists them under. */
|
|
27
|
+
export const REQUIRED_DECODERS = ["hevc", "h264"] as const;
|
|
28
|
+
export const REQUIRED_FILTERS = ["zscale", "tonemap"] as const;
|
|
29
|
+
|
|
30
|
+
const INSTALL_HINT = "install an ffmpeg built with libzimg (macOS: brew install ffmpeg, Debian/Ubuntu: apt install ffmpeg)";
|
|
31
|
+
|
|
32
|
+
/** The names in `ffmpeg -decoders` or `-filters` output: the second column of each listing line. */
|
|
33
|
+
export function readFfmpegListing(output: string): Set<string> {
|
|
34
|
+
const names = new Set<string>();
|
|
35
|
+
for (const line of output.split("\n")) {
|
|
36
|
+
const match = /^\s*[A-Z.|]{2,}\s+(\S+)\s/.exec(line);
|
|
37
|
+
if (match?.[1] !== undefined && match[1] !== "=") names.add(match[1]);
|
|
38
|
+
}
|
|
39
|
+
return names;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function listFfmpeg(kind: "-decoders" | "-filters", signal: AbortSignal | undefined): Promise<Set<string> | null> {
|
|
43
|
+
const result = await runProcess({ command: "ffmpeg", args: ["-hide_banner", kind], ...(signal === undefined ? {} : { signal }) });
|
|
44
|
+
return result.kind === "exited" && result.code === 0 ? readFfmpegListing(result.stdout) : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function isRunnable(command: string, args: string[], options: { env?: NodeJS.ProcessEnv; signal?: AbortSignal }): Promise<boolean> {
|
|
48
|
+
const result = await runProcess({ command, args, ...options });
|
|
49
|
+
return result.kind === "exited" && result.code === 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A `chrome-headless-shell` binary in one of hyperframes' cache folders (`<base>/<version>/<platform folder>/`). */
|
|
53
|
+
function findCachedHeadlessShell(base: string): string | null {
|
|
54
|
+
if (!existsSync(base)) return null;
|
|
55
|
+
for (const version of readdirSync(base)) {
|
|
56
|
+
const versionDir = join(base, version);
|
|
57
|
+
if (!statSync(versionDir).isDirectory()) continue;
|
|
58
|
+
for (const folder of readdirSync(versionDir)) {
|
|
59
|
+
for (const name of ["chrome-headless-shell", "chrome-headless-shell.exe"]) {
|
|
60
|
+
const binary = join(versionDir, folder, name);
|
|
61
|
+
if (existsSync(binary)) return binary;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The browser hyperframes renders with, resolved as hyperframes 0.8 does: `PRODUCER_HEADLESS_SHELL_PATH`, then
|
|
70
|
+
* `HYPERFRAMES_BROWSER_PATH`, then its own and puppeteer's cache of chrome-headless-shell. A problem when none is there.
|
|
71
|
+
*/
|
|
72
|
+
export function findBrowserProblem(env: NodeJS.ProcessEnv): string | null {
|
|
73
|
+
for (const name of ["PRODUCER_HEADLESS_SHELL_PATH", "HYPERFRAMES_BROWSER_PATH"]) {
|
|
74
|
+
const path = env[name];
|
|
75
|
+
if (path === undefined || path.length === 0) continue;
|
|
76
|
+
return existsSync(path) ? null : `${name} names ${path}, which does not exist.`;
|
|
77
|
+
}
|
|
78
|
+
const home = env.HOME ?? env.USERPROFILE ?? homedir();
|
|
79
|
+
const caches = [join(home, ".cache", "hyperframes", "chrome", "chrome-headless-shell"), join(home, ".cache", "puppeteer", "chrome-headless-shell")];
|
|
80
|
+
if (caches.some((base) => findCachedHeadlessShell(base) !== null)) return null;
|
|
81
|
+
return "hyperframes has no browser: run `npx hyperframes browser ensure` in the image, or set HYPERFRAMES_BROWSER_PATH to a chrome-headless-shell.";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Checks the machine for a footage run: ffmpeg and ffprobe run, ffmpeg decodes HEVC and H.264 and has `zscale` and
|
|
86
|
+
* `tonemap` (HDR clips), and, for a render, hyperframes runs and has its browser. Returns every problem found; an
|
|
87
|
+
* empty list means the machine is ready.
|
|
88
|
+
*/
|
|
89
|
+
export async function checkFootageTools(options: FootageToolsOptions = {}): Promise<string[]> {
|
|
90
|
+
const { signal } = options;
|
|
91
|
+
const env = options.env ?? process.env;
|
|
92
|
+
const problems: string[] = [];
|
|
93
|
+
const aborting = signal === undefined ? {} : { signal };
|
|
94
|
+
const decoders = await listFfmpeg("-decoders", signal);
|
|
95
|
+
if (decoders === null) {
|
|
96
|
+
problems.push(`no ffmpeg in PATH: ${INSTALL_HINT}.`);
|
|
97
|
+
} else {
|
|
98
|
+
const filters = await listFfmpeg("-filters", signal);
|
|
99
|
+
for (const decoder of REQUIRED_DECODERS) if (!decoders.has(decoder)) problems.push(`ffmpeg has no ${decoder} decoder: ${INSTALL_HINT}.`);
|
|
100
|
+
for (const filter of REQUIRED_FILTERS) {
|
|
101
|
+
if (filters?.has(filter) !== true) problems.push(`ffmpeg has no ${filter} filter (HDR clips need it): ${INSTALL_HINT}.`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!(await isRunnable("ffprobe", ["-version"], aborting))) problems.push(`no ffprobe in PATH: it comes with ffmpeg; ${INSTALL_HINT}.`);
|
|
105
|
+
if (options.needsRender === false) return problems;
|
|
106
|
+
let hyperframes: string | null = null;
|
|
107
|
+
try {
|
|
108
|
+
hyperframes = getHyperframesBin();
|
|
109
|
+
} catch {
|
|
110
|
+
// Resolving the package failed: it is not installed, reported below.
|
|
111
|
+
}
|
|
112
|
+
if (hyperframes === null || !(await isRunnable(process.execPath, [hyperframes, "--version"], { env: getHyperframesEnv(env), ...aborting }))) {
|
|
113
|
+
problems.push(`hyperframes ${HYPERFRAMES_VERSION} does not run: reinstall @softure-ai/marketing-kit.`);
|
|
114
|
+
} else if (options.isBrowserDownloadAllowed !== true) {
|
|
115
|
+
const browser = findBrowserProblem(env);
|
|
116
|
+
if (browser !== null) problems.push(browser);
|
|
117
|
+
}
|
|
118
|
+
return problems;
|
|
119
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Words compared as an editor hears them: without case, punctuation and repeated letters. */
|
|
2
|
+
|
|
3
|
+
/** A word reduced for comparison: lower case, letters and digits only, repeated letters collapsed (`Yyyy,` → `y`). */
|
|
4
|
+
export function normalizeWord(text: string): string {
|
|
5
|
+
return text
|
|
6
|
+
.toLowerCase()
|
|
7
|
+
.replace(/[^\p{L}\p{N}]/gu, "")
|
|
8
|
+
.replace(/(.)\1+/gu, "$1");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Whether the word is one of the fillers (compared as `normalizeWord` writes both). */
|
|
12
|
+
export function isFiller(text: string, fillers: readonly string[]): boolean {
|
|
13
|
+
const word = normalizeWord(text);
|
|
14
|
+
return word.length > 0 && fillers.some((filler) => normalizeWord(filler) === word);
|
|
15
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -181,7 +181,14 @@ export {
|
|
|
181
181
|
DEFAULT_FILLERS,
|
|
182
182
|
DEFAULT_MUSIC_VOLUME,
|
|
183
183
|
DEFAULT_TRANSITIONS,
|
|
184
|
+
CAPTION_PRESETS,
|
|
185
|
+
CAPTION_STYLES,
|
|
186
|
+
DEFAULT_EDIT,
|
|
184
187
|
getDefaultFillers,
|
|
188
|
+
getFootageEdit,
|
|
189
|
+
type CaptionPreset,
|
|
190
|
+
type CaptionStyle,
|
|
191
|
+
type FootageEdit,
|
|
185
192
|
type ClipFit,
|
|
186
193
|
type ClipRole,
|
|
187
194
|
type CutOptions,
|
|
@@ -201,18 +208,37 @@ export {
|
|
|
201
208
|
probeFile,
|
|
202
209
|
probeFootage,
|
|
203
210
|
readFootageProbe,
|
|
211
|
+
runFfprobe,
|
|
204
212
|
type FootageProbe,
|
|
205
213
|
type HdrKind,
|
|
206
214
|
type ProbeResult,
|
|
207
215
|
type ProbedClip,
|
|
208
216
|
} from "./footage/probe.js";
|
|
217
|
+
export {
|
|
218
|
+
MUSIC_FILE_TYPES,
|
|
219
|
+
checkMusicFileType,
|
|
220
|
+
describeAudioProbe,
|
|
221
|
+
probeAudio,
|
|
222
|
+
readAudioProbe,
|
|
223
|
+
type AudioProbe,
|
|
224
|
+
type AudioProbeFailure,
|
|
225
|
+
type AudioProbeResult,
|
|
226
|
+
type MusicFileTypeCheck,
|
|
227
|
+
} from "./footage/audio.js";
|
|
209
228
|
export { FOOTAGE_FPS, FOOTAGE_SAMPLE_RATE, buildNormalizeArgs, buildVideoFilter, normalizeFootage, resolveFit, toneMapFilter, type Frame, type NormalizeInput } from "./footage/normalize.js";
|
|
210
229
|
export {
|
|
211
230
|
describePaidSteps,
|
|
231
|
+
toPaidAudio,
|
|
232
|
+
type FootageCharge,
|
|
233
|
+
type FootageProgress,
|
|
212
234
|
type FootageProviders,
|
|
235
|
+
type FootageRates,
|
|
236
|
+
type FootageStage,
|
|
213
237
|
type IsolationProvider,
|
|
214
238
|
type MusicProvider,
|
|
239
|
+
type PaidAudio,
|
|
215
240
|
type PaidStep,
|
|
241
|
+
type PaidStepKind,
|
|
216
242
|
type SttInput,
|
|
217
243
|
type SttProvider,
|
|
218
244
|
type SttTranscript,
|
|
@@ -225,6 +251,7 @@ export {
|
|
|
225
251
|
createElevenLabsMusicProvider,
|
|
226
252
|
createElevenLabsSttProvider,
|
|
227
253
|
getMusicLengthMs,
|
|
254
|
+
readReportedCredits,
|
|
228
255
|
readScribeResponse,
|
|
229
256
|
type ElevenLabsFootageOptions,
|
|
230
257
|
} from "./footage/elevenlabs.js";
|
|
@@ -243,31 +270,88 @@ export {
|
|
|
243
270
|
MIN_SEGMENT_SECONDS,
|
|
244
271
|
SEGMENT_MOTIONS,
|
|
245
272
|
buildEdl,
|
|
273
|
+
diffEdl,
|
|
246
274
|
edlSchema,
|
|
247
275
|
findEdlProblems,
|
|
248
276
|
getEdlDuration,
|
|
277
|
+
getEdlJsonSchema,
|
|
249
278
|
getSegmentStarts,
|
|
279
|
+
getSoundSpan,
|
|
250
280
|
isFiller,
|
|
251
281
|
normalizeWord,
|
|
252
282
|
readEdl,
|
|
253
283
|
remapWords,
|
|
284
|
+
validateEdl,
|
|
285
|
+
type BuildEdlOptions,
|
|
254
286
|
type Edl,
|
|
287
|
+
type EdlAudio,
|
|
255
288
|
type EdlClip,
|
|
256
289
|
type EdlSegment,
|
|
257
290
|
type SegmentMotion,
|
|
258
291
|
} from "./footage/edl.js";
|
|
292
|
+
export { findRetakes, splitFilmSentences, splitSentences, type RetakeKind, type RetakeSuggestion, type Sentence } from "./footage/sentences.js";
|
|
293
|
+
export {
|
|
294
|
+
CAPTION_SAFE_ZONES,
|
|
295
|
+
findMissingCaptionGlyphs,
|
|
296
|
+
getCaptionPresetLayout,
|
|
297
|
+
phraseChunks,
|
|
298
|
+
type MissingCaptionGlyphs,
|
|
299
|
+
type PhraseChunk,
|
|
300
|
+
type SafeZone,
|
|
301
|
+
} from "./footage/captions.js";
|
|
302
|
+
export { MAX_FRAMES, buildFrameArgs, extractFrames, getFrameTimes, type ExtractFramesOptions, type ExtractedFrame, type FrameSpacing } from "./footage/frames.js";
|
|
259
303
|
export { duckingKeyframes, getSpeechSpans, volumeExpression, type DuckingOptions, type VolumeKeyframe } from "./footage/music.js";
|
|
260
304
|
export { END_CARD_SECONDS, FADE_SECONDS, composeFootage, getFootageFilmSeconds, getSegmentScales, type FootageComposeAssets, type FootageComposeInput } from "./footage/compose.js";
|
|
261
305
|
export { buildCutPreviewArgs, buildLastFrameArgs, buildMusicArgs, buildSpeechArgs } from "./footage/render.js";
|
|
306
|
+
export {
|
|
307
|
+
DEFAULT_LOUDNESS,
|
|
308
|
+
buildLoudnessArgs,
|
|
309
|
+
buildLoudnessMeasureArgs,
|
|
310
|
+
isSilent,
|
|
311
|
+
normalizeLoudness,
|
|
312
|
+
readLoudnessMeasurement,
|
|
313
|
+
type LoudnessMeasurement,
|
|
314
|
+
type LoudnessOutcome,
|
|
315
|
+
type LoudnessTarget,
|
|
316
|
+
} from "./footage/loudness.js";
|
|
317
|
+
export {
|
|
318
|
+
buildCoverArgs,
|
|
319
|
+
buildFinishArgs,
|
|
320
|
+
clampCoverSeconds,
|
|
321
|
+
findFinishProblems,
|
|
322
|
+
getCoverPath,
|
|
323
|
+
getDefaultCoverSeconds,
|
|
324
|
+
isFastStart,
|
|
325
|
+
isPublishableAudio,
|
|
326
|
+
isPublishableVideo,
|
|
327
|
+
probeFilmFacts,
|
|
328
|
+
readFilmFacts,
|
|
329
|
+
readTopLevelBoxes,
|
|
330
|
+
type FilmFacts,
|
|
331
|
+
} from "./footage/publish.js";
|
|
332
|
+
export { readFfmpegProgressSeconds, runFfmpeg, runProcess, type FfmpegRunOptions, type ProcessOptions, type ProcessOutcome } from "./footage/process.js";
|
|
333
|
+
export {
|
|
334
|
+
estimateFootageFilm,
|
|
335
|
+
findCachedStep,
|
|
336
|
+
getDownloadPath,
|
|
337
|
+
type EstimateFootageOptions,
|
|
338
|
+
type FootageCacheOptions,
|
|
339
|
+
type FootageEstimate,
|
|
340
|
+
type FootageEstimateItem,
|
|
341
|
+
} from "./footage/paid.js";
|
|
342
|
+
export { REQUIRED_DECODERS, REQUIRED_FILTERS, checkFootageTools, findBrowserProblem, readFfmpegListing, type FootageToolsOptions } from "./footage/tools.js";
|
|
262
343
|
export {
|
|
263
344
|
cutFootage,
|
|
264
345
|
getEdlPath,
|
|
265
346
|
getFrame,
|
|
266
347
|
prepareFootage,
|
|
348
|
+
getFootageSentences,
|
|
267
349
|
readEdlFile,
|
|
350
|
+
readRenderPercent,
|
|
268
351
|
renderFootage,
|
|
269
352
|
renderFootageFilm,
|
|
270
353
|
transcribeFootage,
|
|
354
|
+
type FinishedFootage,
|
|
271
355
|
type FootageBrand,
|
|
272
356
|
type FootageResult,
|
|
273
357
|
type FootageRunOptions,
|