브랜드 분석 페이지 css 수정, song id polling 적용 .

This commit is contained in:
HyeongBaeYang committed 2026-01-22 11:52:19 +09:00
1 parent e3ed840d12
commit d5b6ad6958
6 files changed
+120 -161

No files matched your search

+16 -14
View File
@@ -22,6 +22,7 @@ type GenerationStatus = 'idle' | 'generating_lyric' | 'generating_song' | 'polli
interface SavedGenerationState {
taskId: string;
songId: string;
lyrics: string;
status: GenerationStatus;
timestamp: number;
@@ -70,9 +71,10 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
const audioRef = useRef<HTMLAudioElement>(null);
const languageDropdownRef = useRef<HTMLDivElement>(null);
const saveToStorage = (taskId: string, currentLyrics: string, currentStatus: GenerationStatus) => {
const saveToStorage = (taskId: string, songId: string, currentLyrics: string, currentStatus: GenerationStatus) => {
const data: SavedGenerationState = {
taskId,
songId,
lyrics: currentLyrics,
status: currentStatus,
timestamp: Date.now(),
@@ -112,7 +114,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
}
setStatus('polling');
setStatusMessage('노래를 생성하고 있습니다... (새로고침 후 복구됨)');
resumePolling(savedState.taskId, savedState.lyrics, 0);
resumePolling(savedState.taskId, savedState.songId, savedState.lyrics, 0);
}
}, []);
@@ -144,25 +146,25 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
}
}, [videoGenerationStatus, songTaskId, onNext]);
const resumePolling = async (taskId: string, currentLyrics: string, currentRetryCount: number = 0) => {
const resumePolling = async (taskId: string, songId: string, currentLyrics: string, currentRetryCount: number = 0) => {
try {
const downloadResponse = await waitForSongComplete(
taskId,
const statusResponse = await waitForSongComplete(
songId,
(pollStatus: string) => {
if (pollStatus === 'processing') {
if (pollStatus === 'streaming') {
setStatusMessage('노래를 생성하고 있습니다...');
} else if (pollStatus === 'uploading') {
setStatusMessage('노래를 업로드하고 있습니다...');
} else if (pollStatus === 'queued') {
setStatusMessage('노래 생성 대기 중...');
}
}
);
if (!downloadResponse.success) {
throw new Error(downloadResponse.error_message || '음악 다운로드에 실패했습니다.');
if (!statusResponse.success) {
throw new Error(statusResponse.error_message || '음악 생성에 실패했습니다.');
}
setAudioUrl(downloadResponse.song_result_url);
setSongTaskId(downloadResponse.task_id);
setAudioUrl(statusResponse.song_url);
setSongTaskId(taskId);
setStatus('complete');
setStatusMessage('');
setRetryCount(0);
@@ -218,8 +220,8 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
throw new Error(songResponse.error_message || '음악 생성 요청에 실패했습니다.');
}
saveToStorage(songResponse.task_id, currentLyrics, 'polling');
await resumePolling(songResponse.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);