Validate source audio is loadable before cover/repaint generation

When prepareAudioFile fails (file not found), it was returning null
silently. For cover and repaint modes this caused Gradio to run without
source audio, generating a short/empty/silent result instead of failing
with a clear error message.
This commit is contained in:
fspecii
2026-03-02 18:12:57 +02:00
parent 78426c00dd
commit 8f67d6a1aa
+6
View File
@@ -141,6 +141,12 @@ async function buildGradioArgs(params: GenerationParams): Promise<unknown[]> {
const referenceAudio = await prepareAudioFile(params.referenceAudioUrl); const referenceAudio = await prepareAudioFile(params.referenceAudioUrl);
const sourceAudio = await prepareAudioFile(params.sourceAudioUrl); const sourceAudio = await prepareAudioFile(params.sourceAudioUrl);
// Guard: cover/repaint modes require source audio to be loadable
const needsSource = params.taskType === 'cover' || params.taskType === 'audio2audio' || params.taskType === 'repaint';
if (needsSource && params.sourceAudioUrl && sourceAudio === null) {
throw new Error(`Source audio file could not be loaded from: ${params.sourceAudioUrl}. Make sure the file was uploaded successfully.`);
}
// CoT features are gated by enhance OR thinking (either enables LLM enrichment) // CoT features are gated by enhance OR thinking (either enables LLM enrichment)
const useCot = isEnhance || isThinking; const useCot = isEnhance || isThinking;