Skip to content

Suno-style web UI for a self-hosted MiniMax-Music3 inference server

2.7 KB
Raw Blame
export type TrackStatus = 'queued' | 'running' | 'done' | 'error';

export interface Track {
  id: string;
  groupId: string;
  takeIndex: number;
  title: string;
  prompt: string;
  lyrics: string;
  duration: number;
  seed: number | null;
  format: string;
  status: TrackStatus;
  /** 0..1 — estimated while rendering (the API is blocking and reports no progress) */
  progress: number;
  stage: string;
  eta: number | null;
  elapsed?: number | null;
  /** opt-in per track: stream audio windows for play-while-rendering (progress is live regardless when the server supports it) */
  stream: boolean;
  /** seconds of audio on disk while a streamed render is running; null when the server can't stream */
  renderedSeconds: number | null;
  error: string | null;
  file: string | null;
  createdAt: string;
  finishedAt: string | null;
}

export interface Health {
  /** public read-only demo: showcase library, simulated renders */
  demo?: boolean;
  upstreamReachable: boolean;
  ready: boolean;
  busy: boolean;
  queued: number;
  formats: string[];
  models?: string[];
  /** optional upstream extras, e.g. "stream" (live progress + play-while-rendering) */
  capabilities?: string[];
  /** an LLM is configured, so the prompt can be rewritten with MiniMax's caption-rewriter skill */
  enhance?: boolean;
  error?: string;
}

export interface GenerateInput {
  title: string;
  prompt: string;
  lyrics: string;
  duration: number;
  seed: number | null;
  format: string;
  takes: number;
  stream: boolean;
}

export interface Template {
  id: string;
  name: string;
  prompt: string;
  lyrics: string;
  duration: number;
  format: string;
  createdAt: string;
}

export interface Settings {
  musicApi: string;
  apiKeySet: boolean;
  /** debug/testing: treat the server as stock sgl-omni (no /health, no streaming) */
  compat: boolean;
  /** OpenAI-compatible LLM for prompt enhancement */
  llmApi: string | null;
  llmModel: string | null;
  llmKeySet: boolean;
  source: {
    musicApi: 'env' | 'settings' | 'default'; apiKey: 'env' | 'settings' | 'none';
    llmApi: 'env' | 'settings' | 'none'; llmApiKey: 'env' | 'settings' | 'none'; llmModel: 'env' | 'settings' | 'none';
  };
  locked: { musicApi: boolean; apiKey: boolean; llmApi: boolean; llmApiKey: boolean; llmModel: boolean };
}

export interface SettingsTestResult {
  ok: boolean;
  musicApi: string;
  health?: Health;
  error?: string;
}

export const isInflight = (t: Track) => t.status === 'queued' || t.status === 'running';
/** done, or rendering with early audio enabled — play arms it and playback starts when audio arrives */
export const isPlayable = (t: Track) => t.status === 'done' || (t.status === 'running' && t.stream);