수노 타임아웃 증가
parent
2ac4b75d96
commit
7e2646337f
|
|
@ -192,24 +192,21 @@ class SunoService:
|
|||
data.alignedWords: 수노 가사 input - startS endS 시간 데이터 매핑
|
||||
"""
|
||||
|
||||
payload = {
|
||||
"task_id" : task_id,
|
||||
"audio_id" : audio_id
|
||||
}
|
||||
payload = {"task_id": task_id, "audio_id": audio_id}
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
f"{self.BASE_URL}/generate/get-timestamped-lyrics",
|
||||
headers=self.headers,
|
||||
json=payload,
|
||||
timeout=30.0,
|
||||
timeout=120.0,
|
||||
)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
|
||||
if not data or not data['data']:
|
||||
if not data or not data["data"]:
|
||||
raise ValueError("Suno API returned empty response for task status")
|
||||
|
||||
return data['data']['alignedWords']
|
||||
return data["data"]["alignedWords"]
|
||||
|
||||
def parse_status_response(self, result: dict | None) -> PollingSongResponse:
|
||||
"""Suno API 상태 응답을 파싱하여 PollingSongResponse로 변환합니다.
|
||||
|
|
@ -295,7 +292,7 @@ class SunoService:
|
|||
word_ranges = [] # [(start_pos, end_pos, entry), ...]
|
||||
|
||||
for entry in word_data:
|
||||
word = entry['word']
|
||||
word = entry["word"]
|
||||
start_pos = len(full_text)
|
||||
full_text += word
|
||||
end_pos = len(full_text) - 1
|
||||
|
|
@ -306,9 +303,9 @@ class SunoService:
|
|||
meta_ranges = []
|
||||
i = 0
|
||||
while i < len(full_text):
|
||||
if full_text[i] == '[':
|
||||
if full_text[i] == "[":
|
||||
start = i
|
||||
while i < len(full_text) and full_text[i] != ']':
|
||||
while i < len(full_text) and full_text[i] != "]":
|
||||
i += 1
|
||||
meta_ranges.append((start, i + 1))
|
||||
i += 1
|
||||
|
|
@ -331,10 +328,10 @@ class SunoService:
|
|||
|
||||
# Step 4: 문장 매칭
|
||||
def normalize(text):
|
||||
return ''.join(c for c in text if c not in ' \n\t-')
|
||||
return "".join(c for c in text if c not in " \n\t-")
|
||||
|
||||
norm_clean = normalize(clean_text)
|
||||
norm_to_clean = [i for i, c in enumerate(clean_text) if c not in ' \n\t-']
|
||||
norm_to_clean = [i for i, c in enumerate(clean_text) if c not in " \n\t-"]
|
||||
|
||||
results = []
|
||||
search_pos = 0
|
||||
|
|
@ -353,14 +350,16 @@ class SunoService:
|
|||
word_start = get_word_at(old_start)
|
||||
word_end = get_word_at(old_end)
|
||||
|
||||
results.append({
|
||||
'text': sentence,
|
||||
'start_sec': word_start['startS'],
|
||||
'end_sec': word_end['endS'],
|
||||
})
|
||||
results.append(
|
||||
{
|
||||
"text": sentence,
|
||||
"start_sec": word_start["startS"],
|
||||
"end_sec": word_end["endS"],
|
||||
}
|
||||
)
|
||||
|
||||
search_pos = found_pos + len(norm_sentence)
|
||||
else:
|
||||
results.append({'text': sentence, 'start_sec': None, 'end_sec': None})
|
||||
results.append({"text": sentence, "start_sec": None, "end_sec": None})
|
||||
|
||||
return results
|
||||
Loading…
Reference in New Issue