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: a switch with its time or price in Transcribe, Lipsync, Captions, Genjutsu's clip words and Character Swap Studio's transcript
Claude329bea95350c
diff --git a/src/components/captions/captions-studio.tsx b/src/components/captions/captions-studio.tsxindex 9ce0466e..3f800e19 100644--- a/src/components/captions/captions-studio.tsx+++ b/src/components/captions/captions-studio.tsx@@ -12,6 +12,7 @@ import { realDuration } from "@/components/av/frame-sampler";import { SourceLanguageSelect } from "@/components/av/language-picker";import { MediaDrop } from "@/components/av/media-drop";import { StepList } from "@/components/av/step-list";+import { VoiceFirstSwitch } from "@/components/studio/voice-first-switch";import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";import { useGeneration } from "@/components/av/use-generation";import { useCreateGeneration, useEngine, useGenerations } from "@/lib/api";@@ -146,6 +147,8 @@ function Editor({ video, restored, onReplace }: { video: SlotValue; restored: Saconst [look, setLook] = useState<CaptionLook>(restored?.look ?? DEFAULT_LOOK);const [transcriptId, setTranscriptId] = useState<string | undefined>(restored?.transcriptId);const [source, setSource] = useState("auto");+ // "Clean the voice first": on for a video (music and effects under the speech blur the words), free on your GPU.+ const [voiceFirst, setVoiceFirst] = useState(true);const [quick, setQuick] = useState(false);const transcript = useGeneration(transcriptId);const player = useRef<HTMLVideoElement>(null);@@ -179,7 +182,7 @@ function Editor({ video, restored, onReplace }: { video: SlotValue; restored: Sa}, [video, cues, look, transcriptId]);const transcribe = () =>- create.mutate(transcribeRequest({ engine, video: video.ref, sourceLanguage: source }), {+ create.mutate(transcribeRequest({ engine, video: video.ref, sourceLanguage: source, voiceFirst, seconds: duration }), {onSuccess: (items) => {loaded.current = null;setTranscriptId(items[0].id);@@ -256,6 +259,7 @@ function Editor({ video, restored, onReplace }: { video: SlotValue; restored: Sa{transcribing ? <Loader2 className="size-4 animate-spin" /> : <Captions className="size-4" />}{transcribing ? "Transcribing…" : "Transcribe the speech"}</Button>+ <VoiceFirstSwitch className="mt-3" engine={engine} on={voiceFirst} onChange={setVoiceFirst} seconds={duration} /><p className="mt-2 text-[12px] text-muted-foreground">{engine === "open" ? "Detects 30 languages." : "ElevenLabs Scribe v2 (word timings, ≈ $0.008 per minute)."}</p>{t && <StepList className="mt-3" steps={[{ key: "t", label: "Transcript", g: t }]} />}</div>diff --git a/src/components/genjutsu/character-panel.tsx b/src/components/genjutsu/character-panel.tsxindex 7e55ad56..459fa8f0 100644--- a/src/components/genjutsu/character-panel.tsx+++ b/src/components/genjutsu/character-panel.tsx@@ -32,6 +32,7 @@ import {import type { GenjutsuTarget, Maker } from "@/lib/catalog/genjutsu";import { cloudSharpenUsd, OPEN_TIER_OFF, SHARPEN_COPY, type SharpenTier } from "@/lib/catalog/sharpen";import type { Engine } from "@/lib/catalog/types";+import { VoiceFirstSwitch } from "@/components/studio/voice-first-switch";/** The Quality field's short hint: H3's own sizes in words, a finishing size's price (cloud) or "Free · your GPU". */export function qualityShort(engine: Engine, q: CharacterChoice): string {@@ -92,8 +93,8 @@ export function CharacterControls({seedProblem?: string | null;/** "Describe my character" from the character picture (the engine's text model). */describe?: PanelHelper;- /** "Use the clip's words": the part's lines from a transcription of the clip. */- words?: PanelHelper;+ /** "Use the clip's words": the part's lines from a transcription of the clip, its voice cleaned first when switched on. */+ words?: PanelHelper & { voiceFirst?: { on: boolean; onChange: (on: boolean) => void; seconds?: number } };}) {const set = (patch: Partial<CharacterOptions>) => onChange({ ...value, ...patch });const h3 = !!maker?.h3;@@ -255,6 +256,7 @@ export function CharacterControls({{words.busy ? <Loader2 className="size-3.5 animate-spin" /> : <AudioLines className="size-3.5" />} {words.busy ? "Listening to the clip…" : "Use the clip's words"}</Button>)}+ {words?.voiceFirst && <VoiceFirstSwitch className="mt-2" engine={engine} on={words.voiceFirst.on} onChange={words.voiceFirst.onChange} seconds={words.voiceFirst.seconds} />}</Field>)}<Field label="Swap style" hint="How the swap is drawn">diff --git a/src/components/genjutsu/genjutsu-studio.tsx b/src/components/genjutsu/genjutsu-studio.tsxindex 9f12724b..afd7fec8 100644--- a/src/components/genjutsu/genjutsu-studio.tsx+++ b/src/components/genjutsu/genjutsu-studio.tsx@@ -214,7 +214,9 @@ export function GenjutsuStudio() {};const describeMutation = useDescribeCharacter();const transcribeMutation = useTranscribeClip();- const [clipWords, setClipWords] = useState<{ url: string; g: Generation } | null>(null);+ // "Clean the voice first" for "Use the clip's words": on (a clip's music and effects blur the words).+ const [cleanWords, setCleanWords] = useState(true);+ const [clipWords, setClipWords] = useState<{ url: string; clean: boolean; g: Generation } | null>(null);const [listening, setListening] = useState(false);const alive = useRef<AbortController | null>(null);useEffect(() => () => alive.current?.abort(), []);@@ -235,11 +237,11 @@ export function GenjutsuStudio() {const ctl = new AbortController();alive.current = ctl;try {- let g = clipWords?.url === url ? clipWords.g : null;+ let g = clipWords?.url === url && clipWords.clean === cleanWords ? clipWords.g : null;if (!g) {- const { id } = await transcribeMutation.mutateAsync({ engine, source: { url, ...(duration ? { duration } : {}) } });+ const { id } = await transcribeMutation.mutateAsync({ engine, source: { url, ...(duration ? { duration } : {}) }, ...(cleanWords && { voiceFirst: true }) });g = await waitForGeneration(id, { signal: ctl.signal });- setClipWords({ url, g });+ setClipWords({ url, clean: cleanWords, g });}const out = g.outputs.find((o) => o.kind === "text");const cues = Array.isArray(out?.meta?.cues) ? (out.meta.cues as { start: number; end: number; text: string }[]) : undefined;@@ -685,7 +687,12 @@ export function GenjutsuStudio() {onSeed={setSeed}seedProblem={seedProblem(seedNumber)}describe={{ run: describeCharacter, busy: describeMutation.isPending, blocked: refs.some((r) => !r.uploading) ? null : "Add your character's picture to describe it" }}- words={{ run: () => void fillClipWords(), busy: listening, blocked: clip?.url && !clip.uploading && range ? null : "Add the clip first" }}+ words={{+ run: () => void fillClipWords(),+ busy: listening,+ blocked: clip?.url && !clip.uploading && range ? null : "Add the clip first",+ ...(clip?.info?.hasAudio !== false && { voiceFirst: { on: cleanWords, onChange: setCleanWords, seconds: duration } }),+ }}/>)}diff --git a/src/components/genjutsu/hooks.ts b/src/components/genjutsu/hooks.tsindex 384c4fad..e52a25f5 100644--- a/src/components/genjutsu/hooks.ts+++ b/src/components/genjutsu/hooks.ts@@ -84,7 +84,7 @@ export function useDescribeCharacter() {/** The clip's words (one transcription; the page takes the part's lines from its cues). */export function useTranscribeClip() {- return useMutation({ mutationFn: (b: { engine: Engine; source: { url: string; duration?: number } }) => send<{ id: string; modelId: string }>("/api/genjutsu/transcribe", "POST", b) });+ return useMutation({ mutationFn: (b: { engine: Engine; source: { url: string; duration?: number }; voiceFirst?: boolean }) => send<{ id: string; modelId: string }>("/api/genjutsu/transcribe", "POST", b) });}/** Waits for one generation to finish (polling; the page's helpers that fill a field from it). */diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsxindex 88bcf3fe..082bcb6b 100644--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@ -12,14 +12,16 @@ import { Button } from "@/components/ui/button";import { Kbd } from "@/components/ui/kbd";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { useToday } from "@/hooks/use-today";-import { estimateCost, imageLimit, layoutCanvas, planGeneration, routesFor, type Plan } from "@/lib/catalog/plan";+import { estimateCost, imageLimit, inferOperation, layoutCanvas, planGeneration, routesFor, type Plan } from "@/lib/catalog/plan";import type { Engine, GenerationRequest, MediaKind, ModelDef, Operation, Preset, PresetRoute, VideoFormat } from "@/lib/catalog/types";import { dualEngine } from "@/lib/catalog/engines";import { locksByDefault } from "@/lib/catalog/palettes";import { DEFAULT_LOOK, lookCard } from "@/lib/catalog/soul-cards";import { formatsOf } from "@/lib/av/formats";import { quoteBody, useHostedQuote, useSettled, type RunOn } from "@/lib/hosted";-import { CONNECT_GPU_EVENT, enhance, useClipFacts, useCreateGeneration, useElements, useEngine, useHydrated, useStatus } from "@/lib/api";+import { CONNECT_GPU_EVENT, enhance, ownGpuOf, useClipFacts, useCreateGeneration, useElements, useEngine, useHydrated, useStatus } from "@/lib/api";+import { putsBedBack, voiceFirstApplies, voiceFirstCost, voiceFirstDefault, voiceSource } from "@/lib/av/voice-first";+import { VoiceFirstSwitch } from "@/components/studio/voice-first-switch";import { usePagePlace } from "@/components/gpu/use-page-place";import { applyMentions, elementsNote, type StudioElement } from "@/lib/catalog/elements";import { applySketch, stripMotionPaths } from "@/lib/catalog/sketch";@@ -588,6 +590,17 @@ 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+ // 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));+ 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;+ const vfBed = vfApplies && !!vfOp && putsBedBack(signed.request, vfOp, vfEngine, vfClip?.hasAudio);// Hosted runs: an open model may run on this studio's GPUs. Its price there is the server's (the words of the// studio's billing service, or free), asked again 300 ms after a change. With the account's own GPU online, that// GPU is the default; the person can pick either.@@ -652,6 +665,8 @@ export function Composer({ docked }: { docked: boolean }) {if (cost !== null) cost += prestepCost(preset, plan.model.id, engine);// PixeletedFace pixelates each picture's faces afterwards ($0.01 a picture in the cloud, free on the GPU).if (cost !== null) cost += postStepCost(plan.model.id, planned.presetId, engine, planned.params?.numOutputs ?? 1, catalog.getModel, today);+ // "Clean the voice first": ElevenLabs Voice Isolation in the cloud (per minute of speech), free on your GPU.+ if (cost !== null && voiceFirstOn) cost += voiceFirstCost(plan.model.engine, vfFacts?.duration, catalog.getModel);} catch (e) {planError = (e as Error).message;}@@ -747,7 +762,7 @@ export function Composer({ docked }: { docked: boolean }) {);// Hosted runs: where it should go, and the price shown (the server checks both; a higher price comes back to confirm).const hosted = viewerInfo?.hosted ? { place: runOn, ...(poolPrice && hostedQuote && { shown: { amount: hostedQuote.amount, priceVersion: hostedQuote.priceVersion } }) } : {};- const body = { ...sent.request, ...hosted, ...(skipGpu && { gpuCheck: "skip" }) } as typeof sent.request;+ const body = { ...sent.request, ...hosted, ...(skipGpu && { gpuCheck: "skip" }), ...(voiceFirstOn && { voiceFirst: true }) } as typeof sent.request;create.mutate(body, {// Accepted: nothing to try again (a card opened later never starts this run a second time).onSuccess: () => dropGpuRetry(),@@ -1272,6 +1287,19 @@ export function Composer({ docked }: { docked: boolean }) {)}{/* On a phone the slot row scrolls sideways, so the switch gets its own line under it. */}{showAttachments && !collapsed && !framesOn && hasCleanVoice && <CleanVoiceSwitch status className="px-3 pb-2 sm:hidden" hint="first, free on your GPU" />}+ {showAttachments && !collapsed && vfApplies && vfSource && (+ <VoiceFirstSwitch+ className="px-3 pb-2"+ engine={vfEngine}+ on={voiceFirstOn}+ onChange={(on) => setVfPick({ ref: vfSource.url, on })}+ seconds={vfFacts?.duration}+ device={ownGpuOf(status)?.device}+ bed={vfBed}+ clip={vfOp === "lipsync" && !!signed.request.inputs?.video && vfClip?.hasAudio !== false}+ getModel={catalog.getModel}+ />+ )}{showPrompt && (<PromptInputdiff --git a/src/components/studio/studio-context.tsx b/src/components/studio/studio-context.tsxindex 7a5378fb..f172f9a5 100644--- a/src/components/studio/studio-context.tsx+++ b/src/components/studio/studio-context.tsx@@ -81,6 +81,11 @@ export interface StudioConfig {* seconds and the request carries them (params.sourceDuration). Not while a video is attached (lip re-sync).*/voiceFacts?: boolean;+ /**+ * "Clean the voice first" (src/lib/av/voice-first.ts): a switch under the files when the speech is attached, so the+ * transcript or lip sync runs on the speech alone (Transcribe, Lipsync & avatars).+ */+ voiceFirst?: boolean;/** Offer every output format of the studio's models on this engine; picking one another model writes moves the request there (SDR to HDR, Export). */formatPicker?: boolean;/** The models' enum settings chip ("Director" by default; "Options" for a tool's settings such as Topaz's model). */diff --git a/src/components/studio/voice-first-switch.tsx b/src/components/studio/voice-first-switch.tsxnew file mode 100644index 00000000..68fbea59--- /dev/null+++ b/src/components/studio/voice-first-switch.tsx@@ -0,0 +1,59 @@+"use client";++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 type { Engine, ModelDef } from "@/lib/catalog/types";+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.+ */+export function VoiceFirstSwitch({+ engine,+ on,+ onChange,+ seconds,+ device,+ bed,+ clip,+ getModel,+ price,+ className,+}: {+ engine: Engine;+ on: boolean;+ onChange: (on: boolean) => void;+ /** Seconds the speech runs, when known. */+ seconds?: number;+ /** Your GPU's device ("cuda", "cpu"), when known: the time's range. */+ device?: string | null;+ /** The clip's music and effects go back after the lip sync (open engine). */+ bed?: boolean;+ /** A lip re-sync of a clip: say what happens to its music and effects. */+ clip?: 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). */+ price?: string;+ className?: string;+}) {+ const id = useId();+ const line = price ?? voiceFirstLine({ engine, seconds, device, bed, getModel });+ return (+ <div className={cn("flex min-w-0 flex-col gap-0.5", className)} data-voice-first>+ <div className="flex min-w-0 items-start gap-2">+ <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>+ </label>+ <span className="shrink-0 font-mono text-[11px] text-muted-foreground tabular-nums">{line}</span>+ </div>+ {clip && <p className="pl-11 text-[11.5px] leading-snug text-muted-foreground">{BED_NOTES[engine]}</p>}+ </div>+ );+}diff --git a/src/components/swap-studio/hooks.ts b/src/components/swap-studio/hooks.tsindex 5626910e..6b66d252 100644--- a/src/components/swap-studio/hooks.ts+++ b/src/components/swap-studio/hooks.ts@@ -118,7 +118,7 @@ function useAction<B, R extends SwapProject | QueueAnswer = SwapProject>(id: strexport const useAddClip = (id: string) => useAction<ClipInput>(id, "clips");export const usePrepareClip = (id: string) => useAction<{ clipId: string }>(id, "prepare");-export const useTranscribe = (id: string) => useAction<{ clipId: string }>(id, "transcribe");+export const useTranscribe = (id: string) => useAction<{ clipId: string; voiceFirst?: boolean }>(id, "transcribe");export const useMakeMask = (id: string) =>useAction<{ clipId: string; shotId: string; kind: "track" | "frame"; frame: number; points: PixelPoint[]; size?: { width: number; height: number }; base?: string }>(id, "masks");export const useMakeAnchor = (id: string) => useAction<{ clipId: string; shotId: string; segmentId?: string; modelId?: string; seed?: number }>(id, "anchors");diff --git a/src/components/swap-studio/stage-words.tsx b/src/components/swap-studio/stage-words.tsxindex 862a91cd..64939bd7 100644--- a/src/components/swap-studio/stage-words.tsx+++ b/src/components/swap-studio/stage-words.tsx@@ -1,9 +1,11 @@"use client";import { Loader2, Mic, Wand2 } from "lucide-react";+import { useState } from "react";import { Button } from "@/components/ui/button";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";import { Panel } from "@/components/av/tool-shell";+import { VoiceFirstSwitch } from "@/components/studio/voice-first-switch";import { buildShotPrompt, ROLE_LABELS, secondsLabel, shotDialogue, shotSpeaker, SWAP_STUDIO, voiceLabel, voicesOf, type SwapRole } from "@/lib/catalog/swap-studio";import { toastError } from "@/lib/refusals";import { useTranscribe } from "./hooks";@@ -34,6 +36,11 @@ function RoleSelect({ value, onChange, label, auto }: { value: SwapRole | null;/** Words: the clip's transcript (both engines' speech to text), who each voice is, and each shot's speaker, words and prompt. */export function WordsStage({ id, project, clip, gens, estimate, edit }: StageProps) {const transcribe = useTranscribe(id);+ // "Clean the voice first": on (a clip's music and effects blur the words); its price is the estimate's.+ const [cleanFirst, setCleanFirst] = useState(true);+ const added = estimate?.cleanVoice?.[clip.id];+ const plain = estimate?.transcribe[clip.id];+ const total = cleanFirst && typeof plain === "number" && typeof added === "number" ? Math.round((plain + added) * 10000) / 10000 : cleanFirst && added === null ? null : plain;const t = clip.transcript;const voices = voicesOf(t?.cues);const busy = !!t?.genId && (gens[t.genId]?.status === "queued" || gens[t.genId]?.status === "running");@@ -49,15 +56,25 @@ export function WordsStage({ id, project, clip, gens, estimate, edit }: StageProvariant={t?.cues ? "outline" : "default"}className="h-8 rounded-full"disabled={busy || transcribe.isPending || !clip.source.hasAudio}- onClick={() => transcribe.mutate({ clipId: clip.id }, { onError: (e) => toastError(e) })}+ onClick={() => transcribe.mutate({ clipId: clip.id, ...(cleanFirst && { voiceFirst: true }) }, { onError: (e) => toastError(e) })}>{busy || transcribe.isPending ? <Loader2 className="size-3.5 animate-spin" /> : <Mic className="size-3.5" />}{t?.cues ? "Transcribe again" : "Transcribe"}- <span className="font-mono text-[11px] opacity-80">{priceText(estimate?.transcribe[clip.id], { demo: estimate?.demo, engine: project.engine })}</span>+ <span className="font-mono text-[11px] opacity-80">{priceText(total, { demo: estimate?.demo, engine: project.engine })}</span></Button></span>}>+ {clip.source.hasAudio && (+ <VoiceFirstSwitch+ className="mb-2"+ engine={project.engine}+ on={cleanFirst}+ onChange={setCleanFirst}+ seconds={clip.source.duration}+ {...(project.engine === "cloud" && typeof added === "number" && { price: `+$${added.toFixed(2)}` })}+ />+ )}{!clip.source.hasAudio ? (<Note>This clip has no sound: every shot is “No dialogue”.</Note>) : !t?.cues ? (diff --git a/src/lib/av/captions.ts b/src/lib/av/captions.tsindex f0204d95..738a7e81 100644--- a/src/lib/av/captions.ts+++ b/src/lib/av/captions.ts@@ -207,14 +207,18 @@ export function burnRequest(o: { route: BurnRoute; video: string; cues: Cue[]; l};}-/** The transcription job: the engine's transcriber, the spoken language if known. */-export function transcribeRequest(o: { engine: Engine; video: string; modelId?: string; sourceLanguage?: string }): GenerationRequest {+/** The transcription job: the engine's transcriber, the spoken language if known, the voice cleaned first if asked (src/lib/av/voice-first.ts). */+export function transcribeRequest(o: { engine: Engine; video: string; modelId?: string; sourceLanguage?: string; voiceFirst?: boolean; seconds?: number }): GenerationRequest {+ const language = o.sourceLanguage && o.sourceLanguage !== "auto" ? o.sourceLanguage : undefined;+ // With "Clean the voice first" the clip's length goes along: it prices the cloud's clean voice.+ const seconds = o.voiceFirst && o.seconds && o.seconds > 0 ? Math.round(o.seconds * 1000) / 1000 : undefined;return {feature: CAPTIONS_FEATURE,modelId: o.modelId ?? (o.engine === "open" ? "oss-qwen3-asr" : "scribe-v2"),op: "transcribe",inputs: { video: o.video },- ...(o.sourceLanguage && o.sourceLanguage !== "auto" && { params: { sourceLanguage: o.sourceLanguage } }),+ ...((language || seconds) && { params: { ...(language && { sourceLanguage: language }), ...(seconds && { sourceDuration: seconds }) } }),+ ...(o.voiceFirst && { voiceFirst: true }),};}diff --git a/src/lib/av/voice-first.ts b/src/lib/av/voice-first.tsindex 5d6125a3..476fb4e8 100644--- a/src/lib/av/voice-first.ts+++ b/src/lib/av/voice-first.ts@@ -197,11 +197,20 @@ export function planVoiceFirst(i: VoiceFirstInput): VoiceFirstPlan {// ---------------------------------------------------------------------------// What the switch says: the time it adds on the open engine, the price in the cloud-/** The price the clean voice adds in the cloud (USD; ElevenLabs Voice Isolation per minute of speech), 0 on the open engine. */-export function voiceFirstCost(engine: Engine, seconds: number | undefined, getModel: (id: string) => ModelDef | undefined): number {+/**+ * ElevenLabs Voice Isolation on fal: $0.10 a minute (the catalog's price, which a test keeps this equal to). Pages that+ * don't load the catalog (Captions, Genjutsu) price the step with it.+ */+export const ISOLATION_USD_PER_MINUTE = 0.1;++/**+ * The price the clean voice adds in the cloud (USD; ElevenLabs Voice Isolation per minute of speech, a minute when the+ * length isn't known), 0 on the open engine. With the catalog, its price; without, ISOLATION_USD_PER_MINUTE.+ */+export function voiceFirstCost(engine: Engine, seconds: number | undefined, getModel?: (id: string) => ModelDef | undefined): number {if (engine === "open") return 0;- const m = getModel(VOICE_FIRST_MODELS.cloud);- if (!m) return 0;+ const m = getModel?.(VOICE_FIRST_MODELS.cloud);+ if (!m) return Math.round(ISOLATION_USD_PER_MINUTE * ((seconds && seconds > 0 ? seconds : 60) / 60) * 10000) / 10000;return estimateCost(m, seconds && seconds > 0 ? { sourceDuration: seconds } : {}, 1, "separate-audio") ?? 0;}@@ -217,7 +226,7 @@ export function voiceFirstTime(o: { seconds: number; device?: string | null; bed}/** The switch's time or price line: "Free · adds about 1–2 min", "+$0.05", "+$0.10 a minute". */-export function voiceFirstLine(o: { engine: Engine; seconds?: number; device?: string | null; bed?: boolean; getModel: (id: string) => ModelDef | undefined }): string {+export function voiceFirstLine(o: { engine: Engine; seconds?: number; device?: string | null; bed?: boolean; getModel?: (id: string) => ModelDef | undefined }): string {if (o.engine === "open") {if (!o.seconds || o.seconds <= 0) return "Free · adds a little time";const t = voiceFirstTime({ seconds: o.seconds, device: o.device, bed: o.bed });diff --git a/src/lib/studios.ts b/src/lib/studios.tsindex 82e0b213..b6617d57 100644--- a/src/lib/studios.ts+++ b/src/lib/studios.ts@@ -127,6 +127,7 @@ export const LIPSYNC_STUDIO: StudioConfig = {defaultModels: { cloud: "kling-avatar-2", open: "oss-infinitetalk" },promptOptional: true,voiceFacts: true,+ voiceFirst: true,};export const UPSCALE_STUDIO: StudioConfig = {@@ -297,6 +298,7 @@ export const TRANSCRIBE_STUDIO: StudioConfig = {defaultModels: { cloud: "scribe-v2", open: "oss-qwen3-asr" },promptOptional: true,hidePrompt: true,+ voiceFirst: true,};export const SFX_STUDIO: StudioConfig = {diff --git a/tests/voice-first.test.ts b/tests/voice-first.test.tsindex 981cbb24..4fb85c81 100644--- a/tests/voice-first.test.ts+++ b/tests/voice-first.test.ts@@ -5,6 +5,7 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest";import {BED_DB,BED_NOTES,+ ISOLATION_USD_PER_MINUTE,planVoiceFirst,putsBedBack,VOICE_FIRST_MODELS,@@ -152,6 +153,10 @@ describe("what the switch says", () => {expect(voiceFirstCost("open", 120, getModel)).toBe(0);expect(voiceFirstLine({ engine: "cloud", seconds: 30, getModel })).toBe("+$0.05");expect(voiceFirstLine({ engine: "cloud", getModel })).toBe("+$0.10 a minute");+ // Pages without the catalog price it at the list price, which is the catalog's.+ expect(ISOLATION_USD_PER_MINUTE).toBe(getModel("elevenlabs-voice-isolation")?.pricing?.usd);+ expect(voiceFirstCost("cloud", 30)).toBe(voiceFirstCost("cloud", 30, getModel));+ expect(voiceFirstLine({ engine: "cloud", seconds: 90 })).toBe("+$0.15");});it("times the open step as one Fast mono split (two and the mux with the put-back)", () => {