Suno-style web UI for a self-hosted MiniMax-Music3 inference server
TypeScript ai-musicdiffusersdockerexpressminimaxminimax-musicmusic-generationreactself-hostedsgl-omnisunotailwindcsstext-to-musictypescriptvite
feat: random song title when none is given
Adam Benhassenee82446a6c07
diff --git a/README.md b/README.mdindex b0592fe..4f1d961 100644--- a/README.md+++ b/README.md@@ -21,7 +21,7 @@## Features-- **Create panel** — Simple or Custom mode, song title, 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 / steps / output format.+- **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 / steps / output format.- **Templates** — a built-in default plus your own saved templates (style, lyrics, duration, steps, format), stored server-side.- **Live queue** — cards show stage, progress bar and ETA straight from the inference server; cancel while queued, retry on error.- **Library** — every finished render is downloaded into `data/tracks/` with its metadata (prompt, lyrics, seed, peak level…) so it survives the inference box pruning its own job list. Search, download, delete, "reuse settings".diff --git a/server/src/app.ts b/server/src/app.tsindex 8831272..2b55aec 100644--- a/server/src/app.ts+++ b/server/src/app.ts@@ -9,6 +9,7 @@ import { normalizeGenerate, ValidationError } from './validate.js';import { normalizeMusicApi, SettingsStore } from './settings.js';import { DEFAULT_FORMATS, type Template, type Track, type UpstreamHealth } from './types.js';import { extFor } from './poller.js';+import { randomTitle } from './names.js';export interface AppDeps {library: Library;@@ -51,6 +52,7 @@ export function createApp(deps: AppDeps) {const formats = lastHealth?.formats?.length ? lastHealth.formats : DEFAULT_FORMATS;const g = normalizeGenerate(req.body, formats);const groupId = randomUUID();+ const title = g.title || randomTitle();const created: Track[] = [];for (let i = 0; i < g.takes; i++) {const seed = g.seed === null ? null : g.seed + i;@@ -59,7 +61,7 @@ export function createApp(deps: AppDeps) {groupId,takeIndex: i,jobId: null,- title: g.title || titleFromPrompt(g.prompt),+ title,prompt: g.prompt,lyrics: g.lyrics,duration: g.duration,@@ -219,10 +221,4 @@ export function createApp(deps: AppDeps) {return app;}-export function titleFromPrompt(prompt: string): string {- const cleaned = prompt.replace(/^(Global Metadata|Vocal Details|Arrangement):\s*/i, '').replace(/\s+/g, ' ').trim();- const words = cleaned.split(' ').slice(0, 6).join(' ');- return words.length > 48 ? `${words.slice(0, 45)}…` : words || 'Untitled';-}-const safeName = (s: string) => s.replace(/[^\w\- ]+/g, '').trim().slice(0, 60) || 'track';diff --git a/server/src/names.ts b/server/src/names.tsnew file mode 100644index 0000000..2e8536a--- /dev/null+++ b/server/src/names.ts@@ -0,0 +1,31 @@+const ADJECTIVES = [+ 'Velvet', 'Neon', 'Paper', 'Golden', 'Hollow', 'Quiet', 'Electric', 'Midnight', 'Amber', 'Wild',+ 'Silver', 'Broken', 'Distant', 'Faded', 'Crimson', 'Lonely', 'Restless', 'Tender', 'Glass', 'Slow',+ 'Violet', 'Empty', 'Burning', 'Frozen', 'Sunday', 'Endless', 'Sacred', 'Little', 'Wandering', 'Cobalt',+ 'Honey', 'Static', 'Pale', 'Sleepless', 'Summer', 'Winter', 'Secret', 'Northern', 'Blue', 'Last',+];+const NOUNS = [+ 'Horizon', 'Rain', 'Cathedral', 'Signal', 'Rivers', 'Lanterns', 'Orbit', 'Tides', 'Weather', 'Mirrors',+ 'Streets', 'Radio', 'Fires', 'Gardens', 'Ghost', 'Highway', 'Satellites', 'Harbor', 'Postcards', 'Windows',+ 'Static', 'Bloom', 'Echoes', 'Motel', 'Coastline', 'Parade', 'Sunday', 'Kingdom', 'Currents', 'Sparrows',+ 'Avenue', 'Comet', 'Machines', 'Lullaby', 'Cinema', 'Skyline', 'Wolves', 'Daydream', 'Voltage', 'Fable',+];+const PATTERNS: ((a: string, n: string, n2: string) => string)[] = [+ (a, n) => `${a} ${n}`,+ (a, n) => `${a} ${n}`,+ (a, n) => `${a} ${n}`,+ (_a, n, n2) => `${n} & ${n2}`,+ (a, n) => `The ${a} ${n}`,+ (_a, n, n2) => `${n} of ${n2}`,+];++const pick = <T,>(arr: T[], rnd: () => number) => arr[Math.floor(rnd() * arr.length)];++/** A random two-word song title, e.g. "Velvet Horizon". `rnd` is injectable for tests. */+export function randomTitle(rnd: () => number = Math.random): string {+ const a = pick(ADJECTIVES, rnd);+ const n = pick(NOUNS, rnd);+ let n2 = pick(NOUNS, rnd);+ if (n2 === n) n2 = NOUNS[(NOUNS.indexOf(n) + 1) % NOUNS.length];+ return pick(PATTERNS, rnd)(a, n, n2);+}diff --git a/server/test/app.test.ts b/server/test/app.test.tsindex c070bc4..a84fc2d 100644--- a/server/test/app.test.ts+++ b/server/test/app.test.ts@@ -7,7 +7,7 @@ import { JsonStore, Library } from '../src/library.js';import type { Template } from '../src/types.js';import { UpstreamClient } from '../src/upstream.js';import { Poller } from '../src/poller.js';-import { createApp, titleFromPrompt } from '../src/app.js';+import { createApp } from '../src/app.js';import { SettingsStore } from '../src/settings.js';import { startFakeUpstream, type FakeUpstream } from './fakeUpstream.js';@@ -48,7 +48,8 @@ describe('app', () => {expect(res.body).toHaveLength(3);expect(res.body.map((t: { seed: number }) => t.seed)).toEqual([100, 101, 102]);expect(res.body[0].groupId).toBe(res.body[2].groupId);- expect(res.body[0].title).toBe('lo-fi hip hop, 80 BPM');+ expect(res.body[0].title).toMatch(/^[A-Z][A-Za-z&' ]+$/);+ expect(new Set(res.body.map((t: { title: string }) => t.title)).size).toBe(1); // all takes share the nameexpect(res.body.every((t: { jobId: string }) => t.jobId)).toBe(true);expect(lib.all()).toHaveLength(3);const gen = fake!.requests.filter((r) => r.path === '/generate');@@ -74,7 +75,7 @@ describe('app', () => {it('full cycle: generate → poll → audio → delete', async () => {const { app, poller, tracksDir } = await setup();- const { body } = await request(app).post('/api/generate').send({ prompt: 'ambient piano', format: 'mp3' });+ const { body } = await request(app).post('/api/generate').send({ prompt: 'ambient piano', title: 'ambient piano', format: 'mp3' });const id = body[0].id;for (let i = 0; i < 8; i++) await poller.tick();const lib = await request(app).get('/api/library');@@ -178,8 +179,9 @@ describe('app', () => {expect((await request(app).get('/api/settings')).body.musicApi).toBe('http://127.0.0.1:7862');});- it('titleFromPrompt strips structured prefix', () => {- expect(titleFromPrompt('Global Metadata: genre dream pop, 92 BPM, D major, wistful')).toBe('genre dream pop, 92 BPM, D');- expect(titleFromPrompt(' ')).toBe('Untitled');+ it('uses the given title when present', async () => {+ const { app } = await setup();+ const res = await request(app).post('/api/generate').send({ prompt: 'x', title: ' Pine Morning ' });+ expect(res.body[0].title).toBe('Pine Morning');});});diff --git a/server/test/names.test.ts b/server/test/names.test.tsnew file mode 100644index 0000000..e315acd--- /dev/null+++ b/server/test/names.test.ts@@ -0,0 +1,17 @@+import { describe, it, expect } from 'vitest';+import { randomTitle } from '../src/names.js';++describe('randomTitle', () => {+ it('is deterministic for a given rng and never repeats a noun', () => {+ let i = 0;+ const seq = [0.1, 0.2, 0.2, 0.5];+ const rnd = () => seq[i++ % seq.length];+ expect(randomTitle(rnd)).toBe(randomTitle(() => seq[(i++ - 4) % seq.length]));+ for (let k = 0; k < 200; k++) {+ const t = randomTitle();+ const words = t.replace(/^The /, '').split(/ (?:&|of) | /);+ expect(t.length).toBeGreaterThan(3);+ expect(new Set(words).size).toBe(words.length);+ }+ });+});diff --git a/web/src/components/CreatePanel.tsx b/web/src/components/CreatePanel.tsxindex f80e43a..2433842 100644--- a/web/src/components/CreatePanel.tsx+++ b/web/src/components/CreatePanel.tsx@@ -126,7 +126,7 @@ export function CreatePanel({ health, form, onFormChange, onSubmit }: Props) {<div><div className="label mb-1">Song title <span className="text-zinc-600 normal-case tracking-normal">(optional)</span></div>- <input className="field" value={form.title} onChange={(e) => set('title', e.target.value)} placeholder="Auto-named from the description if empty" maxLength={120} />+ <input className="field" value={form.title} onChange={(e) => set('title', e.target.value)} placeholder="Leave empty for a random name" maxLength={120} /></div><div>