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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Clean the voice first: off for an uploaded voice in Lipsync, says when a voice is already clean, and Captions and the lip re-sync show its graphs on the GPU pre-flight board
Claude677a0567e722
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsxindex 082bcb6b..ddeb94c0 100644--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@ -112,7 +112,7 @@ import { SketchTools } from "./sketch-tools";import { RECENT_MODELS, useStoredList } from "./stored-list";import { usePresetUrl, useStartRequest, useStudio, type Draft } from "./studio-context";import { useEdgeFade } from "./use-edge-fade";-import { CleanVoiceSlot, CleanVoiceSwitch, useVoiceCleaning } from "@/components/audio-tools/clean-voice-switch";+import { CleanVoiceSlot, CleanVoiceSwitch, useVoiceCleaning, type CleanedSlot } from "@/components/audio-tools/clean-voice-switch";import { useSignature } from "../palettes/use-signature";import { placeholdersOn } from "@/lib/demo-mode";@@ -590,13 +590,15 @@ export function Composer({ docked }: { docked: boolean }) {return { mentions, sketched, signed, request: m ? stripMotionPaths(sketched.request, m) : sketched.request };};const { mentions, sketched, signed } = prepare(draft);- // "Clean the voice first" (Transcribe, Lipsync): on by default for a video, off for an audio upload; a pick holds+ // "Clean the voice first" (Transcribe, Lipsync): on by default for a video's soundtrack, off for an audio upload; a pick holds// while the same speech file stays attached. The speech's header times or prices the step.const vfOp = studioOp ?? (model ? inferOperation(model, signed.request) : undefined);const vfSource = config.voiceFirst ? voiceSource(signed.request, vfOp) : null;const vfApplies = !!config.voiceFirst && voiceFirstApplies(signed.request, vfOp) && !draft.slots.audio?.uploading && !draft.slots.video?.uploading;const [vfPick, setVfPick] = useState<{ ref: string; on: boolean } | null>(null);- const voiceFirstOn = vfApplies && (vfPick && vfPick.ref === vfSource?.url ? vfPick.on : voiceFirstDefault(signed.request, vfOp));+ // A voice "Clean up voice" already cleaned as it was added starts off and says so: it isn't cleaned twice unless asked.+ const vfCleaned = !!vfSource && !!(draft.slots[vfSource.slot] as CleanedSlot | undefined)?.original;+ const voiceFirstOn = vfApplies && (vfPick && vfPick.ref === vfSource?.url ? vfPick.on : !vfCleaned && voiceFirstDefault(signed.request, vfOp));const vfFacts = useClipFacts(vfApplies ? vfSource?.url : undefined).data;const vfClip = useClipFacts(vfApplies && vfOp === "lipsync" ? signed.request.inputs?.video : undefined).data;const vfEngine = model?.engine ?? engine;@@ -1297,6 +1299,7 @@ export function Composer({ docked }: { docked: boolean }) {device={ownGpuOf(status)?.device}bed={vfBed}clip={vfOp === "lipsync" && !!signed.request.inputs?.video && vfClip?.hasAudio !== false}+ cleaned={vfCleaned}getModel={catalog.getModel}/>)}diff --git a/src/components/studio/voice-first-switch.tsx b/src/components/studio/voice-first-switch.tsxindex a83201eb..bab544a6 100644--- a/src/components/studio/voice-first-switch.tsx+++ b/src/components/studio/voice-first-switch.tsx@@ -2,7 +2,7 @@import { useId } from "react";import { Switch } from "@/components/ui/switch";-import { BED_NOTES, VOICE_FIRST_HINTS, VOICE_FIRST_LABEL, voiceFirstLine } from "@/lib/av/voice-first";+import { BED_NOTES, BED_OFF_NOTE, VOICE_FIRST_CLEANED_HINT, VOICE_FIRST_HINTS, VOICE_FIRST_LABEL, voiceFirstLine } from "@/lib/av/voice-first";import type { Engine, ModelDef } from "@/lib/catalog/types";import { cn } from "@/lib/utils";@@ -10,7 +10,9 @@ import { cn } from "@/lib/utils";* "Clean the voice first" (src/lib/av/voice-first.ts) where speech feeds a model: Transcribe, Lipsync & avatars,* Captions, Genjutsu's "What's said" and Character Swap Studio's transcript. One line: the switch, what it does on this* engine, and what it adds (time on your GPU, the price in the cloud). For a lip re-sync of a clip, a second line says- * what happens to the clip's music and effects. Always the same height, on or off, so nothing moves.+ * what happens to the clip's music and effects (on your GPU with the switch off, that turning it on puts them back). A voice+ * already cleaned as it was added ("Clean up voice" beside the slot) says so in place of the hint. Always the same+ * height, on or off, so nothing moves.*/export function VoiceFirstSwitch({engine,@@ -20,6 +22,7 @@ export function VoiceFirstSwitch({device,bed,clip,+ cleaned,getModel,price,className,@@ -35,6 +38,8 @@ export function VoiceFirstSwitch({bed?: boolean;/** A lip re-sync of a clip: say what happens to its music and effects. */clip?: boolean;+ /** The voice was already cleaned when it was added (D5's "Clean up voice"). */+ cleaned?: boolean;/** The catalog, where the page has it (its price for the cloud step); else the step's list price. */getModel?: (id: string) => ModelDef | undefined;/** The price line, when the page has its own (Character Swap Studio's estimate). */@@ -50,11 +55,11 @@ export function VoiceFirstSwitch({<Switch id={id} checked={on} onCheckedChange={onChange} className="mt-px shrink-0" /><label htmlFor={id} className="min-w-0 flex-1 text-[12px] leading-snug"><span className="font-medium">{VOICE_FIRST_LABEL}</span>- <span className="text-muted-foreground"> · {VOICE_FIRST_HINTS[engine]}</span>+ <span className="text-muted-foreground"> · {cleaned ? VOICE_FIRST_CLEANED_HINT : VOICE_FIRST_HINTS[engine]}</span></label><span className="basis-full pl-11 font-mono text-[11px] text-muted-foreground tabular-nums sm:basis-auto sm:shrink-0 sm:pl-0">{line}</span></div>- {clip && <p className="pl-11 text-[11.5px] leading-snug text-muted-foreground">{BED_NOTES[engine]}</p>}+ {clip && <p className="pl-11 text-[11.5px] leading-snug text-muted-foreground">{engine === "open" && !on ? BED_OFF_NOTE : BED_NOTES[engine]}</p>}</div>);}diff --git a/src/lib/av/voice-first.ts b/src/lib/av/voice-first.tsindex 0a1890e5..6a7ce7f3 100644--- a/src/lib/av/voice-first.ts+++ b/src/lib/av/voice-first.ts@@ -17,8 +17,9 @@ import { durationWords, splitTime, SPLIT_MODEL, type SplitQuality } from "./spli* nowhere, and SAM Audio in its place is the owner's call, not taken (docs/handoff/owner-decisions.json* samAudioCloud: false), so the music and effects don't go back under a cloud lip sync, and the switch says so.*- * Default on for a video (a soundtrack usually has music or effects under the speech), off for an audio upload (usually- * speech alone): a guess until the separation evaluation (D4) measures transcripts with and without it.+ * Default on for a video's soundtrack (it usually has music or effects under the speech), off for an audio upload (a+ * recording, a lip sync's voice: usually speech alone): a guess until the separation evaluation (D4) measures transcripts+ * with and without it.*/export const VOICE_FIRST_LABEL = "Clean the voice first";@@ -42,6 +43,12 @@ export const VOICE_FIRST_HINTS: Record<Engine, string> = {cloud: "ElevenLabs isolates the voice first: music and noise are taken out",};+/** The hint when the voice was already cleaned as it was added ("Clean up voice" beside the slot). */+export const VOICE_FIRST_CLEANED_HINT = "Your voice was already cleaned when you added it";++/** On your GPU with the switch off: what turning it on does for a lip re-sync of a clip with sound. */+export const BED_OFF_NOTE = "Turn it on to put the clip's music and effects back under it.";+/** What a lip re-sync on a video does with the clip's own music and effects, per engine. */export const BED_NOTES: Record<Engine, string> = {open: "The clip's music and effects go back under the new lip movement.",@@ -62,14 +69,12 @@ export function voiceSource(req: Pick<GenerationRequest, "inputs">, op: Operatio}/**- * The switch's default: on when the speech comes with a picture (a video to transcribe, a clip in Lipsync), off for an- * audio upload with a portrait, or a recording to transcribe, which is usually speech alone.+ * The switch's default: on when the speech is a video's soundtrack (a video to transcribe), off when it is an audio+ * upload (a recording to transcribe, a lip sync's or avatar's voice), which is usually speech alone. A lip re-sync's+ * voice is an audio upload too, so it starts off; turned on, on your GPU it also puts the clip's music and effects back.*/export function voiceFirstDefault(req: Pick<GenerationRequest, "inputs">, op: Operation | undefined): boolean {- const src = voiceSource(req, op);- if (!src) return false;- if (op === "transcribe") return src.slot === "video";- return !!req.inputs?.video;+ return voiceSource(req, op)?.slot === "video";}/** Whether a run puts the clip's music and effects back after the lip sync (open engine, a clip with sound). */diff --git a/src/server/gpu/tools.ts b/src/server/gpu/tools.tsindex 3df51115..4587881a 100644--- a/src/server/gpu/tools.ts+++ b/src/server/gpu/tools.ts@@ -1,6 +1,8 @@import "server-only";import { DUB_STEP_MODELS } from "@/lib/av/dub";import { SPLIT_MODEL } from "@/lib/av/split";+import { BED_MUX_MODEL, VOICE_FIRST_MODELS } from "@/lib/av/voice-first";+import { BURN_MODELS } from "@/lib/av/captions";import { CLEAN_DIALOGUE_PRESET, OPEN_MODEL as CLEAN_DIALOGUE_MODEL, OPEN_MUX_MODEL as CLEAN_DIALOGUE_MUX } from "@/lib/av/clean-dialogue";import { REMOVE_DIALOGUE_MODELS } from "@/lib/av/remove-dialogue";import { CLEAN_MODEL } from "@/lib/av/clean-voice";@@ -186,6 +188,18 @@ export const STUDIO_ROWS: StudioRowDef[] = [{ href: "/extend", label: "Extend", group: "Video", config: S.EXTEND_STUDIO },{ href: "/reframe", label: "Reframe", group: "Video", config: S.REFRAME_STUDIO },{ href: "/lipsync", label: "Lipsync", group: "Video", config: S.LIPSYNC_STUDIO },+ // Clean the voice first (DBS D6) on a lip re-sync of a clip: the voice cleaned, the re-sync on it, and the clip's music+ // and effects put back by the stream-copy mux (its own DBS pass, the same graph).+ {+ href: "/lipsync?model=oss-infinitetalk-v2v",+ label: "Lip re-sync, voice cleaned",+ group: "Video",+ steps: [+ { modelId: VOICE_FIRST_MODELS.open, op: "separate-audio" },+ { modelId: "oss-infinitetalk-v2v", op: "lipsync" },+ { modelId: BED_MUX_MODEL, op: "mux" },+ ],+ },{ href: "/character-swap", label: "Character swap", group: "Video", workflows: [STUDIO_WORKFLOWS.mask, STUDIO_WORKFLOWS.segment] },// Cinema's 3D scene films a still along a keyframed camera path (N7-5).{ href: "/cinema", label: "Fly path", group: "Video", steps: [{ modelId: PATH_MODELS.open, op: "camera-path" }] },@@ -302,6 +316,17 @@ export const STUDIO_ROWS: StudioRowDef[] = [{ modelId: REMOVE_DIALOGUE_MODELS.mux, op: "mux" },],},+ // Captions on your GPU: the voice cleaned first (on by default for the clip, DBS D6), its words, and the burn-in.+ {+ href: "/video-tools/captions",+ label: "Captions",+ group: "Video tools",+ steps: [+ { modelId: VOICE_FIRST_MODELS.open, op: "separate-audio" },+ { modelId: "oss-qwen3-asr", op: "transcribe" },+ { modelId: BURN_MODELS.open, op: "captions" },+ ],+ },{ href: "/video-tools/relight", label: "Relight", group: "Video tools", config: S.VIDEO_RELIGHT_STUDIO },{ href: "/video-tools/depth", label: "Depth map", group: "Video tools", config: S.VIDEO_DEPTH_STUDIO },{ href: "/video-tools/join", label: "Join clips", group: "Video tools", config: S.JOIN_CLIPS_STUDIO },diff --git a/tests/e2e/voice-first.mjs b/tests/e2e/voice-first.mjsindex 481adfda..52060bbc 100644--- a/tests/e2e/voice-first.mjs+++ b/tests/e2e/voice-first.mjs@@ -2,7 +2,7 @@// Usage: node tests/e2e/voice-first.mjs [appUrl] [outDir] (the app in demo mode: no keys, no ComfyUI)// Checks, at 1440 px and 390 px in light and dark: Transcribe with a video shows the switch on with its hint and "Free ·// adds …" on the open engine, and its price on the cloud; with a recording only, off. Lipsync with a clip and a voice-// shows it on and says the clip's music and effects go back (open) or don't (cloud). Captions shows it on under+// shows it off (the voice is an upload); turned on, it says the clip's music and effects go back (open) or don't (cloud). Captions shows it on under// "Transcribe the speech". Toggling never changes the composer's height, nothing scrolls sideways, no console errors.// Screenshots go to outDir.import { spawnSync } from "node:child_process";@@ -87,7 +87,7 @@ try {await page.waitForTimeout(500);check(!(await switchOn(page)), `${l} Transcribe: off for a recording`);- // Lipsync: a clip and a voice → on, and what happens to the clip's music and effects.+ // Lipsync: a clip and a voice → off, then on, and what happens to the clip's music and effects.// A lip re-sync model on each engine (the studio opens on a talking-avatar model).await openRoute(page, `${app}/lipsync?model=${engine === "open" ? "oss-infinitetalk-v2v" : "sync-lipsync-3"}`);await page.locator('[data-slot-key="video"] input[type="file"]').setInputFiles(mp4);@@ -95,7 +95,13 @@ try {await sw(page).waitFor({ timeout: 60_000 });// The voice's header times or prices the step (a moment after the upload).await sw(page).getByText(engine === "open" ? /Free · adds (under|about)/ : /\+\$0\.0\d$/).waitFor({ timeout: 30_000 }).catch(() => {});- check(await switchOn(page), `${l} Lipsync: on for a re-sync of a clip`);+ // The voice is an audio upload: off, and on your GPU it says turning it on puts the clip's music and effects back.+ check(!(await switchOn(page)), `${l} Lipsync: off for an uploaded voice`);+ const offNote = engine === "open" ? "Turn it on to put the clip's music and effects back" : "keeps the clean voice only";+ await sw(page).getByText(offNote).waitFor({ timeout: 30_000 }).catch(() => {});+ check(await sw(page).getByText(offNote).isVisible(), `${l} Lipsync: says what turning it on does for the clip's music and effects`);+ await sw(page).getByRole("switch").click();+ check(await switchOn(page), `${l} Lipsync: turns on`);const note = engine === "open" ? "go back under the new lip movement" : "keeps the clean voice only";await sw(page).getByText(note).waitFor({ timeout: 30_000 }).catch(() => {});check(await sw(page).getByText(note).isVisible(), `${l} Lipsync: says what happens to the clip's music and effects`);diff --git a/tests/voice-first.test.ts b/tests/voice-first.test.tsindex 7ab729a8..19126768 100644--- a/tests/voice-first.test.ts+++ b/tests/voice-first.test.ts@@ -35,6 +35,8 @@ const { createPipeline } = await import("@/server/chains");const { transcribeClip } = await import("@/server/genjutsu");const { changeAccess } = await import("@/server/model-access");const { planTranscribe } = await import("@/lib/catalog/swap-studio-plan");+const { STUDIO_ROWS, studioTool, toolFor } = await import("@/server/gpu/tools");+const { loadIndex } = await import("@/server/gpu/index-file");beforeAll(() => setSetting("demoMode", "auto"));afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));@@ -57,12 +59,14 @@ describe("where it applies, and its default", () => {expect(voiceFirstApplies({ inputs: {} }, "transcribe")).toBe(false);});- it("is on for a video and off for an audio upload", () => {+ it("is on for a video's soundtrack and off for an audio upload, a lip sync's voice included", () => {expect(voiceFirstDefault({ inputs: { video: VIDEO } }, "transcribe")).toBe(true);expect(voiceFirstDefault({ inputs: { audio: AUDIO } }, "transcribe")).toBe(false);- expect(voiceFirstDefault({ inputs: { video: VIDEO, audio: AUDIO } }, "lipsync")).toBe(true);+ // A lip re-sync's voice is an audio upload: off, though turned on it puts the clip's music and effects back on your GPU.+ expect(voiceFirstDefault({ inputs: { video: VIDEO, audio: AUDIO } }, "lipsync")).toBe(false);+ expect(putsBedBack({ inputs: { video: VIDEO, audio: AUDIO } }, "lipsync", "open")).toBe(true);expect(voiceFirstDefault({ inputs: { images: ["/api/files/a.png"], audio: AUDIO } }, "avatar")).toBe(false);- expect(voiceFirstDefault({ inputs: { video: VIDEO, audio: AUDIO } }, "avatar")).toBe(true);+ expect(voiceFirstDefault({ inputs: { video: VIDEO, audio: AUDIO } }, "avatar")).toBe(false);});it("puts the music and effects back only after a lip re-sync on your GPU of a clip with sound", () => {@@ -318,6 +322,25 @@ describe("previewGeneration with voiceFirst", () => {expect(open.costUsd).toBe(0);});+ it("leaves the price unknown when the clean voice's price isn't known, never the main step's alone", () => {+ const iso = getModel("elevenlabs-voice-isolation")!;+ const pricing = iso.pricing;+ const audio = voice();+ // Priced as paid (the demo is free): a key on the install, demo mode off.+ setSetting("demoMode", "off");+ setSetting("falKey", "test-fal-key");+ try {+ expect(gens.previewGeneration({ ...transcript({ audio }, "scribe-v2"), voiceFirst: true }).costUsd).toBeGreaterThan(gens.previewGeneration(transcript({ audio }, "scribe-v2")).costUsd!);+ (iso as { pricing?: unknown }).pricing = undefined;+ expect(gens.previewGeneration(transcript({ audio }, "scribe-v2")).costUsd).not.toBeNull();+ expect(gens.previewGeneration({ ...transcript({ audio }, "scribe-v2"), voiceFirst: true }).costUsd).toBeNull();+ } finally {+ (iso as { pricing?: unknown }).pricing = pricing;+ setSetting("falKey", "");+ setSetting("demoMode", "auto");+ }+ });+it("says what a lip re-sync does with the clip's music and effects on each engine", () => {const req = (modelId: string) => ({ ...lipsync({ video: clip(), audio: voice() }, modelId), voiceFirst: true });expect(gens.previewGeneration(req("oss-infinitetalk-v2v")).notes).toContain(BED_NOTES.open);@@ -343,3 +366,23 @@ describe("the studios that transcribe a clip", () => {expect(planTranscribe(c, "cloud", true)[0].request).toMatchObject({ modelId: "scribe-v2", voiceFirst: true });});});++describe("the GPU pre-flight board", () => {+ it("lists the clean voice's graph for Captions and a lip re-sync with its music put back", () => {+ const idx = loadIndex();+ const want: Record<string, string[]> = {+ "/video-tools/captions": ["separate-soundtrack-dbs"],+ "/lipsync?model=oss-infinitetalk-v2v": ["separate-soundtrack-dbs", "video-mux-audio"],+ };+ for (const [href, workflows] of Object.entries(want)) {+ const row = STUDIO_ROWS.find((r) => r.href === href);+ expect(row, href).toBeDefined();+ const t = studioTool(row!)!;+ expect(t, href).not.toBeNull();+ for (const wf of workflows) expect(t.workflows, href).toContain(wf);+ for (const wf of t.workflows) expect(idx.workflows[wf], `${href}: ${wf}`).toBeDefined();+ expect(toolFor(`studio:${href}`)?.workflows).toEqual(t.workflows);+ }+ expect(new Set(STUDIO_ROWS.map((r) => r.href)).size).toBe(STUDIO_ROWS.length);+ });+});