노래 백그라운드 추가

This commit is contained in:
bluebamus committed 2025-12-24 15:13:46 +09:00
1 parent cafe6a894e
commit b7df726345
14 files changed
+1102 -715

No files matched your search

+136 -23
View File
@@ -15,7 +15,7 @@ class GenerateSongRequest(BaseModel):
"""노래 생성 요청 스키마
Usage:
POST /song/generate
POST /song/generate/{task_id}
Request body for generating a song via Suno API.
Example Request:
@@ -51,29 +51,46 @@ class GenerateSongResponse(BaseModel):
"""노래 생성 응답 스키마
Usage:
POST /song/generate
Returns the task ID for tracking song generation.
POST /song/generate/{task_id}
Returns the task IDs for tracking song generation.
Example Response:
Note:
실패 조건:
- task_id에 해당하는 Project가 없는 경우 (404 HTTPException)
- task_id에 해당하는 Lyric이 없는 경우 (404 HTTPException)
- Suno API 호출 실패
Example Response (Success):
{
"success": true,
"task_id": "abc123...",
"message": "노래 생성 요청이 접수되었습니다."
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
"suno_task_id": "abc123...",
"message": "노래 생성 요청이 접수되었습니다. suno_task_id로 상태를 조회하세요.",
"error_message": null
}
Example Response (Failure):
{
"success": false,
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
"suno_task_id": null,
"message": "노래 생성 요청에 실패했습니다.",
"error_message": "Suno API connection error"
}
"""
success: bool = Field(..., description="요청 성공 여부")
task_id: Optional[str] = Field(None, description="Suno 작업 ID")
task_id: Optional[str] = Field(None, description="내부 작업 ID (Project/Lyric task_id)")
suno_task_id: Optional[str] = Field(None, description="Suno API 작업 ID")
message: str = Field(..., description="응답 메시지")
error_message: Optional[str] = Field(None, description="에러 메시지 (실패 시)")
class PollingSongRequest(BaseModel):
"""노래 생성 상태 조회 요청 스키마
"""노래 생성 상태 조회 요청 스키마 (Legacy)
Usage:
POST /song/polling
Request body for checking song generation status.
Note:
현재 사용되지 않음. GET /song/status/{suno_task_id} 엔드포인트 사용.
Example Request:
{
@@ -100,21 +117,66 @@ class PollingSongResponse(BaseModel):
"""노래 생성 상태 조회 응답 스키마
Usage:
POST /song/polling 또는 GET /song/status/{task_id}
Returns the current status of song generation.
GET /song/status/{suno_task_id}
Suno API 작업 상태를 조회합니다.
Example Response:
Note:
상태 값:
- PENDING: 대기 중
- processing: 생성 중
- SUCCESS / TEXT_SUCCESS / complete: 생성 완료
- failed: 생성 실패
- error: API 조회 오류
SUCCESS 상태 시:
- 백그라운드에서 MP3 파일 다운로드 시작
- Song 테이블의 status를 completed로 업데이트
- song_result_url에 로컬 파일 경로 저장
Example Response (Processing):
{
"success": true,
"status": "complete",
"status": "processing",
"message": "노래를 생성하고 있습니다.",
"clips": null,
"raw_response": {...},
"error_message": null
}
Example Response (Success):
{
"success": true,
"status": "SUCCESS",
"message": "노래 생성이 완료되었습니다.",
"clips": [...]
"clips": [
{
"id": "clip-id",
"audio_url": "https://...",
"stream_audio_url": "https://...",
"image_url": "https://...",
"title": "Song Title",
"status": "complete",
"duration": 60.0
}
],
"raw_response": {...},
"error_message": null
}
Example Response (Failure):
{
"success": false,
"status": "error",
"message": "상태 조회에 실패했습니다.",
"clips": null,
"raw_response": null,
"error_message": "ConnectionError: ..."
}
"""
success: bool = Field(..., description="조회 성공 여부")
status: Optional[str] = Field(
None, description="작업 상태 (pending, processing, complete, failed)"
None, description="작업 상태 (PENDING, processing, SUCCESS, failed)"
)
message: str = Field(..., description="상태 메시지")
clips: Optional[List[SongClipData]] = Field(None, description="생성된 노래 클립 목록")
@@ -127,21 +189,72 @@ class DownloadSongResponse(BaseModel):
Usage:
GET /song/download/{task_id}
Downloads the generated song and returns the local file path.
Polls for song completion and returns project info with song URL.
Example Response:
Note:
상태 값:
- processing: 노래 생성 진행 중 (song_result_url은 null)
- completed: 노래 생성 완료 (song_result_url 포함)
- failed: 노래 생성 실패
- not_found: task_id에 해당하는 Song 없음
- error: 조회 중 오류 발생
Example Response (Processing):
{
"success": true,
"status": "processing",
"message": "노래 생성이 진행 중입니다.",
"store_name": null,
"region": null,
"detail_region_info": null,
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
"language": null,
"song_result_url": null,
"created_at": null,
"error_message": null
}
Example Response (Completed):
{
"success": true,
"status": "completed",
"message": "노래 다운로드가 완료되었습니다.",
"file_path": "/media/2025-01-15/01234567-89ab-7def-0123-456789abcdef/song.mp3",
"file_url": "http://localhost:8000/media/2025-01-15/01234567-89ab-7def-0123-456789abcdef/song.mp3"
"store_name": "스테이 머뭄",
"region": "군산",
"detail_region_info": "군산 신흥동 말랭이 마을",
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
"language": "Korean",
"song_result_url": "http://localhost:8000/media/2025-01-15/스테이머뭄.mp3",
"created_at": "2025-01-15T12:00:00",
"error_message": null
}
Example Response (Not Found):
{
"success": false,
"status": "not_found",
"message": "task_id 'xxx'에 해당하는 Song을 찾을 수 없습니다.",
"store_name": null,
"region": null,
"detail_region_info": null,
"task_id": null,
"language": null,
"song_result_url": null,
"created_at": null,
"error_message": "Song not found"
}
"""
success: bool = Field(..., description="다운로드 성공 여부")
status: str = Field(..., description="처리 상태 (processing, completed, failed, not_found, error)")
message: str = Field(..., description="응답 메시지")
file_path: Optional[str] = Field(None, description="저장된 파일 경로 (상대 경로)")
file_url: Optional[str] = Field(None, description="파일 접근 URL")
store_name: Optional[str] = Field(None, description="업체명")
region: Optional[str] = Field(None, description="지역명")
detail_region_info: Optional[str] = Field(None, description="상세 지역 정보")
task_id: Optional[str] = Field(None, description="작업 고유 식별자")
language: Optional[str] = Field(None, description="언어")
song_result_url: Optional[str] = Field(None, description="노래 결과 URL")
created_at: Optional[datetime] = Field(None, description="생성 일시")
error_message: Optional[str] = Field(None, description="에러 메시지 (실패 시)")