Suno-style web UI for a self-hosted MiniMax-Music3 inference server
TypeScript ai-musicdiffusersdockerexpressminimaxminimax-musicmusic-generationreactself-hostedsgl-omnisunotailwindcsstext-to-musictypescriptvite
feat: wav-only output, matching the official /v1/audio/speech contract; drop format selector
Adam Benhassen6249e4c5343f
diff --git a/README.md b/README.mdindex 2666c00..82da3dd 100644--- a/README.md+++ b/README.md@@ -22,8 +22,8 @@## Features-- **Create panel** — Simple or Custom mode, song title (random name like “Velvet Horizon” if left empty), style description, lyrics editor with `[Verse]` / `[Chorus]` / … tag chips, instrumental toggle, duration 5–360 s, 1–4 takes per submit (each take gets `seed + i`), advanced seed / output format (wav · flac · mp3).-- **Templates** — a built-in default plus your own saved templates (style, lyrics, duration, format), stored server-side.+- **Create panel** — Simple or Custom mode, song title (random name like “Velvet Horizon” if left empty), style description, lyrics editor with `[Verse]` / `[Chorus]` / … tag chips, instrumental toggle, duration 5–360 s, 1–4 takes per submit (each take gets `seed + i`), advanced seed. Output is WAV, as the official route documents.+- **Templates** — a built-in default plus your own saved templates (style, lyrics, duration), stored server-side.- **Render queue** — the UI server renders one track at a time against the blocking `/v1/audio/speech` route and shows queued / rendering / done with elapsed time and an estimated bar (~3× realtime — the API reports no progress). Cancel while queued or rendering, retry on error.- **Library** — every finished render is saved into `data/tracks/` with its metadata (prompt, lyrics, seed, format). Search, download, delete, "reuse settings".- **Player** — sticky bottom bar with waveform (decoded client-side), seek, prev/next, keyboard space to play/pause.@@ -36,7 +36,7 @@```browser ──/api/*──▶ server/ (Express 5) ──POST /v1/audio/speech──▶ MiniMax-Music3 server (sgl-omni, :8000)│ one render at a time; streams the audio response to disk- └─▶ data/library.json · data/templates.json · data/settings.json · data/tracks/*.wav|flac|mp3+ └─▶ data/library.json · data/templates.json · data/settings.json · data/tracks/*.wav```| Package | What |@@ -127,7 +127,7 @@ The server speaks the standard MiniMax-Music3 contract (the same one `sgl-omni s| Method | Path | ||---|---|---|| `GET` | `/v1/models` | Reachability probe. Optional — a 404 still counts as "up". If present, the first listed id is used as `model`; otherwise `MiniMaxAI/MiniMax-Music3` (the model card's example) |-| `POST` | `/v1/audio/speech` | `{model: <from /v1/models or "MiniMaxAI/MiniMax-Music3">, input: <lyrics>, instructions: <style>, response_format: wav\|flac\|mp3, seed?, max_new_tokens: duration×25 (≤ 9000), stream: false}` → audio bytes; `X-Seed` header (if present) is stored |+| `POST` | `/v1/audio/speech` | `{model: <from /v1/models or "MiniMaxAI/MiniMax-Music3">, input: <lyrics>, instructions: <style>, response_format: "wav", seed?, max_new_tokens: duration×25 (≤ 9000), stream: false}` → audio bytes; `X-Seed` header (if present) is stored |The call blocks for the whole render (roughly 2.5–3× the audio length), so the UI server queues renders one at a time and shows an estimated bar. Optional `Authorization: Bearer <key>` is sent when an API key is configured.diff --git a/server/src/app.ts b/server/src/app.tsindex 4bf7b85..eb5c137 100644--- a/server/src/app.ts+++ b/server/src/app.ts@@ -20,7 +20,7 @@ export interface AppDeps {log?: (msg: string) => void;}-const MIME: Record<string, string> = { wav: 'audio/wav', flac: 'audio/flac', mp3: 'audio/mpeg' };+const MIME: Record<string, string> = { wav: 'audio/wav' };export function createApp(deps: AppDeps) {const { library, templates, settings, upstream, queue, tracksDir } = deps;diff --git a/server/src/types.ts b/server/src/types.tsindex ab413c9..593c56f 100644--- a/server/src/types.ts+++ b/server/src/types.ts@@ -44,5 +44,5 @@ export interface Template {createdAt: string;}-/** Output formats accepted by POST /v1/audio/speech. */-export const FORMATS = ['wav', 'flac', 'mp3'];+/** Output formats — the official /v1/audio/speech route documents wav only. */+export const FORMATS = ['wav'];diff --git a/server/src/upstream.ts b/server/src/upstream.tsindex c6d96db..3ec242b 100644--- a/server/src/upstream.ts+++ b/server/src/upstream.ts@@ -11,7 +11,7 @@ export const REALTIME_FACTOR = 3;const FRAMES_PER_SECOND = 25;const MAX_FRAMES = 9000;-const EXT: Record<string, string> = { wav: 'wav', flac: 'flac', mp3: 'mp3' };+const EXT: Record<string, string> = { wav: 'wav' };/** Model id in the official model card's example; used when /v1/models doesn't tell us otherwise. */export const DEFAULT_MODEL = 'MiniMaxAI/MiniMax-Music3';export const extFor = (format: string) => EXT[format] ?? format;diff --git a/server/test/app.test.ts b/server/test/app.test.tsindex d929286..9fe9ac9 100644--- a/server/test/app.test.ts+++ b/server/test/app.test.ts@@ -41,18 +41,18 @@ describe('app', () => {it('health probes /v1/models and reports queue state', async () => {const { app } = await setup();const res = await request(app).get('/api/health');- expect(res.body).toMatchObject({ upstreamReachable: true, ready: true, busy: false, queued: 0, formats: ['wav', 'flac', 'mp3'], models: ['minimax_ttm'] });+ expect(res.body).toMatchObject({ upstreamReachable: true, ready: true, busy: false, queued: 0, formats: ['wav'], models: ['minimax_ttm'] });expect(fake!.requests.map((r) => r.path)).toEqual(['/v1/models']);await fake!.close(); fake = null;const down = await request(app).get('/api/health');expect(down.body.upstreamReachable).toBe(false);expect(down.body.error).toMatch(/unreachable/);- expect(down.body.formats).toEqual(['wav', 'flac', 'mp3']);+ expect(down.body.formats).toEqual(['wav']);});it('generate → queue → speech → file: maps fields, serialises takes, forwards bearer', async () => {const { app, lib } = await setup({ renderMs: 120 }, 'sekrit');- const res = await request(app).post('/api/generate').send({ prompt: 'ambient', lyrics: '', duration: 10, format: 'flac', takes: 2, seed: 5 });+ const res = await request(app).post('/api/generate').send({ prompt: 'ambient', lyrics: '', duration: 10, takes: 2, seed: 5 });expect(res.status).toBe(201);expect(res.body).toHaveLength(2);expect(res.body[0]).toMatchObject({ status: 'queued', seed: 5, lyrics: '[Instrumental]' });@@ -66,18 +66,18 @@ describe('app', () => {expect(lib.get(a.id)?.progress).toBeGreaterThan(0);expect(lib.get(a.id)?.progress).toBeLessThan(1);await until(() => lib.get(b.id)?.status === 'done');- expect(lib.get(a.id)).toMatchObject({ status: 'done', file: `${a.id}.flac`, seed: 5, progress: 1, eta: 0 });+ expect(lib.get(a.id)).toMatchObject({ status: 'done', file: `${a.id}.wav`, seed: 5, progress: 1, eta: 0 });const speech = fake!.requests.filter((r) => r.path === '/v1/audio/speech');expect(speech).toHaveLength(2);expect(speech[0].auth).toBe('Bearer sekrit');- expect(speech[0].body).toEqual({ model: 'minimax_ttm', input: '[Instrumental]', instructions: 'ambient', response_format: 'flac', max_new_tokens: 250, stream: false, seed: 5 });+ expect(speech[0].body).toEqual({ model: 'minimax_ttm', input: '[Instrumental]', instructions: 'ambient', response_format: 'wav', max_new_tokens: 250, stream: false, seed: 5 });expect(speech[1].body).toMatchObject({ seed: 6 });const audio = await request(app).get(`/api/tracks/${a.id}/audio`);expect(audio.status).toBe(200);- expect(audio.headers['content-type']).toBe('audio/flac');+ expect(audio.headers['content-type']).toBe('audio/wav');expect(Buffer.from(audio.body).toString()).toBe('RIFF-fake-audio');const dl = await request(app).get(`/api/tracks/${a.id}/audio?download`);- expect(dl.headers['content-disposition']).toMatch(/^attachment; filename=".+\.flac"$/);+ expect(dl.headers['content-disposition']).toMatch(/^attachment; filename=".+\.wav"$/);});it('uses the model id advertised by /v1/models', async () => {@@ -108,7 +108,7 @@ describe('app', () => {it('rejects bad input', async () => {const { app } = await setup();expect((await request(app).post('/api/generate').send({})).status).toBe(400);- expect((await request(app).post('/api/generate').send({ prompt: 'x', format: 'wav16' })).status).toBe(400);+ expect((await request(app).post('/api/generate').send({ prompt: 'x', format: 'flac' })).status).toBe(400);expect((await request(app).post('/api/generate').send({ prompt: 'x', seed: 1.5 })).status).toBe(400);});@@ -135,12 +135,12 @@ describe('app', () => {expect(lib.all()).toEqual([]);expect((await request(app).delete(`/api/tracks/${a.id}`)).status).toBe(404);- const done = await request(app).post('/api/generate').send({ prompt: 'y', format: 'mp3', title: 'ambient piano' });+ const done = await request(app).post('/api/generate').send({ prompt: 'y', title: 'ambient piano' });const id = done.body[0].id;await until(() => lib.get(id)?.status === 'done');- await fs.access(path.join(tracksDir, `${id}.mp3`));+ await fs.access(path.join(tracksDir, `${id}.wav`));expect((await request(app).delete(`/api/tracks/${id}`)).status).toBe(200);- await expect(fs.access(path.join(tracksDir, `${id}.mp3`))).rejects.toThrow();+ await expect(fs.access(path.join(tracksDir, `${id}.wav`))).rejects.toThrow();});it('failOrphans marks leftover renders after a restart', async () => {@@ -171,9 +171,9 @@ describe('app', () => {const { app } = await setup();expect((await request(app).post('/api/templates').send({ prompt: 'x' })).status).toBe(400);expect((await request(app).post('/api/templates').send({ name: 'Lo-fi' })).status).toBe(400);- const c = await request(app).post('/api/templates').send({ name: 'Lo-fi', prompt: 'lo-fi hip hop', lyrics: '', duration: 90, format: 'mp3' });+ const c = await request(app).post('/api/templates').send({ name: 'Lo-fi', prompt: 'lo-fi hip hop', lyrics: '', duration: 90 });expect(c.status).toBe(201);- expect(c.body).toMatchObject({ name: 'Lo-fi', prompt: 'lo-fi hip hop', lyrics: '[Instrumental]', duration: 90, format: 'mp3' });+ expect(c.body).toMatchObject({ name: 'Lo-fi', prompt: 'lo-fi hip hop', lyrics: '[Instrumental]', duration: 90, format: 'wav' });const u = await request(app).post('/api/templates').send({ name: 'lo-fi', prompt: 'lo-fi v2' });expect(u.status).toBe(200);expect(u.body.id).toBe(c.body.id);diff --git a/server/test/fakeUpstream.ts b/server/test/fakeUpstream.tsindex 330dfd0..ba18560 100644--- a/server/test/fakeUpstream.ts+++ b/server/test/fakeUpstream.ts@@ -45,9 +45,9 @@ export async function startFakeUpstream(opts: FakeUpstreamOptions = {}): Promiseif (b.stream === true) return res.status(400).json({ error: 'stream: true is not supported' });if (opts.strictModel && b.model !== (modelId ?? 'MiniMaxAI/MiniMax-Music3')) return res.status(404).json({ error: `model ${b.model} not found` });if (!b.instructions) return res.status(422).json({ detail: 'instructions required' });- if (!['wav', 'flac', 'mp3'].includes(b.response_format ?? 'wav')) return res.status(422).json({ detail: 'response_format must be wav, flac or mp3' });+ if ((b.response_format ?? 'wav') !== 'wav') return res.status(422).json({ detail: 'response_format must be wav' });const timer = setTimeout(() => {- res.setHeader('Content-Type', b.response_format === 'mp3' ? 'audio/mpeg' : b.response_format === 'flac' ? 'audio/flac' : 'audio/wav');+ res.setHeader('Content-Type', 'audio/wav');res.setHeader('X-Seed', String(b.seed ?? 4242));res.send(audio);}, renderMs);diff --git a/server/test/validate.test.ts b/server/test/validate.test.tsindex abae54c..bb59e4b 100644--- a/server/test/validate.test.ts+++ b/server/test/validate.test.ts@@ -22,10 +22,10 @@ describe('normalizeGenerate', () => {expect(normalizeGenerate({ prompt: 'x', seed: '' }).seed).toBeNull();expect(normalizeGenerate({ prompt: 'x', seed: '42' }).seed).toBe(42);});- it('validates format against the speech route list', () => {- expect(() => normalizeGenerate({ prompt: 'x', format: 'ogg' })).toThrow(/format/);- expect(() => normalizeGenerate({ prompt: 'x', format: 'wav16' })).toThrow(/format/);- expect(normalizeGenerate({ prompt: 'x', format: 'flac' }).format).toBe('flac');+ it('only wav is accepted (official route)', () => {+ expect(() => normalizeGenerate({ prompt: 'x', format: 'flac' })).toThrow(/format/);+ expect(() => normalizeGenerate({ prompt: 'x', format: 'mp3' })).toThrow(/format/);+ expect(normalizeGenerate({ prompt: 'x', format: 'wav' }).format).toBe('wav');expect(normalizeGenerate({ prompt: 'x' }).format).toBe('wav');});});diff --git a/web/src/components/CreatePanel.tsx b/web/src/components/CreatePanel.tsxindex ce8e6cf..cc0c998 100644--- a/web/src/components/CreatePanel.tsx+++ b/web/src/components/CreatePanel.tsx@@ -1,9 +1,8 @@-import { useEffect, useMemo, useState } from 'react';+import { useMemo, useState } from 'react';import type { GenerateInput, Health, Track } from '../types';import { LyricsEditor } from './LyricsEditor';import { TemplatesMenu, type TemplateValues } from './TemplatesMenu';import { Chevron, Sparkle } from './Icons';-import { FORMAT_LABEL } from '../lib/format';export const TEMPLATE_PROMPT = 'Genre: acoustic pop. BPM: 96. Key: C major. Warm and intimate, building gently into the chorus. Vocals: soft female lead, close and breathy, light stacked harmonies in the chorus. Arrangement: fingerpicked guitar and soft piano; brushed drums and upright bass enter in the chorus.';@@ -26,7 +25,7 @@ export interface FormState {}export const DEFAULT_FORM: FormState = {- mode: 'simple', title: '', prompt: TEMPLATE_PROMPT, lyrics: TEMPLATE_LYRICS, instrumental: false, duration: 60, takes: 1, seed: '', format: 'flac',+ mode: 'simple', title: '', prompt: TEMPLATE_PROMPT, lyrics: TEMPLATE_LYRICS, instrumental: false, duration: 60, takes: 1, seed: '', format: 'wav',};export function formFromTrack(t: Track): FormState {@@ -56,11 +55,6 @@ export function CreatePanel({ health, form, onFormChange, onSubmit }: Props) {const [error, setError] = useState<string | null>(null);const set = <K extends keyof FormState>(k: K, v: FormState[K]) => onFormChange({ ...form, [k]: v });- const formats = health?.formats?.length ? health.formats : ['wav', 'flac', 'mp3'];- useEffect(() => {- if (!formats.includes(form.format)) onFormChange({ ...form, format: formats.includes('flac') ? 'flac' : formats[0] });- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [formats.join(',')]);const online = !!health?.upstreamReachable;const canSubmit = online && form.prompt.trim().length > 0 && !submitting;@@ -128,7 +122,7 @@ export function CreatePanel({ health, form, onFormChange, onSubmit }: Props) {<div className="flex items-center justify-between mb-1"><div className="label">{form.mode === 'simple' ? 'Song description' : 'Style of music'}</div><TemplatesMenu- builtin={{ prompt: TEMPLATE_PROMPT, lyrics: TEMPLATE_LYRICS, duration: 60, format: 'flac' }}+ builtin={{ prompt: TEMPLATE_PROMPT, lyrics: TEMPLATE_LYRICS, duration: 60, format: 'wav' }}current={{prompt: form.prompt.trim(),lyrics: form.instrumental ? '[Instrumental]' : form.lyrics.trim(),@@ -189,17 +183,11 @@ export function CreatePanel({ health, form, onFormChange, onSubmit }: Props) {<Chevron width={14} height={14} className={`transition-transform ${advanced ? 'rotate-90' : ''}`} /> Advanced</button>{advanced && (- <div className="grid grid-cols-2 gap-3 mt-2">+ <div className="grid grid-cols-2 gap-3 mt-2 max-w-xs"><div><div className="label mb-1">Seed</div><input className="field font-mono" inputMode="numeric" value={form.seed} onChange={(e) => set('seed', e.target.value)} placeholder="random" /></div>- <div>- <div className="label mb-1">Format</div>- <select className="field" value={form.format} onChange={(e) => set('format', e.target.value)}>- {formats.map((f) => <option key={f} value={f}>{FORMAT_LABEL[f] ?? f}</option>)}- </select>- </div></div>)}</div>diff --git a/web/src/components/TemplatesMenu.tsx b/web/src/components/TemplatesMenu.tsxindex 64056e4..44f4845 100644--- a/web/src/components/TemplatesMenu.tsx+++ b/web/src/components/TemplatesMenu.tsx@@ -85,7 +85,7 @@ export function TemplatesMenu({ builtin, current, onLoad }: Props) {<input className="field !py-1 text-xs" placeholder="Template name" value={name} onChange={(e) => setName(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') void save(); }} /><button type="button" className="btn-primary !px-3 !py-1 text-xs" disabled={!name.trim() || saving} onClick={save}>Save</button></div>- <div className="text-[10px] text-zinc-500 px-2 pb-1">Saves style, lyrics, duration and format. Same name overwrites.</div>+ <div className="text-[10px] text-zinc-500 px-2 pb-1">Saves style, lyrics and duration. Same name overwrites.</div>{error && <div className="text-[11px] text-red-400 px-2 pb-1">{error}</div>}</div>)}diff --git a/web/src/components/TrackCard.tsx b/web/src/components/TrackCard.tsxindex e1757d2..ce286a1 100644--- a/web/src/components/TrackCard.tsx+++ b/web/src/components/TrackCard.tsx@@ -1,7 +1,7 @@import { useState } from 'react';import { isInflight, type Track } from '../types';import { coverStyle } from '../lib/cover';-import { fmtAgo, fmtTime, FORMAT_LABEL } from '../lib/format';+import { fmtAgo, fmtTime } from '../lib/format';import { api } from '../api';import { Alert, Download, Pause, Play, Refresh, Reuse, Trash, X } from './Icons';import { ProgressDetail } from './ProgressDetail';@@ -65,8 +65,6 @@ export function TrackCard({ track: t, groupSize, active, playing, onPlay, onDele<div className="mt-2 flex items-center gap-2 text-[11px] text-zinc-500 tabular-nums"><span>{fmtTime(t.duration)}</span>- <span>·</span>- <span>{FORMAT_LABEL[t.format] ?? t.format}</span>{t.seed !== null && (<><span>·</span><span className="font-mono">seed {t.seed}</span></>)}<span>·</span><span>{fmtAgo(t.createdAt)}</span>diff --git a/web/src/hooks/usePolling.ts b/web/src/hooks/usePolling.tsindex 91ca4cb..aad9a03 100644--- a/web/src/hooks/usePolling.ts+++ b/web/src/hooks/usePolling.ts@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';import { api } from '../api';import { isInflight, type Health, type Track } from '../types';-const OFFLINE_HEALTH: Health = { upstreamReachable: false, ready: false, busy: false, queued: 0, formats: ['wav', 'flac', 'mp3'], error: 'ui server unreachable' };+const OFFLINE_HEALTH: Health = { upstreamReachable: false, ready: false, busy: false, queued: 0, formats: ['wav'], error: 'ui server unreachable' };export function useHealth(intervalMs = 5000) {const [health, setHealth] = useState<Health | null>(null);diff --git a/web/src/lib/format.ts b/web/src/lib/format.tsindex 17ddc46..9e542c9 100644--- a/web/src/lib/format.ts+++ b/web/src/lib/format.ts@@ -19,4 +19,4 @@ export function fmtAgo(iso: string): string {return new Date(iso).toLocaleDateString();}-export const FORMAT_LABEL: Record<string, string> = { wav: 'WAV', flac: 'FLAC', mp3: 'MP3' };+export const FORMAT_LABEL: Record<string, string> = { wav: 'WAV' };