suno task id -> song id 상태확인 변경 .
parent
9a7c55de49
commit
2acf4e2cb6
|
|
@ -22,7 +22,7 @@ type GenerationStatus = 'idle' | 'generating_lyric' | 'generating_song' | 'polli
|
|||
|
||||
interface SavedGenerationState {
|
||||
taskId: string;
|
||||
sunoTaskId: string;
|
||||
songId: string;
|
||||
lyrics: string;
|
||||
status: GenerationStatus;
|
||||
timestamp: number;
|
||||
|
|
@ -71,10 +71,10 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
|||
const audioRef = useRef<HTMLAudioElement>(null);
|
||||
const languageDropdownRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const saveToStorage = (taskId: string, sunoTaskId: string, currentLyrics: string, currentStatus: GenerationStatus) => {
|
||||
const saveToStorage = (taskId: string, songId: string, currentLyrics: string, currentStatus: GenerationStatus) => {
|
||||
const data: SavedGenerationState = {
|
||||
taskId,
|
||||
sunoTaskId,
|
||||
songId,
|
||||
lyrics: currentLyrics,
|
||||
status: currentStatus,
|
||||
timestamp: Date.now(),
|
||||
|
|
@ -114,7 +114,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
|||
}
|
||||
setStatus('polling');
|
||||
setStatusMessage('노래를 생성하고 있습니다... (새로고침 후 복구됨)');
|
||||
resumePolling(savedState.taskId, savedState.sunoTaskId, savedState.lyrics, 0);
|
||||
resumePolling(savedState.taskId, savedState.songId, savedState.lyrics, 0);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
@ -146,11 +146,11 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
|||
}
|
||||
}, [videoGenerationStatus, songTaskId, onNext]);
|
||||
|
||||
const resumePolling = async (taskId: string, sunoTaskId: string, currentLyrics: string, currentRetryCount: number = 0) => {
|
||||
const resumePolling = async (taskId: string, songId: string, currentLyrics: string, currentRetryCount: number = 0) => {
|
||||
try {
|
||||
const downloadResponse = await waitForSongComplete(
|
||||
taskId,
|
||||
sunoTaskId,
|
||||
songId,
|
||||
(pollStatus: string) => {
|
||||
if (pollStatus === 'pending') {
|
||||
setStatusMessage('노래를 생성하고 있습니다...');
|
||||
|
|
@ -221,8 +221,8 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
|||
throw new Error(songResponse.error_message || '음악 생성 요청에 실패했습니다.');
|
||||
}
|
||||
|
||||
saveToStorage(songResponse.task_id, songResponse.suno_task_id, currentLyrics, 'polling');
|
||||
await resumePolling(songResponse.task_id, songResponse.suno_task_id, currentLyrics, currentRetryCount);
|
||||
saveToStorage(songResponse.task_id, songResponse.song_id, currentLyrics, 'polling');
|
||||
await resumePolling(songResponse.task_id, songResponse.song_id, currentLyrics, currentRetryCount);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Song regeneration failed:', error);
|
||||
|
|
@ -396,9 +396,9 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
|||
|
||||
setStatus('polling');
|
||||
setStatusMessage('노래를 생성하고 있습니다...');
|
||||
saveToStorage(songResponse.task_id, songResponse.suno_task_id, lyricDetailResponse.lyric_result, 'polling');
|
||||
saveToStorage(songResponse.task_id, songResponse.song_id, lyricDetailResponse.lyric_result, 'polling');
|
||||
|
||||
await resumePolling(songResponse.task_id, songResponse.suno_task_id, lyricDetailResponse.lyric_result, 0);
|
||||
await resumePolling(songResponse.task_id, songResponse.song_id, lyricDetailResponse.lyric_result, 0);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Music generation failed:', error);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ export interface SongGenerateRequest {
|
|||
export interface SongGenerateResponse {
|
||||
success: boolean;
|
||||
task_id: string;
|
||||
suno_task_id: string;
|
||||
song_id: string;
|
||||
message: string;
|
||||
error_message: string | null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,9 +150,9 @@ export async function generateSong(taskId: string, request: SongGenerateRequest)
|
|||
return response.json();
|
||||
}
|
||||
|
||||
// 노래 상태 확인 API (suno_task_id 사용)
|
||||
export async function getSongStatus(sunoTaskId: string): Promise<SongStatusResponse> {
|
||||
const response = await fetch(`${API_URL}/song/status/${sunoTaskId}`, {
|
||||
// 노래 상태 확인 API (song_id 사용)
|
||||
export async function getSongStatus(songId: string): Promise<SongStatusResponse> {
|
||||
const response = await fetch(`${API_URL}/song/status/${songId}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ const POLL_INTERVAL = 5000; // 5초
|
|||
|
||||
export async function waitForSongComplete(
|
||||
taskId: string,
|
||||
sunoTaskId: string,
|
||||
songId: string,
|
||||
onStatusChange?: (status: string) => void
|
||||
): Promise<SongDownloadResponse> {
|
||||
const startTime = Date.now();
|
||||
|
|
@ -195,8 +195,8 @@ export async function waitForSongComplete(
|
|||
}
|
||||
|
||||
try {
|
||||
// 상태 확인은 suno_task_id 사용
|
||||
const statusResponse = await getSongStatus(sunoTaskId);
|
||||
// 상태 확인은 song_id 사용
|
||||
const statusResponse = await getSongStatus(songId);
|
||||
onStatusChange?.(statusResponse.status);
|
||||
|
||||
// status가 "SUCCESS" (대문자)인 경우 완료
|
||||
|
|
|
|||
Loading…
Reference in New Issue