fix: ai-bridge ACE-Step fallback for /generate/music
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,14 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
if (url.pathname === "/generate/music" && req.method === "POST") {
|
||||
const {prompt="ambient",duration=30,style="experimental"} = JSON.parse(await readBody(req));
|
||||
// Try ACE-Step first (20s for 4min, MIT) → fallback to MusicGen
|
||||
try {
|
||||
const aceOk = await fetch(ACE_STEP_URL + '/health', {signal:AbortSignal.timeout(2000)}).then(r=>r.json()).catch(()=>null);
|
||||
if (aceOk && aceOk.ok) {
|
||||
const ar = await fetch(ACE_STEP_URL + '/generate', {method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({prompt:prompt+', '+style,duration,steps:8}),signal:AbortSignal.timeout(300000)});
|
||||
if (ar.ok) { const buf = Buffer.from(await ar.arrayBuffer()); res.writeHead(200,{'Content-Type':'audio/wav','Content-Length':buf.length}); res.end(buf); return; }
|
||||
}
|
||||
} catch {} // ACE-Step unavailable, fall through
|
||||
try {
|
||||
const r = await fetch(`${TTS_URL}/compose`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:`${prompt}, ${style}`,duration}),signal:AbortSignal.timeout(300000)});
|
||||
if (!r.ok) throw new Error(`TTS ${r.status}`);
|
||||
|
||||
Reference in New Issue
Block a user