Merge pull request #96 from karldivad/main

Adds error message management on generation
This commit is contained in:
blueeon 2024-06-06 01:03:16 +08:00 committed by GitHub
commit 9be31d8519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,6 +23,7 @@ export interface AudioInfo {
type?: string;
tags?: string; // Genre of music.
duration?: string; // Duration of the audio
error_message?: string; // Error message if any
}
class SunoApi {
@ -227,7 +228,10 @@ class SunoApi {
const allCompleted = response.every(
audio => audio.status === 'streaming' || audio.status === 'complete'
);
if (allCompleted) {
const allError = response.every(
audio => audio.status === 'error'
);
if (allCompleted || allError) {
return response;
}
lastResponse = response;
@ -358,6 +362,7 @@ class SunoApi {
type: audio.metadata.type,
tags: audio.metadata.tags,
duration: audio.metadata.duration_formatted,
error_message: audio.metadata.error_message,
}));
}