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.

Faceless and Explainer: the music bed can be MiniMax Music 3 or ElevenLabs Music v2.5, each with its longest bed; tests for songs, lyrics and Mureka's song tools

Claudec22063ece6fb
diff --git a/src/components/faceless/settings-form.tsx b/src/components/faceless/settings-form.tsx
index 451c7dd7..004e083b 100644
--- a/src/components/faceless/settings-form.tsx
+++ b/src/components/faceless/settings-form.tsx
@@ -1,5 +1,6 @@
"use client";
+import { songLength } from "@/lib/lyrics";
import { AtSign, ChevronDown, Film, Images, Plus, X } from "lucide-react";
import Link from "next/link";
import { useEffect, useState } from "react";
@@ -141,6 +142,9 @@ export function EpisodeSettingsForm({
}, [offPick, onChange]);
const video = frames ? (camera && { ...camera, engine: value.engine }) : (videos.find((m) => m.id === value.videoModel) ?? videos.find((m) => m.id === ENGINE_MODELS[value.engine].video) ?? videos[0]);
const resolution = value.resolution && video?.resolutions.includes(value.resolution) ? value.resolution : (DEFAULT_RESOLUTION[video?.id ?? ""]?.[value.animation] ?? video?.resolutions[0]);
+ // The music bed's model (Advanced), with the longest bed each makes; one switched off in Settings leaves the list.
+ const beds = keepOffered((picker.musicModels ?? []).filter((m) => m.engine === value.engine), (m) => offered(access, m.id, value.engine));
+ const bed = beds.find((m) => m.id === value.musicModel) ?? beds.find((m) => m.id === ENGINE_MODELS[value.engine].music) ?? beds[0];
return (
<div className="space-y-7">
{kind === "faceless" && (
@@ -243,6 +247,16 @@ export function EpisodeSettingsForm({
<Segmented label="Video model" value={video?.id ?? ""} options={videos.map((m) => ({ value: m.id, label: m.name }))} onChange={(videoModel) => onChange({ videoModel, resolution: undefined })} />
</Section>
)}
+ {value.music && beds.length > 1 && (
+ <Section title="Music" hint="Longer films play the bed again, with a soft crossfade on your GPU.">
+ <Segmented
+ label="Music model"
+ value={bed?.id ?? ""}
+ options={beds.map((m) => ({ value: m.id, label: `${m.name} · up to ${songLength(m.maxSeconds)}` }))}
+ onChange={(musicModel) => onChange({ musicModel })}
+ />
+ </Section>
+ )}
{video && video.resolutions.length > 1 && (
<Section title="Quality" hint={frames ? "The size the camera moves render at: no model runs, larger sizes take longer and more memory." : undefined}>
<Segmented label="Quality" value={resolution ?? ""} options={video.resolutions.map((r) => ({ value: r, label: r }))} onChange={(r) => onChange({ resolution: r })} />
@@ -250,8 +264,8 @@ export function EpisodeSettingsForm({
)}
<p className="text-[12px] text-muted-foreground">
{value.engine === "cloud"
- ? `Pictures: Nano Banana Pro · ${frames ? "Camera: Ken Burns zoom (fal), no video model" : `Video: ${video?.name ?? "Gemini Omni Flash"}`} · Voice: ElevenLabs v4 (Chatterbox for your own voice), timed word by word by ElevenLabs forced alignment · Music: Sonilo · Subtitles: Auto Subtitle`
- : `Pictures: Qwen-Image 2.1 (Krea 2 Style Reference or Qwen-Image 2.1 Turbo with your images) · ${frames ? "Camera: Ken Burns pan and zoom, scenes over 10 s in pieces" : `Video: ${video?.name ?? "MiniMax H3"}`} · Voice: Chatterbox, timed by Qwen3-ASR · Music: ACE-Step, looped past 4 minutes · Subtitles: Qwen3-ASR + burn-in`}
+ ? `Pictures: Nano Banana Pro · ${frames ? "Camera: Ken Burns zoom (fal), no video model" : `Video: ${video?.name ?? "Gemini Omni Flash"}`} · Voice: ElevenLabs v4 (Chatterbox for your own voice), timed word by word by ElevenLabs forced alignment · Music: ${bed?.name ?? "Sonilo"} · Subtitles: Auto Subtitle`
+ : `Pictures: Qwen-Image 2.1 (Krea 2 Style Reference or Qwen-Image 2.1 Turbo with your images) · ${frames ? "Camera: Ken Burns pan and zoom, scenes over 10 s in pieces" : `Video: ${video?.name ?? "MiniMax H3"}`} · Voice: Chatterbox, timed by Qwen3-ASR · Music: ${bed ? `${bed.name}, looped past ${songLength(bed.maxSeconds)}` : "ACE-Step, looped past 4 minutes"} · Subtitles: Qwen3-ASR + burn-in`}
{" "}Each scene is cut to where its lines are spoken.
</p>
</CollapsibleContent>
diff --git a/src/lib/catalog/faceless.ts b/src/lib/catalog/faceless.ts
index aa582fbd..d624a03c 100644
--- a/src/lib/catalog/faceless.ts
+++ b/src/lib/catalog/faceless.ts
@@ -406,6 +406,8 @@ export interface EpisodeSettings {
elements: string[];
/** Advanced: the video model and its quality ("" = the mode's default). */
videoModel?: string;
+ /** Advanced: the music bed's model (ENGINE_MODELS.musicChoices; none = the engine's default). */
+ musicModel?: string;
resolution?: string;
/** Reference images that show the subject (Explainer sources). */
sourceImages?: string[];
@@ -605,6 +607,8 @@ export interface EngineModels {
longNarration: string;
narrationMaxChars: number;
music: string;
+ /** Other music models the settings offer for the bed (nm10-music3), each with the longest bed it makes (MUSIC_MAX). */
+ musicChoices: string[];
/** Extends a bed the music model can't make long enough (crossfaded on the open engine, whole plays on the cloud). */
loop: string;
/** Frame by frame: the camera move over each still (Ken Burns). */
@@ -645,6 +649,7 @@ export const ENGINE_MODELS: Record<Engine, EngineModels> = {
longNarration: "elevenlabs-multilingual-v2",
narrationMaxChars: 5000,
music: "sonilo-music",
+ musicChoices: ["sonilo-music", "minimax-music-3", "elevenlabs-music-2-5"],
loop: "join-audio",
kenBurns: "ken-burns",
join: "join-clips",
@@ -671,6 +676,7 @@ export const ENGINE_MODELS: Record<Engine, EngineModels> = {
longNarration: "oss-chatterbox",
narrationMaxChars: Infinity,
music: "oss-ace-step",
+ musicChoices: ["oss-ace-step", "oss-minimax-music-3"],
loop: "oss-audio-loop",
kenBurns: "oss-ken-burns",
join: "oss-join-clips",
@@ -717,8 +723,11 @@ export const PRICE_PER_SECOND: Record<string, Record<string, number>> = {
"seedance-2-5": { "480p": 0.2205, "720p": 0.473, "1080p": 1.164 },
};
-/** Music models that make any whole length up to this (Sonilo: up to 600 s; ACE-Step's workflow: up to 240 s). */
-export const MUSIC_MAX: Record<string, number> = { "sonilo-music": 600, "oss-ace-step": 240 };
+/**
+ * Music models that make any whole length up to this (Sonilo: up to 600 s; ACE-Step's workflow: up to 240 s; MiniMax Music 3
+ * on either engine: 300 s; ElevenLabs Music v2.5: 600 s).
+ */
+export const MUSIC_MAX: Record<string, number> = { "sonilo-music": 600, "oss-ace-step": 240, "minimax-music-3": 300, "oss-minimax-music-3": 300, "elevenlabs-music-2-5": 600 };
/** Longest bed a loop model makes (the open loop graph's limit; the cloud's whole plays go past any film). */
export const LOOP_MAX: Record<string, number> = { "oss-audio-loop": 600 };
@@ -867,7 +876,7 @@ export function resolveModels(settings: EpisodeSettings, narrationChars: number,
video,
resolution: wanted,
narration,
- music: settings.music ? m.music : null,
+ music: settings.music ? (settings.musicModel && m.musicChoices.includes(settings.musicModel) ? settings.musicModel : m.music) : null,
loop: settings.music ? m.loop : null,
level: settings.music ? (m.levelMusic ?? null) : null,
mux: settings.music ? m.mixMusic : m.mux,
@@ -1154,7 +1163,8 @@ export function buildEpisodeGraph(input: GraphInput, lookup: ModelLookup): Graph
modelId: models.music,
op: "music",
prompt: musicPrompt(input.genre, style, settings.brief?.music),
- params: { duration: bed, numOutputs: 1, ...(settings.engine === "open" && { extra: { lyrics: "[Instrumental]" } }) },
+ // A model that sings is asked for an instrumental (ACE-Step, MiniMax Music 3).
+ params: { duration: bed, numOutputs: 1, ...(musicDef.options.lyrics && { extra: { lyrics: "[Instrumental]" } }) },
step: { label: "Music", index: n, of: n },
},
});
@@ -1946,6 +1956,8 @@ export function defaultSettings(engine: Engine, genre: GenreInfo, o: { explainer
export interface PickerData {
voices: { id: string; name: string; hint?: string }[];
videoModels: { id: string; name: string; engine: Engine; resolutions: string[] }[];
+ /** The music bed's models per engine, each with the longest bed it makes in one go (seconds; longer films loop it). */
+ musicModels?: { id: string; name: string; engine: Engine; maxSeconds: number }[];
/** Frame by frame's camera move per engine (Ken Burns) and the qualities it renders at (none: the still's own size). */
cameraMoves?: Record<Engine, { id: string; name: string; resolutions: string[] }>;
/** How many style references each engine's picture model reads (the open one takes 2). */
@@ -1963,6 +1975,13 @@ export function pickerData(lookup: ModelLookup): PickerData {
return m ? [{ id, name: m.name, engine, resolutions: m.options.resolutions ?? [] }] : [];
}),
);
+ const musicModels = (["cloud", "open"] as const).flatMap((engine) =>
+ ENGINE_MODELS[engine].musicChoices.flatMap((id) => {
+ const m = lookup(id);
+ const max = MUSIC_MAX[id] ?? Math.max(...(m?.options.durations ?? [0]));
+ return m && max > 0 ? [{ id, name: m.name.replace(/ · both engines$/, ""), engine, maxSeconds: max }] : [];
+ }),
+ );
const camera = (engine: Engine) => {
const id = ENGINE_MODELS[engine].kenBurns;
return { id, name: lookup(id)?.name ?? "Ken Burns", resolutions: lookup(id)?.options.resolutions ?? [] };
@@ -1970,6 +1989,7 @@ export function pickerData(lookup: ModelLookup): PickerData {
return {
voices: voices.map((v) => ({ id: v.id, name: v.name, ...(v.hint && { hint: v.hint }) })),
videoModels,
+ musicModels,
cameraMoves: { cloud: camera("cloud"), open: camera("open") },
maxStyleRefs: { cloud: styleRefLimit("cloud", lookup), open: styleRefLimit("open", lookup) },
};
diff --git a/src/lib/palette-index.ts b/src/lib/palette-index.ts
index cc75698c..0742a74e 100644
--- a/src/lib/palette-index.ts
+++ b/src/lib/palette-index.ts
@@ -23,6 +23,7 @@ import {
MUSIC_STUDIO,
REFRAME_STUDIO,
SFX_STUDIO,
+ SONG_TOOLS_STUDIO,
TRANSCRIBE_STUDIO,
UPSCALE_STUDIO,
VIDEO_COLOR_MATCH_STUDIO,
@@ -54,6 +55,7 @@ const MODEL_STUDIOS: [string, StudioConfig][] = [
["/audio/transcribe", TRANSCRIBE_STUDIO],
["/audio/sfx", SFX_STUDIO],
["/audio/music", MUSIC_STUDIO],
+ ["/audio/song", SONG_TOOLS_STUDIO],
["/audio/video", FOLEY_STUDIO],
["/video-tools", VIDEO_MATTE_STUDIO],
["/video-tools/relight", VIDEO_RELIGHT_STUDIO],
diff --git a/tests/lyrics.test.ts b/tests/lyrics.test.ts
new file mode 100644
index 00000000..659427e2
--- /dev/null
+++ b/tests/lyrics.test.ts
@@ -0,0 +1,74 @@
+import { describe, expect, it } from "vitest";
+import { insertTag, isInstrumental, lyricsOf, lyricsProblem, normalizeLyrics, parseLyrics, promptWithLyrics, songLength, structureOf, tagName } from "@/lib/lyrics";
+import { durationLabel } from "@/lib/composer";
+
+// nm10-music3: the lyrics editor's words and section tags, as every music model reads them.
+describe("lyrics with section tags", () => {
+ it("reads each tag with the lines under it, in title case, words after a tag moved below it", () => {
+ const text = "Intro hum\n[verse 1] Morning light\nacross the window\n\n[PRE CHORUS]\nhold on\n[chorus][Instrumental]";
+ expect(parseLyrics(text)).toEqual([
+ { tag: null, lines: ["Intro hum"] },
+ { tag: "Verse 1", lines: ["Morning light", "across the window"] },
+ { tag: "Pre-Chorus", lines: ["hold on"] },
+ { tag: "Chorus", lines: [] },
+ { tag: "Instrumental", lines: [] },
+ ]);
+ expect(structureOf(text)).toEqual(["Verse 1", "Pre-Chorus", "Chorus", "Instrumental"]);
+ });
+
+ it("writes one tag per line, the words below, a blank line between sections", () => {
+ expect(normalizeLyrics("[verse] Line one \r\nline two\n\n\n[chorus] sing it\n")).toBe("[Verse]\nLine one\nline two\n\n[Chorus]\nsing it");
+ expect(normalizeLyrics(" \n")).toBe("");
+ expect(normalizeLyrics(undefined)).toBe("");
+ expect(tagName("outro - final chord")).toBe("Outro - final chord");
+ expect(tagName("verse2")).toBe("Verse 2");
+ expect(tagName("hook")).toBe("Hook");
+ });
+
+ it("knows an instrumental from a song", () => {
+ expect(isInstrumental("")).toBe(true);
+ expect(isInstrumental("[Instrumental]")).toBe(true);
+ expect(isInstrumental("[Intro]\n[Solo]")).toBe(false);
+ expect(isInstrumental("[Instrumental]\n[Solo]")).toBe(true);
+ expect(isInstrumental("[Verse]\nla la")).toBe(false);
+ });
+
+ it("takes them from params.extra.lyrics, normalized", () => {
+ expect(lyricsOf({ lyrics: "[verse] hi" })).toBe("[Verse]\nhi");
+ expect(lyricsOf({ lyrics: 3 })).toBe("");
+ expect(lyricsOf(undefined)).toBe("");
+ });
+
+ it("says when they are longer than the model sings", () => {
+ expect(lyricsProblem("[Verse]\nshort", 3000)).toBeNull();
+ expect(lyricsProblem(`[Verse]\n${"la ".repeat(40)}`, 50, "Mureka Extend")).toMatch(/^Mureka Extend sings up to 50 characters of lyrics: these are \d+\./);
+ expect(lyricsProblem("x".repeat(9000), undefined)).toBeNull();
+ });
+
+ it("goes after the prompt for a model that reads both in one text (Lyria 3.5)", () => {
+ expect(promptWithLyrics("Indie pop, 96 BPM.", "[verse]\nhello")).toBe("Indie pop, 96 BPM.\n\nLyrics:\n[Verse]\nhello");
+ expect(promptWithLyrics("Ambient", "[Instrumental]")).toBe("Ambient. Instrumental, no vocals.");
+ expect(promptWithLyrics("Ambient", "")).toBe("Ambient");
+ });
+
+ it("puts a tag on a line of its own at the cursor, the cursor below it", () => {
+ expect(insertTag("", 0, "verse")).toEqual({ text: "[Verse]\n", cursor: 8 });
+ // At the end of a line: after it, a blank line between.
+ const a = insertTag("hello there", 5, "chorus");
+ expect(a.text).toBe("hello there\n\n[Chorus]\n");
+ expect(a.cursor).toBe(a.text.length);
+ // At the start of a line: before it.
+ const b = insertTag("one\ntwo", 4, "Bridge");
+ expect(b.text).toBe("one\n\n[Bridge]\n\ntwo");
+ expect(b.text.slice(b.cursor)).toBe("\ntwo");
+ expect(insertTag("words", 0, "Intro").text).toBe("[Intro]\n\nwords");
+ });
+
+ it("reads lengths as a song does", () => {
+ expect(songLength(300)).toBe("5:00");
+ expect(songLength(95)).toBe("1:35");
+ expect(durationLabel(10)).toBe("10s");
+ expect(durationLabel(120)).toBe("2:00");
+ expect(durationLabel(270)).toBe("4:30");
+ });
+});
diff --git a/tests/music3-cloud.test.ts b/tests/music3-cloud.test.ts
new file mode 100644
index 00000000..8a9b5203
--- /dev/null
+++ b/tests/music3-cloud.test.ts
@@ -0,0 +1,190 @@
+/**
+ * nm10-music3 in the cloud: MiniMax Music 3 (the open model, hosted on fal), Mureka 9 / 9.5 songs and instrumentals,
+ * ElevenLabs Music v2.5 and Lyria 3.5, and Mureka's song tools (extend, remix, stems): payloads built from the research
+ * records, prices as fal's pages state them (2026-11-01), lyrics in each model's own form.
+ */
+import fs from "node:fs";
+import { describe, expect, it } from "vitest";
+import { getModel, getPreset } from "@/lib/catalog";
+import { buildPayload, extractOutputs } from "@/lib/catalog/payload";
+import { estimateCost, planGeneration } from "@/lib/catalog/plan";
+import type { GenerationRequest, ModelRoute, Operation } from "@/lib/catalog/types";
+import { outputActions } from "@/lib/output-actions";
+import type { Generation } from "@/lib/catalog/types";
+
+const route = (id: string, op?: Operation): ModelRoute => {
+ const r = getModel(id)?.routes.find((x) => !op || x.op === op);
+ if (!r?.map) throw new Error(`${id} has no ${op ?? ""} route`);
+ return r;
+};
+const payload = (id: string, input: Record<string, unknown>) => buildPayload(route(id).map!, { prompt: "", ...input } as never);
+const plan = (req: Omit<GenerationRequest, "feature">) => planGeneration({ feature: "audio", ...req }, getModel, getPreset);
+const planError = (req: Omit<GenerationRequest, "feature">) => {
+ try {
+ plan(req);
+ return null;
+ } catch (e) {
+ return (e as Error).message;
+ }
+};
+const cost = (id: string, params: Record<string, unknown> = {}, op: Operation = "music") => estimateCost(getModel(id)!, params, 1, op);
+
+const research = JSON.parse(fs.readFileSync("docs/research/new-models-10.json", "utf8")) as { endpointRecords: { endpoint: string; inputs: Record<string, { required?: boolean }>; license?: string; status: string }[] };
+const record = (ep: string) => research.endpointRecords.find((e) => e.endpoint === ep)!;
+
+describe("the research records", () => {
+ it("hold every endpoint the cloud models call, read from fal on 11-01, with each one's licence or terms", () => {
+ for (const ep of ["minimax/music-3", "mureka/v9.5/generate/song", "mureka/v9/generate/song", "mureka/v9/generate/instrumental", "mureka/v8/song/extend", "mureka/v8/song/remix", "mureka/api/song/stem", "mureka/api/files/upload", "elevenlabs/music/v2.5", "google/lyria-3.5"]) {
+ const r = record(ep);
+ expect(r, ep).toBeTruthy();
+ expect(r.status, ep).toBe("active");
+ expect(r.license, ep).toBeTruthy();
+ }
+ // MiniMax Music 3's own licence and the Comfy-Org repack's tag are both on record.
+ expect(record("minimax/music-3").license).toMatch(/MiniMax-Music3 Community License.*Apache-2\.0/s);
+ });
+});
+
+describe("MiniMax Music 3 on fal (minimax-music-3)", () => {
+ it("is the open model's cloud line, with its licence as information", () => {
+ const m = getModel("minimax-music-3")!;
+ expect(m.name).toBe("MiniMax Music 3 · both engines");
+ expect(m.engine).toBe("cloud");
+ expect(m.licence?.licence).toBe("MiniMax-Music3 Community License");
+ expect(m.options.durations).toContain(300);
+ expect(getModel("oss-minimax-music-3")?.engine).toBe("open");
+ });
+
+ it("sends the style, the lyrics with their tags on lines of their own, the length and the seed", () => {
+ expect(payload("minimax-music-3", { prompt: "Acoustic pop, 96 BPM", duration: 180, seed: 7, extra: { lyrics: "[verse] Morning light\n[chorus]\nsing" } })).toEqual({
+ prompt: "Acoustic pop, 96 BPM",
+ lyrics: "[Verse]\nMorning light\n\n[Chorus]\nsing",
+ duration: 180,
+ seed: 7,
+ });
+ // Its lyrics are required: a run with none asks for an instrumental.
+ expect(payload("minimax-music-3", { prompt: "Lo-fi" })).toEqual({ prompt: "Lo-fi", lyrics: "[instrumental]" });
+ });
+
+ it("costs $0.002 a second of the length asked for", () => {
+ expect(cost("minimax-music-3", { duration: 300 })).toBe(0.6);
+ expect(cost("minimax-music-3")).toBe(0.24);
+ });
+});
+
+describe("Mureka 9 / 9.5", () => {
+ it("Mureka 9.5 runs on its own route: lyrics, a length of 2 to 5 minutes, no Version", () => {
+ expect(route("mureka-song").endpoint).toBe("mureka/v9.5/generate/song");
+ expect(payload("mureka-song", { prompt: "Synth pop", duration: 240, extra: { lyrics: "[Verse]\nhi", model: "mureka-8" } })).toEqual({ prompt: "Synth pop", lyrics: "[Verse]\nhi", duration: 240 });
+ expect(getModel("mureka-song")!.options.durations).toEqual([120, 180, 240, 300]);
+ });
+
+ it("prices a song by whether it brings its lyrics", () => {
+ expect(cost("mureka-song")).toBe(0.5);
+ expect(cost("mureka-song", { extra: { lyrics: "[Verse]\nhello" } })).toBe(0.15);
+ expect(cost("mureka-9")).toBe(0.3);
+ expect(cost("mureka-9", { extra: { lyrics: "[Verse]\nhello" } })).toBe(0.045);
+ expect(cost("mureka-9-instrumental")).toBe(0.045);
+ expect(route("mureka-9").endpoint).toBe("mureka/v9/generate/song");
+ expect(payload("mureka-9-instrumental", { prompt: "Calm piano bed", extra: { lyrics: "[Verse]\nx" } })).toEqual({ prompt: "Calm piano bed" });
+ });
+
+ it("keeps the song's id on the result, for its song tools", () => {
+ const out = extractOutputs({ audio: { url: "https://v3.fal.media/x.mp3", content_type: "audio/mpeg" }, song_id: "song_123", duration: 180000 }, "music");
+ expect(out).toHaveLength(1);
+ expect(out[0].meta).toMatchObject({ songId: "song_123" });
+ });
+});
+
+describe("ElevenLabs Music v2.5 and Lyria 3.5", () => {
+ it("ElevenLabs takes a length in milliseconds and bills each started minute", () => {
+ expect(payload("elevenlabs-music-2-5", { prompt: "Synthwave", duration: 90, seed: 3 })).toEqual({ prompt: "Synthwave", music_length_ms: 90000 });
+ expect(cost("elevenlabs-music-2-5", { duration: 30 })).toBe(0.6);
+ expect(cost("elevenlabs-music-2-5", { duration: 90 })).toBe(1.2);
+ expect(getModel("elevenlabs-music-2-5")!.options.lyrics).toBeUndefined();
+ });
+
+ it("Lyria 3.5 reads the lyrics after the description, takes a picture, and has no negative prompt", () => {
+ expect(payload("lyria-3-5", { prompt: "Uplifting pop, 120 BPM", images: ["https://x/p.png"], extra: { lyrics: "[chorus] rise up" } })).toEqual({
+ prompt: "Uplifting pop, 120 BPM.\n\nLyrics:\n[Chorus]\nrise up",
+ image_url: "https://x/p.png",
+ });
+ expect(getModel("lyria-3-5")!.options.negativePrompt).toBeUndefined();
+ expect(cost("lyria-3-5")).toBe(0.1);
+ });
+});
+
+describe("Mureka's song tools", () => {
+ it("extend: one of Mureka's own songs by its id, the new part's lyrics, where it starts in whole milliseconds", () => {
+ const sent = payload("mureka-extend", { audio: "https://x/song.mp3", startTime: 183.4567, extra: { lyrics: "[verse] more", songId: "song_9", extend_type: "tail" } });
+ expect(sent).toEqual({ song_id: "song_9", lyrics: "[Verse]\nmore", extend_at: 183457, extend_type: "tail" });
+ // Any other song: no id here, the fal provider sends it first through Mureka's files/upload (purpose "audio").
+ const other = payload("mureka-extend", { audio: "https://x/song.mp3", startTime: 10, extra: { lyrics: "[Verse]\nmore" } });
+ expect(other).toEqual({ lyrics: "[Verse]\nmore", extend_at: 10000 });
+ expect(route("mureka-extend").map!.songSource).toEqual({ songId: "song_id", uploadId: "upload_audio_id", upload: { endpoint: "mureka/api/files/upload", purpose: "audio" } });
+ expect(route("mureka-remix").map!.songSource?.upload.purpose).toBe("remix");
+ });
+
+ it("prices the upload a song that isn't Mureka's needs", () => {
+ expect(cost("mureka-extend", { extra: { songId: "song_9" } }, "song-extend")).toBe(0.004);
+ expect(cost("mureka-extend", {}, "song-extend")).toBe(0.014);
+ expect(cost("mureka-remix", {}, "song-remix")).toBe(0.21);
+ expect(cost("mureka-stems", {}, "song-stems")).toBe(0.2);
+ });
+
+ it("remix takes a style and the whole song's lyrics; stems take the song's address", () => {
+ expect(payload("mureka-remix", { prompt: "Jazz trio", extra: { lyrics: "[Verse]\nla", songId: "s1" } })).toEqual({ prompt: "Jazz trio", lyrics: "[Verse]\nla", song_id: "s1" });
+ expect(payload("mureka-stems", { audio: "https://x/song.mp3" })).toEqual({ audio_url: "https://x/song.mp3" });
+ });
+
+ it("plans each tool with what it needs, in plain words", () => {
+ const song = { audio: "/api/files/song.mp3" };
+ expect(planError({ modelId: "mureka-extend", inputs: song })).toBe("Write the lyrics of the new part");
+ expect(planError({ modelId: "mureka-extend", inputs: {}, params: { extra: { lyrics: "[Verse]\nx" } } })).toBe("Add the song to extend");
+ expect(planError({ modelId: "mureka-remix", inputs: song, params: { extra: { lyrics: "[Verse]\nx" } } })).toBe("Describe the remix: its genre, mood and instruments");
+ expect(planError({ modelId: "mureka-remix", prompt: "jazz", inputs: song })).toMatch(/^Write the remix's lyrics/);
+ expect(plan({ modelId: "mureka-stems", inputs: song }).op).toBe("song-stems");
+ expect(plan({ modelId: "mureka-extend", inputs: song, params: { extra: { lyrics: "[verse] x" } } }).params.extra).toEqual({ lyrics: "[Verse]\nx" });
+ });
+});
+
+describe("lyrics in the plan", () => {
+ it("normalizes them for a model that sings, refuses ones too long, and leaves them out for one that doesn't", () => {
+ expect(plan({ modelId: "minimax-music-3", prompt: "pop", params: { extra: { lyrics: "[verse] a" } } }).params.extra).toEqual({ lyrics: "[Verse]\na" });
+ expect(planError({ modelId: "mureka-extend", inputs: { audio: "/api/files/s.mp3" }, params: { extra: { lyrics: `[Verse]\n${"la ".repeat(1100)}` } } })).toMatch(/^Mureka Extend sings up to 3,000 characters/);
+ const sonilo = plan({ modelId: "sonilo-music", prompt: "beat", params: { duration: 30, extra: { lyrics: "[Verse]\nwords" } } });
+ expect(sonilo.params.extra).toBeUndefined();
+ expect(sonilo.notes?.[0]).toMatch(/writes its own words/);
+ // An instrumental bed (Faceless) on a model that doesn't sing: quietly left out.
+ expect(plan({ modelId: "sonilo-music", prompt: "beat", params: { duration: 30, extra: { lyrics: "[Instrumental]" } } }).notes).toBeUndefined();
+ });
+
+ it("YuE2 sings lyrics only, and covers a song; other models refuse a song to cover", () => {
+ expect(planError({ modelId: "oss-yue2", prompt: "pop" })).toMatch(/^YuE2 sings your lyrics/);
+ expect(planError({ modelId: "oss-yue2", prompt: "pop", params: { extra: { lyrics: "[Instrumental]" } } })).toMatch(/^YuE2 sings your lyrics/);
+ expect(plan({ modelId: "oss-yue2", prompt: "pop", inputs: { audio: "/api/files/s.mp3" }, params: { extra: { lyrics: "[Verse]\nla" } } }).op).toBe("music");
+ expect(planError({ modelId: "oss-minimax-music-3", prompt: "pop", inputs: { audio: "/api/files/s.mp3" } })).toBe("MiniMax Music 3 makes a new song: remove the song you added, or pick YuE2 to cover it");
+ });
+});
+
+describe("a music result's song tools", () => {
+ const gen = (o: Partial<Generation> = {}, meta: Record<string, unknown> = {}): Generation =>
+ ({ id: "g1", status: "succeeded", op: "music", feature: "audio", modelId: "mureka-song", request: { feature: "audio", modelId: "mureka-song" }, outputs: [{ url: "/api/files/song.mp3", kind: "audio", meta }], createdAt: 0, ...o }) as unknown as Generation;
+ const ids = (g: Generation, engineMode?: "both" | "open" | "cloud") => outputActions(g, 0, { engineMode }).filter((a) => ["extend-song", "remix-song", "song-stems"].includes(a.id));
+
+ it("Extend song, Remix and Stems open Extend & remix with the song (and Mureka's id for its own)", () => {
+ const acts = ids(gen({}, { songId: "song_1" }));
+ expect(acts.map((a) => a.label)).toEqual(["Extend song", "Remix", "Stems"]);
+ expect(acts[0].href).toBe("/audio/song?model=mureka-extend&audio=%2Fapi%2Ffiles%2Fsong.mp3&song=song_1");
+ expect(acts[2].href).toBe("/audio/song?model=mureka-stems&audio=%2Fapi%2Ffiles%2Fsong.mp3");
+ // Any song made in Fuobe (a song from your GPU too): sent to Mureka first.
+ expect(ids(gen({ modelId: "oss-minimax-music-3" }))[1].href).toBe("/audio/song?model=mureka-remix&audio=%2Fapi%2Ffiles%2Fsong.mp3");
+ });
+
+ it("not on sound effects or speech, nor on an install that runs open models only", () => {
+ expect(ids(gen({ op: "sfx" }))).toEqual([]);
+ expect(ids(gen({ op: "tts" }))).toEqual([]);
+ expect(ids(gen(), "open")).toEqual([]);
+ expect(ids(gen({ op: "song-remix" }))).toHaveLength(3);
+ });
+});
diff --git a/tests/music3-faceless.test.ts b/tests/music3-faceless.test.ts
new file mode 100644
index 00000000..8bbadb30
--- /dev/null
+++ b/tests/music3-faceless.test.ts
@@ -0,0 +1,45 @@
+import { describe, expect, it } from "vitest";
+import { getModel } from "@/lib/catalog";
+import { buildEpisodeGraph, defaultSettings, genreInfo, MUSIC_MAX, pickerData, resolveModels, secondsFor, type EpisodeSettings, type ScriptBlock } from "@/lib/catalog/faceless";
+
+// nm10-music3: Faceless, Explainer and Content Factory's music bed can be MiniMax Music 3 (either engine) or ElevenLabs Music
+// v2.5 in the cloud, beside Sonilo and ACE-Step; each says the longest bed it makes.
+const block = (i: number, words = 20): ScriptBlock => {
+ const narration = Array.from({ length: words }, (_, w) => `w${i}x${w}`).join(" ");
+ return { id: `b${i}`, narration, visual: `Scene ${i}`, motion: "slow push-in", seconds: secondsFor(narration) };
+};
+const settings = (s: Partial<EpisodeSettings>) => ({ ...defaultSettings(s.engine ?? "cloud", genreInfo("education")), ...s });
+const graph = (s: Partial<EpisodeSettings>) =>
+ buildEpisodeGraph({ feature: "faceless", title: "Tides", genre: genreInfo("education"), settings: settings(s), blocks: [block(1), block(2)], fallbackVoice: "/api/files/uploads/demo-voice.wav" }, getModel);
+const musicStep = (s: Partial<EpisodeSettings>) => graph(s).find((x) => x.key === "music")!;
+
+describe("the music bed's model", () => {
+ it("lists each engine's choices with the longest bed each makes", () => {
+ const picks = pickerData(getModel).musicModels!;
+ expect(picks.filter((m) => m.engine === "cloud").map((m) => [m.id, m.name, m.maxSeconds])).toEqual([
+ ["sonilo-music", "Sonilo Music 1.1", 600],
+ ["minimax-music-3", "MiniMax Music 3", 300],
+ ["elevenlabs-music-2-5", "ElevenLabs Music v2.5", 600],
+ ]);
+ expect(picks.filter((m) => m.engine === "open").map((m) => [m.id, m.maxSeconds])).toEqual([
+ ["oss-ace-step", 240],
+ ["oss-minimax-music-3", 300],
+ ]);
+ expect(MUSIC_MAX["oss-minimax-music-3"]).toBe(300);
+ });
+
+ it("runs the one picked on its engine, else the engine's default", () => {
+ expect(resolveModels(settings({ musicModel: "minimax-music-3" }), 100, getModel).music).toBe("minimax-music-3");
+ expect(resolveModels(settings({ engine: "open", musicModel: "oss-minimax-music-3" }), 100, getModel).music).toBe("oss-minimax-music-3");
+ // A pick from the other engine (a channel moved to your GPU) falls back.
+ expect(resolveModels(settings({ engine: "open", musicModel: "minimax-music-3" }), 100, getModel).music).toBe("oss-ace-step");
+ expect(resolveModels(settings({ music: false, musicModel: "minimax-music-3" }), 100, getModel).music).toBeNull();
+ });
+
+ it("asks a model that sings for an instrumental bed", () => {
+ expect(musicStep({ musicModel: "minimax-music-3" }).request).toMatchObject({ modelId: "minimax-music-3", op: "music", params: { extra: { lyrics: "[Instrumental]" } } });
+ expect(musicStep({ engine: "open", musicModel: "oss-minimax-music-3" }).request.params?.extra).toEqual({ lyrics: "[Instrumental]" });
+ expect(musicStep({}).request.params?.extra).toBeUndefined();
+ expect(musicStep({ musicModel: "elevenlabs-music-2-5" }).request.params?.extra).toBeUndefined();
+ });
+});
diff --git a/tests/music3-hosted.test.ts b/tests/music3-hosted.test.ts
new file mode 100644
index 00000000..f2ec7ed9
--- /dev/null
+++ b/tests/music3-hosted.test.ts
@@ -0,0 +1,82 @@
+import fs from "node:fs";
+import http from "node:http";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
+import { listenInRange, startFakeBilling, type FakeBilling } from "./helpers/fake-billing";
+import { startFakeComfy, type FakeComfy } from "./helpers/fake-comfy-runner";
+
+// nm10-music3 under public sign-up: an account's song on this install's GPUs (hosted runs) plans and prices as any studio run
+// (MiniMax Music 3 and YuE2 are open models on core nodes); a model that needs words is refused before anything is
+// priced or held.
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-music3-hosted-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.FUOBE_PUBLIC_SIGNUP = "1";
+delete process.env.FUOBE_PASSWORD;
+delete process.env.FUOBE_HOSTED_RUNS;
+delete process.env.FUOBE_BILLING_URL;
+delete process.env.FUOBE_MODERATION_URL;
+globalThis.__fuobeTestDiskFree = 1e13;
+
+const probe = http.createServer();
+const comfyPort = await listenInRange(probe);
+await new Promise<void>((r) => probe.close(() => r()));
+const comfy: FakeComfy = await startFakeComfy({ output: "image", delayMs: 0 }, comfyPort);
+process.env.COMFYUI_URL = comfy.url;
+
+const auth = await import("@/server/auth");
+const generationsRoute = await import("@/app/api/generations/route");
+const { resetRates } = await import("@/server/rate");
+const billing = await import("@/server/billing");
+
+let fake: FakeBilling;
+let cookie = "";
+beforeAll(async () => {
+ fake = await startFakeBilling();
+ auth.setPassword("install password");
+ const a = auth.createAccount("[email protected]", "long enough").id;
+ cookie = `${auth.SESSION_COOKIE}=${auth.createSession(a).value}`;
+});
+afterAll(async () => {
+ globalThis.__fuobeTestDiskFree = undefined;
+ for (const k of ["FUOBE_HOSTED_RUNS", "FUOBE_BILLING_URL", "FUOBE_BILLING_TOKEN"]) delete process.env[k];
+ await fake.close();
+ await comfy.close();
+ try {
+ fs.rmSync(dir, { recursive: true, force: true });
+ } catch {}
+});
+beforeEach(() => {
+ resetRates();
+ billing.resetBillingCache();
+ process.env.FUOBE_HOSTED_RUNS = "1";
+ process.env.FUOBE_BILLING_URL = fake.url;
+ process.env.FUOBE_BILLING_TOKEN = "test-billing-token";
+ fake.calls.length = 0;
+ fake.policy = { hosted: true, pool: {}, uploads: { image: true, video: false, audio: false }, limits: { activeRuns: 7, waiting: 7, runsPerHour: 70, outputsPerRun: 2, maxMegapixels: 7, maxSeconds: 600, keepDays: 7, spaceBytes: 7 }, ttlS: 0 };
+});
+
+const post = (body: unknown, query = "") => {
+ const text = JSON.stringify(body);
+ return generationsRoute.POST(
+ new Request(`http://localhost:3000/api/generations${query}`, { method: "POST", headers: { cookie, host: "localhost:3000", "content-type": "application/json", "content-length": String(Buffer.byteLength(text)) }, body: text }),
+ );
+};
+const song = { feature: "audio", modelId: "oss-minimax-music-3", op: "music", prompt: "Acoustic pop, 96 BPM", params: { duration: 180, extra: { lyrics: "[Verse]\nMorning light" } } };
+
+describe("songs on this install's GPUs (hosted runs)", () => {
+ it("prices an account's MiniMax Music 3 song there, with its op, model and seconds", async () => {
+ const p = await post(song, "?preview=1");
+ expect(p.status).toBe(200);
+ expect(((await p.json()) as { place: string }).place).toBe("pool");
+ const quote = fake.calls_of("/v1/quote").at(-1)!.body as { run: { model: string; op: string; kind: string; seconds: number; engine: string } };
+ expect(quote.run).toMatchObject({ model: "oss-minimax-music-3", op: "music", kind: "audio", seconds: 180, engine: "open" });
+ });
+
+ it("YuE2 needs its lyrics before anything is priced or held", async () => {
+ const r = await post({ ...song, modelId: "oss-yue2", params: { duration: 120 } });
+ expect(r.status).toBe(422);
+ expect(((await r.json()) as { error: string }).error).toMatch(/^YuE2 sings your lyrics/);
+ expect(fake.calls_of("/v1/reserve")).toHaveLength(0);
+ });
+});
diff --git a/tests/music3-open.test.ts b/tests/music3-open.test.ts
new file mode 100644
index 00000000..a24910e5
--- /dev/null
+++ b/tests/music3-open.test.ts
@@ -0,0 +1,179 @@
+import fs from "node:fs";
+import http from "node:http";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+import type { GenInput, ModelDef } from "@/lib/catalog/types";
+import type { MediaInfo } from "@/lib/media-probe";
+
+// nm10-music3 on the open engine: MiniMax Music 3 and YuE2 (songs and covers) on core ComfyUI nodes, bound for real; and the
+// fal provider's song tools (a song sent first through Mureka's files/upload, stems unpacked from Mureka's zip) against a
+// stand-in fal.ai on this machine.
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-music3-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://comfy.test:8188";
+
+const { loadManifest, prepareWorkflow } = await import("@/server/providers/comfyui");
+const { getModel } = await import("@/lib/catalog");
+const { resolveWorkflowId } = await import("@/lib/comfy-variants");
+const { buildLicenceList, licenceInfo, workflowLicence } = await import("@/lib/licences");
+const { setSetting } = await import("@/server/settings");
+const { falProvider } = await import("@/server/providers/fal");
+const { zip } = await import("@/server/zip");
+const { unzip } = await import("@/server/unzip");
+
+const requirements = JSON.parse(fs.readFileSync("workflows/comfyui/requirements.json", "utf8")) as { workflows: Record<string, { files: string[]; vramGb?: number | string }> };
+const SONGS = ["music-minimax-3", "music-yue2-song", "music-yue2-cover"];
+
+const song: MediaInfo = { container: "mp3", hasVideo: false, hasAudio: true, duration: 95, channels: 2 } as MediaInfo;
+async function prepare(id: string, input: Partial<GenInput>) {
+ const uploads: string[] = [];
+ const res = await prepareWorkflow(id, { prompt: "", ...input } as GenInput, {
+ generationId: "gen1",
+ op: "music",
+ upload: async (_d, _t, name) => {
+ uploads.push(name);
+ return `up_${name}`;
+ },
+ media: (name) => (name === "song.mp3" ? song : undefined),
+ serverRam: async () => undefined,
+ });
+ return { ...res, uploads };
+}
+
+describe("the song graphs", () => {
+ it("are in the manifest, accepted by a live ComfyUI, with their licences, pinned files and a model that runs them", () => {
+ const byId = new Map(loadManifest().workflows.map((w) => [w.id, w]));
+ for (const id of SONGS) {
+ const wf = byId.get(id)!;
+ expect(wf, id).toBeTruthy();
+ expect(wf.validated, id).toBe(true);
+ expect(wf.capability).toBe("music");
+ expect(wf.customNodes, id).toEqual([]);
+ expect(requirements.workflows[id]?.files.length, id).toBeGreaterThan(0);
+ }
+ expect(byId.get("music-minimax-3")!.models.map((m) => [m.file, m.sizeGb])).toEqual([
+ ["minimax_music3_dit_int8_convrot.safetensors", 2.5],
+ ["minimax_music3_text_encoder_pruned_int8_convrot.safetensors", 9.2],
+ ["minimax_music3_dav.safetensors", 0.22],
+ ]);
+ expect(byId.get("music-minimax-3")!.vramGb).toBe(24);
+ expect(byId.get("music-yue2-cover")!.models.map((m) => m.file)).toEqual(["yue2_3b_int8_convrot.safetensors", "sheetsage2_bf16.safetensors"]);
+ expect(getModel("oss-minimax-music-3")!.routes[0].endpoint).toBe("music-minimax-3");
+ expect(getModel("oss-yue2")!.routes[0].endpoint).toBe("music-yue2-song");
+ });
+
+ it("show each licence as information: MiniMax-Music3's own (with its notice), YuE2's non-commercial", () => {
+ const wfs = loadManifest().workflows;
+ const mm = licenceInfo(workflowLicence(wfs.find((w) => w.id === "music-minimax-3")!));
+ expect(mm).toMatchObject({ name: "MiniMax-Music3 Community License", class: "conditions", notices: ["MiniMax-Music3"] });
+ expect(mm.url).toContain("MiniMaxAI/MiniMax-Music3/blob/1b525ccb");
+ expect(licenceInfo(workflowLicence(wfs.find((w) => w.id === "music-yue2-song")!)).class).toBe("non-commercial");
+ const rows = buildLicenceList([getModel("oss-yue2")!, getModel("oss-minimax-music-3")!] as ModelDef[], wfs).rows;
+ expect(rows.find((r) => r.id === "oss-yue2")).toMatchObject({ workflows: ["music-yue2-song"], flags: ["non-commercial"] });
+ });
+
+ it("MiniMax Music 3: the style, the lyrics, the length, the seed; long songs decode in tiles", async () => {
+ const { workflow: prompt } = await prepare("music-minimax-3", { prompt: "Acoustic pop, 96 BPM", duration: 180, seed: 5, extra: { lyrics: "[Verse]\nMorning light" } });
+ expect(prompt["4"].inputs).toMatchObject({ caption: "Acoustic pop, 96 BPM", lyrics: "[Verse]\nMorning light", max_duration: 180, seed: 5 });
+ expect(prompt["7"].inputs.seed).toBe(5);
+ expect(prompt["10"].inputs.switch).toBe(true);
+ const short = await prepare("music-minimax-3", { prompt: "Lo-fi", duration: 60 });
+ expect(short.workflow["10"].inputs.switch).toBe(false);
+ // No words: the graph's own instrumental.
+ expect(short.workflow["4"].inputs.lyrics).toBe("[Instrumental]");
+ await expect(prepare("music-minimax-3", { prompt: "x", duration: 330 })).rejects.toThrow("This model writes songs up to 5 minutes on your GPU: pick a shorter length");
+ });
+
+ it("YuE2: the style and lyrics plan the song; a song added is covered from its melody", async () => {
+ const { workflow: prompt } = await prepare("music-yue2-song", { prompt: "English, warm female vocal, pop", duration: 120, seed: 9, extra: { lyrics: "[Verse]\nla la" } });
+ expect(prompt["2"].inputs).toMatchObject({ style: "English, warm female vocal, pop", lyrics: "[Verse]\nla la", seed: 9, mode: "full" });
+ expect(prompt["3"].inputs).toMatchObject({ abc: ["2", 0], max_duration: 120, seed: 9 });
+ const has = (id: string) => SONGS.includes(id);
+ const base = { op: "music", clips: 0, images: 0, audio2: false, extra: {}, has };
+ expect(resolveWorkflowId("music-yue2-song", base)).toBe("music-yue2-song");
+ expect(resolveWorkflowId("music-yue2-song", { ...base, audio: true })).toBe("music-yue2-cover");
+ expect(resolveWorkflowId("music-minimax-3", { ...base, audio: true })).toBe("music-minimax-3");
+ const cover = await prepare("music-yue2-song", { prompt: "Jazz, male vocal", audio: "song.mp3", extra: { lyrics: "[Verse]\nnew words" } });
+ expect(cover.workflow["9"].inputs.audio).toBe("song.mp3");
+ expect(cover.workflow["11"].inputs).toMatchObject({ audio: ["9", 0], mode: "melody" });
+ expect(cover.workflow["3"].inputs).toMatchObject({ style: "Jazz, male vocal", lyrics: "[Verse]\nnew words", abc: ["11", 0], mode: "melody" });
+ });
+});
+
+describe("the fal provider's song tools", () => {
+ let server: http.Server;
+ let base = "";
+ const log: { method: string; path: string; body: string }[] = [];
+ const stems = zip([
+ { name: "stems/vocals.mp3", data: Buffer.from("ID3vocals") },
+ { name: "stems/drums.wav", data: Buffer.from("RIFFdrums") },
+ { name: "__MACOSX/._vocals.mp3", data: Buffer.from("x") },
+ { name: "readme.txt", data: Buffer.from("hi") },
+ ]);
+ beforeAll(async () => {
+ server = http.createServer((req, res) => {
+ const chunks: Buffer[] = [];
+ req.on("data", (c: Buffer) => chunks.push(c));
+ req.on("end", () => {
+ const p = req.url ?? "/";
+ log.push({ method: req.method ?? "GET", path: p, body: Buffer.concat(chunks).toString() });
+ const json = (b: unknown) => {
+ res.writeHead(200, { "Content-Type": "application/json" });
+ res.end(JSON.stringify(b));
+ };
+ if (p === "/mureka/api/files/upload") return json({ id: "upload_7", purpose: "audio" });
+ if (p === "/stems.zip") {
+ res.writeHead(200, { "Content-Type": "application/zip" });
+ return res.end(stems);
+ }
+ if (p.startsWith("/requests/") && p.includes("/status")) return json({ status: "COMPLETED" });
+ if (p.startsWith("/requests/")) return json({ zip_url: `${base}/stems.zip`, midi_zip_url: null });
+ return json({ request_id: "r1", status_url: `${base}/requests/r1/status`, response_url: `${base}/requests/r1`, cancel_url: `${base}/requests/r1/cancel` });
+ });
+ });
+ await new Promise<void>((r) => server.listen(0, "127.0.0.1", r));
+ base = `http://127.0.0.1:${(server.address() as { port: number }).port}`;
+ globalThis.__fuobeTestFalUrl = base;
+ setSetting("falKey", "owner-fal-key");
+ });
+ afterAll(async () => {
+ globalThis.__fuobeTestFalUrl = undefined;
+ await new Promise<void>((r) => server.close(() => r()));
+ fs.rmSync(dir, { recursive: true, force: true });
+ });
+
+ const model = (id: string) => getModel(id)!;
+ it("sends a song Mureka didn't make through its files/upload first, then extends it by that id", async () => {
+ const m = model("mureka-extend");
+ const job = await falProvider.submit({ generationId: "g", model: m, route: m.routes[0], input: { prompt: "", audio: "https://files.test/song.mp3", startTime: 95, extra: { lyrics: "[Verse]\nmore" } } });
+ expect(JSON.parse(log.find((l) => l.path === "/mureka/api/files/upload")!.body)).toEqual({ file_url: "https://files.test/song.mp3", purpose: "audio" });
+ expect(job.payload).toEqual({ lyrics: "[Verse]\nmore", extend_at: 95000, upload_audio_id: "upload_7" });
+ // One of Mureka's own: no upload.
+ log.length = 0;
+ const own = await falProvider.submit({ generationId: "g", model: m, route: m.routes[0], input: { prompt: "", audio: "https://files.test/song.mp3", startTime: 95, extra: { lyrics: "[Verse]\nmore", songId: "song_1" } } });
+ expect(log.some((l) => l.path === "/mureka/api/files/upload")).toBe(false);
+ expect(own.payload).toMatchObject({ song_id: "song_1" });
+ });
+
+ it("unpacks the stems' zip into one result per track, named by its file", async () => {
+ const m = model("mureka-stems");
+ const job = await falProvider.submit({ generationId: "g", model: m, route: m.routes[0], input: { prompt: "", audio: "https://files.test/song.mp3" } });
+ expect(job.payload).toEqual({ audio_url: "https://files.test/song.mp3" });
+ const r = await falProvider.poll({ externalId: job.externalId, meta: job.meta!, route: m.routes[0], model: m, createdAt: Date.now() });
+ expect(r.state).toBe("succeeded");
+ if (r.state !== "succeeded") return;
+ expect(r.outputs.map((o) => [o.meta?.stem, o.contentType, o.kind])).toEqual([
+ ["vocals", "audio/mpeg", "audio"],
+ ["drums", "audio/wav", "audio"],
+ ]);
+ expect(Buffer.from(r.outputs[0].url.split(",")[1], "base64").toString()).toBe("ID3vocals");
+ });
+
+ it("reads an archive's files, and refuses a damaged or oversized one", () => {
+ expect(unzip(stems).map((f) => f.name)).toEqual(["stems/vocals.mp3", "stems/drums.wav", "readme.txt"]);
+ expect(() => unzip(Buffer.from("not a zip at all, just words"))).toThrow("Not a zip archive");
+ expect(() => unzip(stems, { maxFiles: 2 })).toThrow(/more than 2/);
+ expect(() => unzip(stems, { maxBytes: 4 })).toThrow(/more than Fuobe keeps/);
+ });
+});