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