Open source CapCut alternative.
TypeScript
fix(site): find_filler returns one span per cut [rebuild]
David Le76c22a0d1cca
diff --git a/site/scripts/lib/cut-eval/fixtures.ts b/site/scripts/lib/cut-eval/fixtures.tsindex 1fdb8eb4..98140477 100644--- a/site/scripts/lib/cut-eval/fixtures.ts+++ b/site/scripts/lib/cut-eval/fixtures.ts@@ -229,11 +229,21 @@ export const FILLER_CUES = [* find_filler's result: the ums and the stranded "you know". */export const FILLER_WORDS = (() => {const picks = new Set(["um,", "uh,", "you", "know,"]);- return FILLER_CUES.flatMap((c) =>- c.words- .filter((w) => picks.has(w.w.toLowerCase()))- .map((w) => ({ cue_id: c.id, word: w.w, start: w.t0, end: w.t1 }))- );+ const out: { cue_id: string; text: string; start: number; end: number }[] = [];+ for (const c of FILLER_CUES) {+ c.words.forEach((w, i) => {+ if (!picks.has(w.w.toLowerCase())) return;+ const last = out[out.length - 1];+ const runsOn = last && last.cue_id === c.id && picks.has((c.words[i - 1]?.w ?? "").toLowerCase());+ if (last && runsOn) {+ last.text += ` ${w.w}`;+ last.end = w.t1;+ } else {+ out.push({ cue_id: c.id, text: w.w, start: w.t0, end: w.t1 });+ }+ });+ }+ return out;})();export const FILLER_STATE = {diff --git a/site/src/cut/components/AiPanel.tools.ts b/site/src/cut/components/AiPanel.tools.tsindex 5da5ddba..2066439a 100644--- a/site/src/cut/components/AiPanel.tools.ts+++ b/site/src/cut/components/AiPanel.tools.ts@@ -71,7 +71,7 @@ export const AI_PANEL_TOOLS = [{name: "find_filler",description:- "Find the filler words in a subtitle track's transcript — um, uh, a stranded 'like' or 'you know', stutters, repeated words — each judged in its sentence. Returns [{cue_id, word, start, end}] in TIMELINE seconds (the cues' own word timings), plus each word's source times when clip_id is passed, so you can cut the speech with split_at / delete_item / trim_clip or tidy the captions with update_cue. Needs a transcribed track (subtitles_generate) first. Words marked estimated sit in cues that lost their word timings.",+ "Find the filler words in a subtitle track's transcript — um, uh, a stranded 'like' or 'you know', stutters, repeated words — each judged in its sentence. Returns [{cue_id, text, start, end}] in TIMELINE seconds, neighbouring filler words merged into one span so each entry is one cut, (the cues' own word timings), plus each word's source times when clip_id is passed, so you can cut the speech with split_at / delete_item / trim_clip or tidy the captions with update_cue. Needs a transcribed track (subtitles_generate) first. Words marked estimated sit in cues that lost their word timings.",inputSchema: obj({track: num("Subtitle track, 0-based (default: the active one)"),clip_id: str("Video clip id — scopes to its timeline span and maps each word to source seconds"),diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.tsindex 242a91ae..8c7c2376 100644--- a/site/src/cut/lib/aiTools.ts+++ b/site/src/cut/lib/aiTools.ts@@ -1161,16 +1161,34 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {}const floor = cutJudge().fillerCut;const toSource = clip ? (t: number) => round2(retimeOf(clip).srcAt(clamp(t - clip.start, 0, Infinity))) : null;- const fillers = words- .filter((w) => (answers[w.key]?.noul ?? 0) >= floor)- .map((w) => ({- cue_id: w.cueId,- word: w.w,- start: round2(w.t0),- end: round2(w.t1),- ...(w.estimated ? { estimated: true } : {}),- ...(toSource ? { source: { start: toSource(w.t0), end: toSource(w.t1) } } : {}),- }));+ // Neighbouring filler words are one span: "you know" is a single cut,+ // and every span the caller gets is a cut it can make in one call.+ const kept = words.filter((w) => (answers[w.key]?.noul ?? 0) >= floor);+ const spans: { cueId: string; words: string[]; t0: number; t1: number; estimated: boolean }[] = [];+ let prev: (typeof kept)[number] | null = null;+ for (const w of kept) {+ const last = spans[spans.length - 1];+ const runsOn =+ prev !== null &&+ last !== undefined &&+ ((prev.cueId === w.cueId && prev.i === w.i - 1) || w.t0 - prev.t1 <= WORD_GAP);+ if (last && runsOn) {+ last.words.push(w.w);+ last.t1 = w.t1;+ last.estimated = last.estimated || w.estimated;+ } else {+ spans.push({ cueId: w.cueId, words: [w.w], t0: w.t0, t1: w.t1, estimated: w.estimated });+ }+ prev = w;+ }+ const fillers = spans.map((sp) => ({+ cue_id: sp.cueId,+ text: sp.words.join(" "),+ start: round2(sp.t0),+ end: round2(sp.t1),+ ...(sp.estimated ? { estimated: true } : {}),+ ...(toSource ? { source: { start: toSource(sp.t0), end: toSource(sp.t1) } } : {}),+ }));return {fillers,count: fillers.length,@@ -4363,6 +4381,8 @@ async function rankStock<T extends { id: string; kind: string; category: string;.map((x) => x.c);}+/** Filler words this close together are cut as one span. */+const WORD_GAP = 0.12;const STOCK_JUDGE_CHUNK = 50;const FILLER_JUDGE_CHUNK = 60;