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 up dialogue: the DBS remix on your GPU or a hosted cleaner in the cloud, with a chip on audio and video results
Claudee6e88e88a6e5
diff --git a/src/app/api/audio-tools/route.ts b/src/app/api/audio-tools/route.tsindex d69de042..d20426a0 100644--- a/src/app/api/audio-tools/route.ts+++ b/src/app/api/audio-tools/route.ts@@ -14,7 +14,7 @@ const MESSAGES: Record<string, string> = {};/**- * Audio → Loop / extend, Join, Split soundtrack and Clean up voice (and a split's mix put back on its video), and Video+ * Audio → Loop / extend, Join, Split soundtrack (and its Clean up dialogue) and Clean up voice (and a split's mix put back on its video), and Video* tools → Remove dialogue: start a run; `?preview=1` only plans and prices it.*/async function post(request: Request) {@@ -29,7 +29,7 @@ async function post(request: Request) {? "Export the mix first": tool === "remove-dialogue" && path === "video"? "Add the video to take the dialogue out of"- : tool === "clean" && path === "media"+ : (tool === "clean" || tool === "clean-dialogue") && path === "media"? "Add the audio or video to clean": (MESSAGES[path] ?? "Check the settings");return Response.json({ error: msg }, { status: 400 });diff --git a/src/components/studio/result-actions.tsx b/src/components/studio/result-actions.tsxindex 758ed278..9d5ebbca 100644--- a/src/components/studio/result-actions.tsx+++ b/src/components/studio/result-actions.tsx@@ -99,6 +99,7 @@ export const ACTION_ICONS: Record<OutputActionId, LucideIcon> = {"split-soundtrack": SlidersVertical,"remove-dialogue": MicOff,"clean-voice": AudioWaveform,+ "clean-dialogue": AudioLines,"copy-text": Copy,"view-3d": Box,download: Download,diff --git a/src/lib/av/clean-dialogue.ts b/src/lib/av/clean-dialogue.tsnew file mode 100644index 00000000..99c2fc6e--- /dev/null+++ b/src/lib/av/clean-dialogue.ts@@ -0,0 +1,228 @@+import type { Engine, GenerationRequest } from "@/lib/catalog/types";+import type { ToolPlan, ToolStep } from "./audio-tools";+import { DBS_MODELS, dbsChannelsFor, separationPasses, splitTime, surroundSource, type DbsChannels, type SplitQuality } from "./split";++/**+ * Audio → Split soundtrack → Clean up dialogue (DBS D5, docs/research/dbs-separation-7.md §9 D5): the speech in a noisy or+ * musical recording made clear, on audio and video. Pure: the page and the server (src/server/audio-tools.ts, tool+ * "clean-dialogue") share it.+ *+ * - Open engine (ComfyUI + ComfyUI-DBS, CPU or GPU): one job on oss-dbs-remix (graph C, soundtrack-remix-dbs): the DBS+ * dialogue, with the music and effects mixed back under it at the level asked for (or left out). A video then gets the+ * result back with the stream-copy mux (oss-mux), the picture untouched. DBS takes out music and effects; measured on+ * the CPU ComfyUI (15 s clips), steady hum mostly went too (50 Hz about 50 dB lower) but hiss only about 10 dB, so the+ * page points to Clean up voice (RE-USE, src/lib/av/clean-voice.ts) and the cloud cleaners for that.+ * - Cloud: hosted speech cleaners under their own names (DBS isn't hosted, and SAM Audio in its place is the owner's call,+ * not taken: docs/handoff/owner-decisions.json samAudioCloud false), so the cloud gives the clean voice with nothing+ * under it: VEED Clean Audio (takes a video's file itself), DeepFilterNet 3 (audio only: a video's soundtrack is+ * extracted first) and ElevenLabs isolation. A video gets the voice back with fal's merge-audio-video.+ */++export const CLEAN_DIALOGUE_FEATURE = "clean-dialogue";+export const OPEN_MODEL = "oss-dbs-remix";+export const OPEN_MUX_MODEL = "oss-mux";+export const CLOUD_MUX_MODEL = "merge-audio-video";+export const EXTRACT_MODEL = "extract-soundtrack";++/** The page's address for the tool (Split soundtrack, opened on Clean up dialogue). */+export const CLEAN_DIALOGUE_PRESET = "clean-dialogue";+export const cleanDialogueHref = (kind: "audio" | "video", url: string): string => `/audio/split?${kind}=${encodeURIComponent(url)}&preset=${CLEAN_DIALOGUE_PRESET}`;++// ---------------------------------------------------------------------------+// The open engine: how loud the music and effects stay under the dialogue++/** "off" leaves the music and effects out; a number is their level in dB. */+export type BedLevel = "off" | number;+export const BED_LEVELS: BedLevel[] = ["off", -24, -18, -12];+export const DEFAULT_BED: BedLevel = -18;+/** What "off" sends: AudioAdjustVolume's floor, 1e-5, under a 16-bit FLAC's smallest step. */+export const OFF_DB = -100;+export const bedLabel = (b: BedLevel): string => (b === "off" ? "Dialogue only" : `Music & effects ${b} dB`);+/** A bed level from what a request or the page sent: a whole number from −40 to 0, or off. */+export function bedOf(v: unknown): BedLevel {+ if (v === "off" || v === null || v === false) return "off";+ const n = typeof v === "number" ? v : typeof v === "string" && v.trim() !== "" ? Number(v) : NaN;+ return Number.isFinite(n) ? Math.min(0, Math.max(-40, Math.round(n))) : DEFAULT_BED;+}++// ---------------------------------------------------------------------------+// The cloud cleaners++export type Cleaner = "veed" | "deepfilternet" | "isolation";+export const CLEANERS: { id: Cleaner; label: string; model: string; op: "enhance-voice" | "separate-audio"; hint: string; takesVideo: boolean }[] = [+ { id: "veed", label: "Clean (VEED)", model: "veed-clean-audio", op: "enhance-voice", hint: "Removes background noise and levels the voice. Keeps quiet and distant words.", takesVideo: true },+ { id: "deepfilternet", label: "Denoise (DeepFilterNet 3)", model: "deepfilternet3", op: "enhance-voice", hint: "Open-source denoiser for steady noise, hiss and hum.", takesVideo: false },+ { id: "isolation", label: "Voice only (ElevenLabs)", model: "elevenlabs-voice-isolation", op: "separate-audio", hint: "Keeps the voice and removes music, noise and everything else.", takesVideo: true },+];+export const cleanerOf = (id: Cleaner) => CLEANERS.find((c) => c.id === id)!;+export const DEFAULT_CLEANER: Cleaner = "veed";++/** VEED Clean Audio takes up to 30 minutes of audio (fal's model page). */+export const VEED_MAX_SECONDS = 30 * 60;++/** VEED's bill: whole seconds, then up to whole minutes, at least one, at $0.0125 a minute. */+export function veedPrice(seconds: number): number {+ return Math.max(1, Math.ceil(Math.round(Math.max(0, seconds)) / 60 - 1e-9)) * 0.0125;+}+/** DeepFilterNet 3's bill: $0.001 a second of audio. */+export const deepFilterNetPrice = (seconds: number): number => Math.max(0, seconds) * 0.001;++// ---------------------------------------------------------------------------+// Words++export const OPEN_NOTE = "Removes music and sound effects. For hiss and hum, use Clean up voice or a cloud cleaner.";+export const CLOUD_NOTE = "The cloud gives the clean voice on its own, with no music or effects under it.";+export const RELATION_NOTE = "Clean up voice repairs the voice itself (noise, echo, muffled sound) on your GPU. Clean up dialogue takes the music and effects out from under it.";++// ---------------------------------------------------------------------------+// The plan++export interface CleanDialogueInput {+ engine: Engine;+ /** The audio or video file (/api/files/…). */+ media: string;+ kind: "audio" | "video";+ name?: string;+ /** Open: the music and effects' level under the dialogue (or off). */+ bed?: BedLevel;+ /** Open: Fast (DBS-BSRNN) or Best (DBS-TIGER); unset = the host's pick. */+ quality?: SplitQuality;+ /** Open: keep a stereo recording stereo (every channel separated, about twice as long). */+ stereo?: boolean;+ /** Cloud: the hosted cleaner. */+ cleaner?: Cleaner;+ /** VEED: how much of the noise goes (0–1; its default 0.874 leaves the rest 18 dB down). */+ strength?: number;+ /** A video: put the clean soundtrack back on the picture (default on). */+ remux?: boolean;+ channels?: number;+ seconds?: number;+ /** The file has no sound track (from its header). */+ silent?: boolean;+}++export interface CleanDialoguePlan extends ToolPlan {+ bed: BedLevel | null;+ cleaner: Cleaner | null;+ mode: DbsChannels | null;+ remux: boolean;+}++const nameOf = (i: Pick<CleanDialogueInput, "name" | "kind">) => i.name?.trim() || (i.kind === "video" ? "video soundtrack" : "recording");++/** What's in the way of a run (in words the page shows), or null. */+export function cleanDialogueProblem(i: Pick<CleanDialogueInput, "engine" | "media" | "kind" | "silent" | "seconds" | "cleaner">): string | null {+ if (!i.media) return `Add the ${i.kind === "video" ? "video" : "audio"} to clean`;+ if (i.silent) return i.kind === "video" ? "This video has no sound to clean" : "This file has no sound to clean";+ if (i.engine === "cloud" && (i.cleaner ?? DEFAULT_CLEANER) === "veed" && i.seconds && i.seconds > VEED_MAX_SECONDS) return "VEED cleans up to 30 minutes — trim it first, or pick another cleaner";+ return null;+}++/** Throws what's in the way (in words the page shows). */+export function planCleanDialogue(i: CleanDialogueInput): CleanDialoguePlan {+ const problem = cleanDialogueProblem(i);+ if (problem) throw new Error(problem);+ const video = i.kind === "video";+ const remux = video && i.remux !== false;+ const name = nameOf(i);+ const title = `Clean dialogue · ${name}`;+ const seconds = i.seconds && i.seconds > 0 ? Math.round(i.seconds * 1000) / 1000 : undefined;+ const timed = seconds ? { sourceDuration: seconds } : {};+ const inputs = video ? { video: i.media } : { audio: i.media };+ const base = { feature: CLEAN_DIALOGUE_FEATURE, batchTitle: title } satisfies Partial<GenerationRequest>;+ const steps: ToolStep[] = [];++ if (i.engine === "open") {+ const bed = i.bed === undefined ? DEFAULT_BED : bedOf(i.bed);+ const mode = dbsChannelsFor(i.stereo ? "each channel" : "mono", i.channels);+ const level = bed === "off" ? OFF_DB : bed;+ const extra: Record<string, unknown> = { channels: mode, voiceDb: 0, musicDb: level, effectsDb: level };+ if (i.quality) extra.separationModel = DBS_MODELS[i.quality];+ if (i.channels && i.channels > 0) extra.sourceChannels = Math.round(i.channels);+ const of = remux ? 2 : 1;+ steps.push({+ key: "clean",+ request: {+ ...base,+ modelId: OPEN_MODEL,+ op: "separate-audio",+ title: remux ? `${title} · soundtrack` : title,+ inputs,+ params: { extra, ...timed },+ step: { label: bed === "off" ? "Dialogue only" : `Dialogue, music & effects at ${bed} dB`, index: 0, of },+ },+ });+ if (remux) {+ steps.push({+ key: "video",+ after: ["clean"],+ chain: [{ slot: "audio" }],+ request: { ...base, modelId: OPEN_MUX_MODEL, op: "mux", title, inputs: { video: i.media }, step: { label: "Clean soundtrack · picture copied", index: 1, of } },+ });+ }+ const surround = surroundSource(i.channels);+ return {+ steps,+ length: seconds ?? null,+ bed,+ cleaner: null,+ mode,+ remux,+ summary: `Takes the music and sound effects ${bed === "off" ? "out" : `down to ${bed} dB under the dialogue`}${mode === "each channel" ? `, every channel on its own (${separationPasses(mode, i.channels)} passes)` : ""}${remux ? ", then puts it back on the picture (copied as it is)" : ""}.`,+ notes: [+ OPEN_NOTE,+ ...(mode === "mono" && i.channels !== 1 && !surround ? ["The result is mono. Turn on Stereo to keep it stereo."] : []),+ ...(surround ? [`This file has ${i.channels} channels: it is cleaned in mono, as ComfyUI saves mono or stereo only.`] : []),+ ],+ };+ }++ // Cloud+ const cleaner = cleanerOf(i.cleaner ?? DEFAULT_CLEANER);+ const extract = video && !cleaner.takesVideo;+ const of = (extract ? 1 : 0) + 1 + (remux ? 1 : 0);+ let index = 0;+ if (extract) {+ steps.push({+ key: "sound",+ request: { ...base, modelId: EXTRACT_MODEL, op: "separate-audio", title: `${title} · soundtrack`, inputs: { video: i.media }, params: { ...timed }, step: { label: "The video's soundtrack", index: index++, of } },+ });+ }+ const strength = cleaner.id === "veed" && typeof i.strength === "number" && Number.isFinite(i.strength) ? Math.min(1, Math.max(0, i.strength)) : undefined;+ steps.push({+ key: "clean",+ ...(extract && { after: ["sound"], chain: [{ slot: "audio" }] }),+ request: {+ ...base,+ modelId: cleaner.model,+ op: cleaner.op,+ title: remux ? `${title} · voice` : title,+ inputs: extract ? {} : inputs,+ params: { ...timed, ...(strength !== undefined && { extra: { strength } }) },+ step: { label: cleaner.label, index: index++, of },+ },+ });+ if (remux) {+ steps.push({+ key: "video",+ after: ["clean"],+ chain: [{ slot: "audio" }],+ request: { ...base, modelId: CLOUD_MUX_MODEL, op: "mux", title, inputs: { video: i.media }, params: { ...timed }, step: { label: "Clean voice back on the video", index: index++, of } },+ });+ }+ return {+ steps,+ length: seconds ?? null,+ bed: null,+ cleaner: cleaner.id,+ mode: null,+ remux,+ summary: `${cleaner.hint}${remux ? " Then the clean voice goes back on the video." : ""}`,+ notes: [CLOUD_NOTE, ...(cleaner.id === "veed" ? ["VEED bills whole minutes, at least one, and returns 48 kHz mono at a steady loudness."] : [])],+ };+}++/** About how long the open engine takes (DBS's split; the remix and mux add a second or two). */+export function cleanDialogueTime(o: { seconds: number; quality: SplitQuality; mode: DbsChannels; channels?: number | null; device?: string | null }): { low: number; high: number } {+ return splitTime(o);+}diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.tsindex b130108e..600b706d 100644--- a/src/lib/catalog/models.ts+++ b/src/lib/catalog/models.ts@@ -1597,6 +1597,26 @@ const open: ModelDef[] = [],},}),+ // DBS graph C (docs/research/dbs-separation-7.md §4.4): the split mixed back into one track at set levels (params.extra+ // voiceDb, musicDb, effectsDb; whole dB, -100 = gone). Clean up dialogue (src/lib/av/clean-dialogue.ts) runs on it: the+ // dialogue alone, or with the music and effects quietly under it.+ o({+ id: "oss-dbs-remix",+ name: "DBS remix (dialogue, music, effects at set levels)",+ vendor: "Open source",+ family: "dbs",+ kind: "audio",+ tagline: "Takes the music and effects out from under the dialogue, or keeps them quietly · 23 MB · CPU or GPU · Apache-2.0",+ badges: ["new"],+ routes: [comfy("separate-audio", "soundtrack-remix-dbs", "one FLAC: the dialogue with the music and effects at the levels asked for + a speed report; ComfyUI-DBS")],+ options: {+ promptless: true,+ controls: [+ { param: "separationModel", label: "Model", values: ["DBS-BSRNN-DnR", "DBS-TIGER-DnR"], labels: { "DBS-BSRNN-DnR": "Fast (DBS-BSRNN)", "DBS-TIGER-DnR": "Best (DBS-TIGER)" } },+ { param: "channels", label: "Channels", values: ["mono", "each channel"], default: "mono", labels: { mono: "Mono", "each channel": "Stereo (about twice as long)" } },+ ],+ },+ }),// NVIDIA NemotronLabs RE-USE (universal speech enhancement) on Fuobe's own ComfyUI-RE-USE pack (comfy-nodes/, no mamba-ssm):// noise, echo, clipping, codec damage and phone-band audio fixed, the main speaker kept. Open engine only: nothing like it is// hosted on fal or Replicate. params.extra.background "keep" runs voice-clean-bed-reuse (DBS keeps the music and effects;diff --git a/src/lib/output-actions.ts b/src/lib/output-actions.tsindex eece3a23..3239958d 100644--- a/src/lib/output-actions.ts+++ b/src/lib/output-actions.ts@@ -14,6 +14,7 @@ import { decodeMoss, LAYOUT_PARAM, readLayout, type LayoutDraft } from "./layoutimport { REMOVE_DIALOGUE_FEATURE } from "./av/remove-dialogue";import { canRerender, regenerateFamily, regenerateHref, rerenderLabel } from "./catalog/regenerate";import { CLEAN_FEATURE } from "./av/clean-voice";+import { CLEAN_DIALOGUE_FEATURE, cleanDialogueHref } from "./av/clean-dialogue";export type OutputActionId =| "animate"@@ -35,6 +36,7 @@ export type OutputActionId =| "split-soundtrack"| "remove-dialogue"| "clean-voice"+ | "clean-dialogue"| "copy-text"| "view-3d"| "download"@@ -145,6 +147,8 @@ export function outputActions(g: Generation, index: number, ctx: ActionContext =link("remove-dialogue", "Remove dialogue", `/video-tools/remove-dialogue?video=${q(o.url)}`);// Clean up voice on a video's soundtrack: results that carry sound, and uploads (a clip from a phone or a call).if (g.feature === "upload" || (g.op && SOUNDED_VIDEO_OPS.has(g.op))) link("clean-voice", "Clean up voice", `/audio/clean?video=${q(o.url)}`);+ // Clean up dialogue (Split soundtrack's preset): the music and effects out from under the speech, or a cloud cleaner.+ if ((g.feature === "upload" || (g.op && SOUNDED_VIDEO_OPS.has(g.op))) && g.feature !== CLEAN_DIALOGUE_FEATURE) link("clean-dialogue", "Clean up dialogue", cleanDialogueHref("video", o.url));// A Fuobe DoP colour-grade effect: the clip opens in Color grading with its grade picked (one click to export).const dopGrade = gradeOf(o);link("grade", dopGrade ? `Apply the ${dopGrade.name} grade` : "Color grade", `/color-grade?video=${q(o.url)}${dopGrade ? `&preset=${q(dopGrade.id)}` : ""}`);@@ -159,6 +163,7 @@ export function outputActions(g: Generation, index: number, ctx: ActionContext =link("split-soundtrack", "Split soundtrack", `/audio/split?audio=${q(o.url)}`);// Not on music or sound effects (it keeps only a voice), nor on a voice it already cleaned.if (g.op !== "music" && g.op !== "sfx" && g.feature !== CLEAN_FEATURE) link("clean-voice", "Clean up voice", `/audio/clean?audio=${q(o.url)}`);+ if (g.op !== "music" && g.op !== "sfx" && g.feature !== CLEAN_DIALOGUE_FEATURE) link("clean-dialogue", "Clean up dialogue", cleanDialogueHref("audio", o.url));break;case "text":out.push({ id: "copy-text", label: "Copy", placement: "primary" }, file, { id: "favorite", label: g.favorite ? "Unfavorite" : "Favorite", placement: "bar" });diff --git a/src/server/audio-tools.ts b/src/server/audio-tools.tsindex 84b65d00..31a0a055 100644--- a/src/server/audio-tools.ts+++ b/src/server/audio-tools.ts@@ -3,6 +3,7 @@ import { z } from "zod";import { planJoin, planLoop, CROSSFADE_MAX, JOIN_MAX_CLIPS, LOOP_MAX_SECONDS, type AudioToolPreview, type ToolPlan } from "@/lib/av/audio-tools";import { CLOUD_ONLY_PROBLEM, DBS_MODELS, dbsChannelsFor, hostPick, missingDbs, planRemux, planSplit, splitTime } from "@/lib/av/split";import { CLOUD_ONLY_REMOVE_PROBLEM, LOWER_MAX_DB, LOWER_MIN_DB, NO_SOUND_PROBLEM, planRemoveDialogue, removeDialogueTime } from "@/lib/av/remove-dialogue";+import { planCleanDialogue } from "@/lib/av/clean-dialogue";import { CLOUD_ONLY_CLEAN_PROBLEM, missingReuse, NO_REUSE_PACK, planClean, planTime, tooLongProblem } from "@/lib/av/clean-voice";import type { Engine, Generation } from "@/lib/catalog/types";import { lastGpuDevice } from "./account-gpu";@@ -19,7 +20,8 @@ import { tenant, tenantAccount } from "./tenant";* the plan from src/lib/av/audio-tools.ts, src/lib/av/split.ts or src/lib/av/remove-dialogue.ts is priced step by step,* and a run is one createPipeline batch, so its results land in the Library like any generation. Split soundtrack and* Remove dialogue run on the open engine only (DBS isn't hosted); a split's mix goes back on the video with a "remux" run- * on either engine.+ * on either engine. Clean up dialogue (src/lib/av/clean-dialogue.ts) runs on both: DBS's remix on the open engine, a hosted+ * speech cleaner (VEED, DeepFilterNet 3, ElevenLabs isolation) in the cloud.*/const FileUrl = z.string().startsWith("/api/files/").max(500);@@ -89,6 +91,24 @@ export const AudioToolBody = z.discriminatedUnion("tool", [channels: z.number().int().positive().max(64).optional(),sourceDuration: z.number().positive().max(36_000).optional(),}),+ z.object({+ tool: z.literal("clean-dialogue"),+ engine: Engine,+ media: FileUrl,+ kind: z.enum(["audio", "video"]),+ name: z.string().max(200).optional(),+ /** Open: the music and effects' level under the dialogue (dB), or "off". */+ bed: z.union([z.literal("off"), z.number().int().min(-40).max(0)]).optional(),+ quality: z.enum(["fast", "best"]).optional(),+ stereo: z.boolean().optional(),+ /** Cloud: the hosted cleaner. */+ cleaner: z.enum(["veed", "deepfilternet", "isolation"]).optional(),+ strength: z.number().min(0).max(1).optional(),+ /** A video: put the clean soundtrack back on the picture (default on). */+ remux: z.boolean().optional(),+ channels: z.number().int().positive().max(64).optional(),+ sourceDuration: z.number().positive().max(36_000).optional(),+ }),z.object({tool: z.literal("remux"),engine: Engine,@@ -171,6 +191,12 @@ async function plan(body: AudioToolRequest): Promise<ToolPlan & { engine: Engineconst channels = facts?.channels ?? body.channels;return { engine: body.engine, ...planClean({ ...body, seconds, channels, silent: facts?.hasAudio === false }), split: { duration: seconds, channels }, headerChannels: facts?.channels };}+ if (body.tool === "clean-dialogue") {+ const facts = factsOf(body.media);+ const seconds = facts?.duration ?? body.sourceDuration;+ const channels = facts?.channels ?? body.channels;+ return { engine: body.engine, ...planCleanDialogue({ ...body, seconds, channels, silent: facts?.hasAudio === false }), split: { duration: seconds, channels }, headerChannels: facts?.channels };+ }if (body.tool === "remux") {present(body.audio, "That mix is gone — export it again");present(body.video, "That video is gone — add it again");@@ -204,7 +230,7 @@ export async function previewAudioTool(body: AudioToolRequest): Promise<AudioToocost = cost === null || r.costUsd === null ? null : cost + r.costUsd;}const out: AudioToolPreview = { summary: p.summary, notes: p.notes, length: p.length, steps: p.steps.length, costUsd: cost === null ? null : Math.round(cost * 1000) / 1000, demo };- if (body.tool === "split" || body.tool === "remove-dialogue") {+ if (body.tool === "split" || body.tool === "remove-dialogue" || (body.tool === "clean-dialogue" && body.engine === "open")) {// How long it takes on this host: its device (asked once a minute), the model it would use (one it has on disk) and// how many passes. A model the host doesn't have is refused here, before the run, with how to install it.// A visitor's price check (a guest's, or an account's on its own GPU) never calls a GPU, as main's price checks@@ -223,8 +249,8 @@ export async function previewAudioTool(body: AudioToolRequest): Promise<AudioTooif (installed && !installed.includes(DBS_MODELS[quality])) throw new AudioToolError(missingDbs(DBS_MODELS[quality], installed));const { duration: seconds, channels } = p.split ?? {};Object.assign(out, { hostPick: pick, ...(device && { device }), ...(installed && { installed: installed.map((m) => (m === DBS_MODELS.best ? "best" : "fast")) }), ...(p.headerChannels && { channels: p.headerChannels }) });- const mode = dbsChannelsFor(body.tool === "split" && body.stereo ? "each channel" : "mono", channels);- if (seconds) out.estimate = (body.tool === "split" ? splitTime : removeDialogueTime)({ seconds, quality, mode, channels, device });+ const mode = dbsChannelsFor((body.tool === "split" || body.tool === "clean-dialogue") && body.stereo ? "each channel" : "mono", channels);+ if (seconds) out.estimate = (body.tool === "remove-dialogue" ? removeDialogueTime : splitTime)({ seconds, quality, mode, channels, device });}if (body.tool === "clean") {// As Split: the host's device and its RE-USE files (and DBS's, to keep music & effects), asked live for the owner;diff --git a/src/server/gpu/tools.ts b/src/server/gpu/tools.tsindex b4f9e5a1..28f099bc 100644--- a/src/server/gpu/tools.ts+++ b/src/server/gpu/tools.ts@@ -1,6 +1,7 @@import "server-only";import { DUB_STEP_MODELS } from "@/lib/av/dub";import { SPLIT_MODEL } from "@/lib/av/split";+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";import { getModel, getPreset, MODELS, modelsFor, PRESETS } from "@/lib/catalog";@@ -220,6 +221,16 @@ export const STUDIO_ROWS: StudioRowDef[] = [{ href: "/audio/transcribe", label: "Transcribe", group: "Audio", config: S.TRANSCRIBE_STUDIO },// DBS soundtrack separation (D1): dialogue, music and effects.{ href: "/audio/split", label: "Split soundtrack", group: "Audio", steps: [{ modelId: SPLIT_MODEL, op: "separate-audio" }] },+ // Clean up dialogue (DBS D5, Split soundtrack's preset): graph C's remix, and the stream-copy mux for a video.+ {+ href: `/audio/split?preset=${CLEAN_DIALOGUE_PRESET}`,+ label: "Clean up dialogue",+ group: "Audio",+ steps: [+ { modelId: CLEAN_DIALOGUE_MODEL, op: "separate-audio" },+ { modelId: CLEAN_DIALOGUE_MUX, op: "mux" },+ ],+ },// Clean up voice (NVIDIA RE-USE on ComfyUI-RE-USE).{ href: "/audio/clean", label: "Clean up voice", group: "Audio", steps: [{ modelId: CLEAN_MODEL, op: "enhance-voice" }] },// Translate & dub on the open engine: the voice split with its transcript (the default split, MelBand RoFormer; DBSdiff --git a/src/server/providers/mock.ts b/src/server/providers/mock.tsindex 1f8bfff4..d429c39b 100644--- a/src/server/providers/mock.ts+++ b/src/server/providers/mock.ts@@ -295,6 +295,8 @@ function demoOutputs(op: Operation | undefined, kind: MediaKind, prompt: string,case "separate-audio": {const stem = (name: string, wav: Buffer): DemoOutput => ({ url: toDataUri(wav, "audio/wav"), kind: "audio", contentType: "audio/wav", meta: { stem: name, demo: true } });// A dialogue / music / effects split (DBS) returns those three and the music-and-effects bed, voice first.+ // A remix of the split at set levels (DBS graph C, Clean up dialogue): one track, the clean dialogue.+ if (meta.remix) return [stem("voice", demoWav(3, [220, 330], 3))];const stems: DemoOutput[] = meta.threeStems? [stem("voice", demoWav(3, [220, 330], 3)), stem("music", demoWav(3, [262, 392])), stem("effects", demoWav(3, [90, 140], 7)), stem("background", demoWav(3, [110, 165]))]: [stem("voice", demoWav(3, [220, 330], 3)), stem("background", demoWav(3, [110, 165]))];@@ -424,6 +426,8 @@ export const mockProvider: ProviderAdapter = {transcript: route.op === "separate-audio" && route.provider === "comfyui" && route.endpoint.includes("transcribe"),// A dialogue / music / effects split (ComfyUI's separate-soundtrack-dbs): four stems.threeStems: route.op === "separate-audio" && route.endpoint === "separate-soundtrack-dbs",+ // DBS graph C (soundtrack-remix-dbs): one remixed track.+ remix: route.op === "separate-audio" && route.endpoint === "soundtrack-remix-dbs",},payload: { demo: true, ...input },};diff --git a/tests/clean-dialogue.test.ts b/tests/clean-dialogue.test.tsnew file mode 100644index 00000000..3bdae048--- /dev/null+++ b/tests/clean-dialogue.test.ts@@ -0,0 +1,305 @@+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterAll, beforeAll, describe, expect, it } from "vitest";+import {+ bedOf,+ CLEAN_DIALOGUE_FEATURE,+ CLEAN_DIALOGUE_PRESET,+ cleanDialogueHref,+ cleanDialogueProblem,+ CLEANERS,+ CLOUD_NOTE,+ deepFilterNetPrice,+ OFF_DB,+ OPEN_NOTE,+ planCleanDialogue,+ VEED_MAX_SECONDS,+ veedPrice,+} from "@/lib/av/clean-dialogue";+import { buildPayload, extractOutputs } from "@/lib/catalog/payload";+import { estimateCost } from "@/lib/catalog/plan";+import { getModel } from "@/lib/catalog";+import type { Generation, GenInput } from "@/lib/catalog/types";++// Clean up dialogue (DBS D5): the plan per engine and cleaner, the cloud cleaners' prices and payloads against their+// research records, graph C (soundtrack-remix-dbs) in the manifest and its bindings, the hand-offs, and the API in demo+// mode.+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-clean-dialogue-"));+process.env.FUOBE_DATA_DIR = dir;+process.env.COMFYUI_URL = "http://127.0.0.1:9";++const { setSetting } = await import("@/server/settings");+const { saveFile } = await import("@/server/storage");+const gens = await import("@/server/generations");+const { prepareWorkflow } = await import("@/server/providers/comfyui");+const route = await import("@/app/api/audio-tools/route");+const { outputActions } = await import("@/lib/output-actions");+const { STUDIO_ROWS, studioTool } = await import("@/server/gpu/tools");++beforeAll(() => setSetting("demoMode", "auto"));+afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));++const ROOT = path.join(__dirname, "..");+const json = (f: string) => JSON.parse(fs.readFileSync(path.join(ROOT, f), "utf8"));+const research = json("docs/research/paid-model-apis-3.json").endpoints as { endpoint: string; inputs: Record<string, unknown>; license?: string; pricing?: { usd: number; unit: string } }[];+const record = (ep: string) => research.find((e) => e.endpoint === ep)!;+const AUDIO = "/api/files/uploads/2026-11-02/podcast.wav";+const VIDEO = "/api/files/uploads/2026-11-02/vlog.mp4";++describe("the plan on the open engine", () => {+ it("one DBS remix: the dialogue at 0 dB and the music and effects at −18 dB by default", () => {+ const p = planCleanDialogue({ engine: "open", media: AUDIO, kind: "audio", name: "Podcast", channels: 2, seconds: 20 });+ expect(p.steps).toHaveLength(1);+ const r = p.steps[0].request;+ expect(r).toMatchObject({ modelId: "oss-dbs-remix", op: "separate-audio", feature: CLEAN_DIALOGUE_FEATURE, inputs: { audio: AUDIO }, title: "Clean dialogue · Podcast" });+ expect(r.params).toEqual({ extra: { channels: "mono", voiceDb: 0, musicDb: -18, effectsDb: -18, sourceChannels: 2 }, sourceDuration: 20 });+ expect(p).toMatchObject({ bed: -18, cleaner: null, mode: "mono", remux: false, length: 20 });+ expect(p.notes).toContain(OPEN_NOTE);+ expect(p.notes).toContain("The result is mono. Turn on Stereo to keep it stereo.");+ });++ it("Dialogue only sends the music and effects to −100 dB; stereo and the model travel as asked", () => {+ const p = planCleanDialogue({ engine: "open", media: AUDIO, kind: "audio", bed: "off", stereo: true, quality: "best", channels: 2 });+ expect(p.steps[0].request.params?.extra).toMatchObject({ channels: "each channel", voiceDb: 0, musicDb: OFF_DB, effectsDb: OFF_DB, separationModel: "DBS-TIGER-DnR" });+ expect(p.summary).toContain("out, every channel on its own (2 passes)");+ // A surround file is cleaned in mono.+ const s = planCleanDialogue({ engine: "open", media: AUDIO, kind: "audio", stereo: true, channels: 6 });+ expect(s.mode).toBe("mono");+ expect(s.notes.some((n) => n.includes("6 channels"))).toBe(true);+ });++ it("a video gets its clean soundtrack back with the stream-copy mux", () => {+ const p = planCleanDialogue({ engine: "open", media: VIDEO, kind: "video", bed: -12 });+ expect(p.steps.map((s) => [s.key, s.request.modelId, s.request.op])).toEqual([+ ["clean", "oss-dbs-remix", "separate-audio"],+ ["video", "oss-mux", "mux"],+ ]);+ expect(p.steps[0].request.inputs).toEqual({ video: VIDEO });+ expect(p.steps[1]).toMatchObject({ after: ["clean"], chain: [{ slot: "audio" }], request: { inputs: { video: VIDEO } } });+ expect(p.steps[0].request.params?.extra).toMatchObject({ musicDb: -12, effectsDb: -12 });+ expect(planCleanDialogue({ engine: "open", media: VIDEO, kind: "video", remux: false }).steps).toHaveLength(1);+ });++ it("reads a bed level in whole dB from −40 to 0, or off", () => {+ expect([bedOf("off"), bedOf(-18), bedOf("-24"), bedOf(-60), bedOf(3), bedOf(-17.6), bedOf(undefined)]).toEqual(["off", -18, -24, -40, 0, -18, -18]);+ });+});++describe("the plan in the cloud", () => {+ it("one call for audio on each cleaner, named as itself", () => {+ for (const c of CLEANERS) {+ const p = planCleanDialogue({ engine: "cloud", media: AUDIO, kind: "audio", cleaner: c.id, seconds: 90 });+ expect(p.steps.map((s) => [s.request.modelId, s.request.op]), c.id).toEqual([[c.model, c.op]]);+ expect(p.steps[0].request.inputs).toEqual({ audio: AUDIO });+ expect(p.steps[0].request.params?.sourceDuration).toBe(90);+ expect(p.notes).toContain(CLOUD_NOTE);+ expect(p.bed).toBeNull();+ }+ expect(CLEANERS.map((c) => c.label)).toEqual(["Clean (VEED)", "Denoise (DeepFilterNet 3)", "Voice only (ElevenLabs)"]);+ });++ it("VEED and ElevenLabs read a video themselves; DeepFilterNet gets its extracted soundtrack; the voice goes back on the video", () => {+ const veed = planCleanDialogue({ engine: "cloud", media: VIDEO, kind: "video", cleaner: "veed", strength: 0.6 });+ expect(veed.steps.map((s) => s.request.modelId)).toEqual(["veed-clean-audio", "merge-audio-video"]);+ expect(veed.steps[0].request).toMatchObject({ inputs: { video: VIDEO }, params: { extra: { strength: 0.6 } } });+ expect(veed.steps[1]).toMatchObject({ after: ["clean"], chain: [{ slot: "audio" }], request: { op: "mux", inputs: { video: VIDEO } } });+ const dfn = planCleanDialogue({ engine: "cloud", media: VIDEO, kind: "video", cleaner: "deepfilternet" });+ expect(dfn.steps.map((s) => [s.key, s.request.modelId])).toEqual([+ ["sound", "extract-soundtrack"],+ ["clean", "deepfilternet3"],+ ["video", "merge-audio-video"],+ ]);+ expect(dfn.steps[1]).toMatchObject({ after: ["sound"], chain: [{ slot: "audio" }] });+ expect(planCleanDialogue({ engine: "cloud", media: VIDEO, kind: "video", cleaner: "isolation" }).steps.map((s) => s.request.modelId)).toEqual(["elevenlabs-voice-isolation", "merge-audio-video"]);+ // Strength is VEED's alone.+ expect(planCleanDialogue({ engine: "cloud", media: AUDIO, kind: "audio", cleaner: "deepfilternet", strength: 0.5 }).steps[0].request.params?.extra).toBeUndefined();+ });++ it("says what's in the way: no file, no sound, over VEED's 30 minutes", () => {+ expect(cleanDialogueProblem({ engine: "open", media: "", kind: "video" })).toBe("Add the video to clean");+ expect(cleanDialogueProblem({ engine: "cloud", media: AUDIO, kind: "audio", silent: true })).toBe("This file has no sound to clean");+ expect(cleanDialogueProblem({ engine: "cloud", media: AUDIO, kind: "audio", seconds: VEED_MAX_SECONDS + 1 })).toContain("30 minutes");+ expect(cleanDialogueProblem({ engine: "cloud", media: AUDIO, kind: "audio", cleaner: "isolation", seconds: VEED_MAX_SECONDS + 1 })).toBeNull();+ expect(() => planCleanDialogue({ engine: "open", media: AUDIO, kind: "audio", silent: true })).toThrow("no sound");+ });+});++describe("the cloud cleaners' prices", () => {+ const veed = getModel("veed-clean-audio")!;+ const dfn = getModel("deepfilternet3")!;+ const iso = getModel("elevenlabs-voice-isolation")!;++ it("VEED bills whole minutes of input, rounded up from whole seconds, at least one ($0.0125 a minute)", () => {+ const at = (s: number) => estimateCost(veed, { sourceDuration: s }, 1, "enhance-voice");+ expect([at(10), at(60), at(60.4), at(61), at(300.011), at(301), at(600), at(1800)]).toEqual([0.0125, 0.0125, 0.0125, 0.025, 0.063, 0.075, 0.125, 0.375].map((v) => Math.round(v * 1000) / 1000));+ expect(veedPrice(300.011)).toBeCloseTo(0.0625);+ expect(veedPrice(0)).toBe(0.0125);+ expect(record("veed/clean-audio").pricing).toMatchObject({ usd: 0.0125, unit: "minute" });+ });++ it("DeepFilterNet 3 bills $0.001 a second of audio; ElevenLabs isolation $0.10 a minute of the clip", () => {+ expect(estimateCost(dfn, { sourceDuration: 90 }, 1, "enhance-voice")).toBe(0.09);+ expect(deepFilterNetPrice(90)).toBeCloseTo(0.09);+ expect(estimateCost(iso, { sourceDuration: 90 }, 1, "separate-audio")).toBe(0.15);+ // A length the caller sets still wins.+ expect(estimateCost(iso, { sourceDuration: 90, duration: 30 }, 1, "separate-audio")).toBe(0.05);+ expect(record("fal-ai/deepfilternet3").pricing).toMatchObject({ usd: 0.001, unit: "second" });+ });++ it("records DeepFilterNet 3's licence as information", () => {+ expect(dfn.licence).toMatchObject({ licence: "MIT OR Apache-2.0", commercial: true });+ expect(record("fal-ai/deepfilternet3").license).toContain("MIT OR Apache-2.0");+ });+});++describe("the cloud payloads against the research schemas", () => {+ const fields = (ep: string) => Object.keys(record(ep).inputs);+ const mapOf = (id: string) => getModel(id)!.routes[0].map!;++ it("VEED: the file (audio or a video) as audio_url, FLAC out, the strength slider", () => {+ const a = buildPayload(mapOf("veed-clean-audio"), { seed: 1, audio: "https://x/a.wav", extra: { strength: 0.6 } } as GenInput);+ const v = buildPayload(mapOf("veed-clean-audio"), { seed: 1, video: "https://x/v.mp4" } as GenInput);+ expect(a).toMatchObject({ audio_url: "https://x/a.wav", output_format: "flac", strength: 0.6 });+ expect(v).toMatchObject({ audio_url: "https://x/v.mp4", output_format: "flac" });+ for (const k of [...Object.keys(a), ...Object.keys(v)]) expect(fields("veed/clean-audio"), k).toContain(k);+ });++ it("DeepFilterNet 3: audio_url and FLAC out", () => {+ const p = buildPayload(mapOf("deepfilternet3"), { seed: 1, audio: "https://x/a.wav" } as GenInput);+ expect(p).toEqual({ audio_url: "https://x/a.wav", audio_format: "flac" });+ for (const k of Object.keys(p)) expect(fields("fal-ai/deepfilternet3"), k).toContain(k);+ });++ it("reads each answer's audio file", () => {+ expect(extractOutputs({ audio: { url: "https://f/v.flac", content_type: "audio/flac" }, audio_duration: 12 }, "enhance-voice")[0]).toMatchObject({ url: "https://f/v.flac", kind: "audio" });+ expect(extractOutputs({ audio_file: { url: "https://f/d.flac", content_type: "audio/flac" }, timings: { inference: 1 } }, "enhance-voice")[0]).toMatchObject({ url: "https://f/d.flac", kind: "audio" });+ });+});++describe("graph C (soundtrack-remix-dbs)", () => {+ const manifest = json("workflows/comfyui/manifest.json");+ const entry = manifest.workflows.find((w: { id: string }) => w.id === "soundtrack-remix-dbs");+ const graph = json("workflows/comfyui/soundtrack-remix-dbs.json") as Record<string, { class_type: string; inputs: Record<string, unknown> }>;++ it("is in the manifest with its levels as bindings, one audio output, the DBS pack and weights, validated", () => {+ expect(entry).toMatchObject({ capability: "separate-audio", validated: true, vramGb: 0 });+ expect(Object.keys(entry.bindings)).toEqual(expect.arrayContaining(["audio", "separationModel", "channels", "voiceDb", "musicDb", "effectsDb"]));+ expect(entry.outputs.filter((o: { kind: string }) => o.kind === "audio")).toHaveLength(1);+ expect(entry.models.map((m: { file?: string; name?: string }) => m.file ?? m.name)).toEqual(expect.arrayContaining(["DBS-BSRNN-DnR/model.safetensors", "DBS-TIGER-DnR/model.safetensors"]));+ const req = json("workflows/comfyui/requirements.json");+ expect(req.workflows["soundtrack-remix-dbs"].packs["ComfyUI-DBS"]).toEqual(["DBSLoader", "DBSSeparate"]);+ });++ it("turns each DBS stem by its level and adds them up into one FLAC", () => {+ expect([graph["4"].inputs.audio, graph["5"].inputs.audio, graph["6"].inputs.audio]).toEqual([["3", 2], ["3", 0], ["3", 1]]);+ for (const k of ["4", "5", "6"]) expect(graph[k].class_type).toBe("AudioAdjustVolume");+ expect(graph["7"].inputs).toMatchObject({ audio1: ["4", 0], audio2: ["5", 0], merge_method: "add" });+ expect(graph["8"].inputs).toMatchObject({ audio1: ["7", 0], audio2: ["6", 0], merge_method: "add" });+ expect(graph["9"]).toMatchObject({ class_type: "SaveAudioAdvanced", inputs: { audio: ["8", 0], format: "flac" } });+ });++ it("the provider fills the levels, the model and the channels from the plan", async () => {+ const p = planCleanDialogue({ engine: "open", media: VIDEO, kind: "video", bed: -24, stereo: true, channels: 2 });+ const { workflow } = await prepareWorkflow("soundtrack-remix-dbs", { seed: 1, video: "vlog.mp4", extra: p.steps[0].request.params?.extra as Record<string, unknown> }, {+ generationId: "g1",+ op: "separate-audio",+ upload: async (_d, _t, name) => `up_${name}`,+ media: () => undefined,+ device: async () => "cpu",+ dbsModels: async () => undefined,+ });+ expect(workflow["1"].inputs.audio).toBe("vlog.mp4");+ expect([workflow["2"].inputs.model, workflow["3"].inputs.channels]).toEqual(["DBS-BSRNN-DnR", "each channel"]);+ expect([workflow["4"].inputs.volume, workflow["5"].inputs.volume, workflow["6"].inputs.volume]).toEqual([0, -24, -24]);+ });++ it("runs on oss-dbs-remix, an open model", () => {+ expect(getModel("oss-dbs-remix")).toMatchObject({ engine: "open", routes: [expect.objectContaining({ op: "separate-audio", provider: "comfyui", endpoint: "soundtrack-remix-dbs" })] });+ });+});++describe("hand-offs and the GPU pre-flight board", () => {+ const gen = (kind: "audio" | "video", op: Generation["op"], feature = "x"): Generation =>+ ({ id: "g", status: "succeeded", op, feature, modelId: "m", engine: "open", outputs: [{ url: "/api/files/a/b." + (kind === "audio" ? "wav" : "mp4"), kind }], request: {} }) as unknown as Generation;++ it("audio and video results open Split soundtrack on Clean up dialogue", () => {+ expect(cleanDialogueHref("audio", "/api/files/a/b.wav")).toBe(`/audio/split?audio=%2Fapi%2Ffiles%2Fa%2Fb.wav&preset=${CLEAN_DIALOGUE_PRESET}`);+ const a = outputActions(gen("audio", "tts"), 0).find((x) => x.id === "clean-dialogue");+ expect(a).toMatchObject({ label: "Clean up dialogue", href: cleanDialogueHref("audio", "/api/files/a/b.wav") });+ expect(outputActions(gen("video", "mux"), 0).find((x) => x.id === "clean-dialogue")?.href).toBe(cleanDialogueHref("video", "/api/files/a/b.mp4"));+ // Not on music or effects, nor on a result it made.+ for (const g of [gen("audio", "music"), gen("audio", "sfx"), gen("audio", "separate-audio", CLEAN_DIALOGUE_FEATURE)]) expect(outputActions(g, 0).some((x) => x.id === "clean-dialogue")).toBe(false);+ });++ it("has a row on the board: graph C and the mux", () => {+ const row = STUDIO_ROWS.find((r) => r.href === `/audio/split?preset=${CLEAN_DIALOGUE_PRESET}`)!;+ expect(row).toMatchObject({ label: "Clean up dialogue", group: "Audio" });+ expect(studioTool(row)!.workflows).toEqual(expect.arrayContaining(["soundtrack-remix-dbs", "video-mux-audio"]));+ });+});++describe("POST /api/audio-tools clean-dialogue (demo mode)", () => {+ const wav = () => {+ const n = 44100 * 2;+ const b = Buffer.alloc(44 + n * 4);+ b.write("RIFF", 0);+ b.writeUInt32LE(36 + n * 4, 4);+ b.write("WAVEfmt ", 8);+ b.writeUInt32LE(16, 16);+ b.writeUInt16LE(1, 20);+ b.writeUInt16LE(2, 22);+ b.writeUInt32LE(44100, 24);+ b.writeUInt32LE(44100 * 4, 28);+ b.writeUInt16LE(4, 32);+ b.writeUInt16LE(16, 34);+ b.write("data", 36);+ b.writeUInt32LE(n * 4, 40);+ return saveFile({ data: b, contentType: "audio/wav", name: "take.wav", source: "upload" }).url;+ };+ const post = (body: unknown, preview = false) =>+ route.POST(new Request(`http://x/api/audio-tools${preview ? "?preview=1" : ""}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }));++ it("prices the open remix as free with a time estimate, and runs it into the Library as one track", async () => {+ const media = wav();+ const p = await (await post({ tool: "clean-dialogue", engine: "open", media, kind: "audio", name: "Take" }, true)).json();+ expect(p).toMatchObject({ steps: 1, costUsd: 0, demo: true, length: 2, channels: 2, hostPick: "fast" });+ expect(p.estimate).toBeDefined();+ const res = await post({ tool: "clean-dialogue", engine: "open", media, kind: "audio", name: "Take", bed: "off" });+ expect(res.status).toBe(201);+ const run = await res.json();+ expect(run.result).toMatchObject({ modelId: "oss-dbs-remix", feature: CLEAN_DIALOGUE_FEATURE });+ const deadline = Date.now() + 15_000;+ let g = gens.getGeneration(run.result.id)!;+ while (g.status !== "succeeded" && g.status !== "failed" && Date.now() < deadline) {+ await new Promise((r) => setTimeout(r, 200));+ g = gens.getGeneration(run.result.id)!;+ }+ expect(g.status).toBe("succeeded");+ expect(g.outputs.filter((o) => o.kind === "audio")).toHaveLength(1);+ }, 30_000);++ it("prices each cloud cleaner on the file's length", async () => {+ const media = wav();+ const priced = async (cleaner: string) => (await (await post({ tool: "clean-dialogue", engine: "cloud", media, kind: "audio", cleaner }, true)).json()) as { costUsd: number | null; demo: boolean; steps: number };+ const veed = await priced("veed");+ const dfn = await priced("deepfilternet");+ const iso = await priced("isolation");+ expect([veed.steps, dfn.steps, iso.steps]).toEqual([1, 1, 1]);+ // Demo mode runs the placeholder, but the price shown is the cleaner's.+ if (!veed.demo) expect([veed.costUsd, dfn.costUsd, iso.costUsd]).toEqual([0.013, 0.002, 0.003]);+ });++ it("an install set to paid APIs only keeps the cloud cleaners and refuses the open remix", async () => {+ const media = wav();+ setSetting("engineMode", "cloud");+ try {+ expect((await post({ tool: "clean-dialogue", engine: "cloud", media, kind: "audio" }, true)).status).toBe(200);+ const open = await post({ tool: "clean-dialogue", engine: "open", media, kind: "audio" }, true);+ expect(open.status).toBe(422);+ expect((await open.json()).error).toContain("paid cloud APIs only");+ } finally {+ setSetting("engineMode", "both");+ }+ });+});