Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Dub review: the long-line hint names every line of the take (lines spoken as one take are flagged together)

Claude6d3e8f63fe99
diff --git a/src/components/dub/dub-studio.tsx b/src/components/dub/dub-studio.tsx
index 74750580..05ff3974 100644
--- a/src/components/dub/dub-studio.tsx
+++ b/src/components/dub/dub-studio.tsx
@@ -17,7 +17,7 @@ import { StepList, type StepRow } from "@/components/av/step-list";
import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";
import { useEngine } from "@/lib/api";
import { cueProblems } from "@/lib/av/cue-edit";
-import { crowdedLines, dubResult, languageStage, ONE_SHOT_MODELS, priceLine, reviewCues, translateKey, type DubPrice, type DubSessionView, type DubStage, type OneShotModel } from "@/lib/av/dub";
+import { crowdedLines, dubResult, languageStage, ONE_SHOT_MODELS, priceLine, reviewCues, takeLines, translateKey, type DubPrice, type DubSessionView, type DubStage, type OneShotModel } from "@/lib/av/dub";
import { languageByCode, supportsTarget, type DubRoute } from "@/lib/av/languages";
import type { Cue } from "@/lib/cues";
import { cn } from "@/lib/utils";
@@ -493,9 +493,11 @@ function Review({ s, lang, time, onSeek }: { s: DubSessionView; lang: string; ti
<>
{" "}
<span className="font-medium text-foreground">
- {crowded.length === 1 ? `Line ${crowded[0] + 1} looks` : `${crowded.length} lines (${crowded.slice(0, 4).map((i) => i + 1).join(", ")}${crowded.length > 4 ? "…" : ""}) look`} long for {crowded.length === 1 ? "its" : "their"} time
+ {crowded.length === 1
+ ? `${takeLines(crowded[0]).replace(/^l/, "L")}${crowded[0].first === crowded[0].last ? " looks" : " (spoken as one take) look"} long for the time before the next line`
+ : `${crowded.length} takes look long for their time (${crowded.slice(0, 4).map(takeLines).join(", ")}${crowded.length > 4 ? "…" : ""})`}
</span>{" "}
- — shorten {crowded.length === 1 ? "it" : "them"} or move the next line later.
+ — shorten the words or start the next line later.
</>
)}
</p>
diff --git a/src/lib/av/dub.ts b/src/lib/av/dub.ts
index 4022ec2a..918a5639 100644
--- a/src/lib/av/dub.ts
+++ b/src/lib/av/dub.ts
@@ -339,21 +339,23 @@ export function priceLine(p: DubPrice): string {
/** Characters a voice speaks per second, about (used to flag lines that won't fit before the next one). */
const SPOKEN_CPS = 16;
-/** Takes whose words likely run past the next take's start (it would be cut there): their first line's index. */
-export function crowdedLines(cues: Cue[], duration?: number): number[] {
+/** Takes whose words likely run past the next take's start (they'd be cut there): the lines (indexes) each take speaks. */
+export function crowdedLines(cues: Cue[], duration?: number): { first: number; last: number }[] {
const phrases = dubPhrases(cues, duration);
const length = trackLength(phrases, duration);
- const out: number[] = [];
+ const out: { first: number; last: number }[] = [];
phrases.forEach((p, i) => {
const room = (i + 1 < phrases.length ? phrases[i + 1].start : length) - p.start;
- if (p.text.length / SPOKEN_CPS > room + 0.25) {
- const first = cues.findIndex((c) => Math.max(0, c.start) === p.start && c.text.trim());
- if (first >= 0) out.push(first);
- }
+ if (p.text.length / SPOKEN_CPS <= room + 0.25) return;
+ const inside = cues.flatMap((c, k) => (c.text.trim() && Math.max(0, c.start) >= p.start && c.start < p.end ? [k] : []));
+ if (inside.length) out.push({ first: inside[0], last: inside.at(-1)! });
});
return out;
}
+/** "line 3", "lines 1–4": the lines a crowded take speaks. */
+export const takeLines = (t: { first: number; last: number }) => (t.first === t.last ? `line ${t.first + 1}` : `lines ${t.first + 1}–${t.last + 1}`);
+
/** A session with its generations, as the studio shows it. */
export interface DubSessionView extends DubSession {
generations: Record<string, Generation>;
diff --git a/tests/av-dub.test.ts b/tests/av-dub.test.ts
index 7757e2d2..dc1b549f 100644
--- a/tests/av-dub.test.ts
+++ b/tests/av-dub.test.ts
@@ -4,7 +4,7 @@ import path from "node:path";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import type { Generation } from "@/lib/catalog/types";
import { cueReducer, cueProblems, formatCueTime, normalizeCues, parseCueTime } from "@/lib/av/cue-edit";
-import { BLANK_FRAME, crowdedLines, dubPhrases, languageStage, oneShotRequests, PHRASE_MAX, prepareSteps, priceLine, reviewCues, spokenText, voiceSteps, type DubSessionView } from "@/lib/av/dub";
+import { BLANK_FRAME, crowdedLines, dubPhrases, languageStage, oneShotRequests, PHRASE_MAX, prepareSteps, priceLine, reviewCues, spokenText, takeLines, voiceSteps, type DubSessionView } from "@/lib/av/dub";
import { DUB_LANGUAGES, supportsTarget } from "@/lib/av/languages";
import { getModel } from "@/lib/catalog";
import { buildPayload } from "@/lib/catalog/payload";
@@ -95,7 +95,16 @@ describe("dub pipeline DAGs", () => {
{ start: 1.6, end: 3, text: "Corta" },
{ start: 10, end: 12, text: "Bien" },
];
- expect(crowdedLines(tight, 14)).toEqual([0]);
+ expect(crowdedLines(tight, 14)).toEqual([{ first: 0, last: 0 }]);
+ // Lines a breath apart are one take: the hint names them all.
+ const joined = [
+ { start: 0, end: 1, text: "Una frase demasiado larga para un segundo" },
+ { start: 1.1, end: 2, text: "y otra más que tampoco cabe aquí" },
+ { start: 2.5, end: 3, text: "Fin" },
+ ];
+ expect(crowdedLines(joined, 4)).toEqual([{ first: 0, last: 1 }]);
+ expect(takeLines({ first: 0, last: 1 })).toBe("lines 1–2");
+ expect(takeLines({ first: 2, last: 2 })).toBe("line 3");
expect(crowdedLines(cues, 30)).toEqual([]);
});