Spaces:
Running
on
Zero
Running
on
Zero
Update sonic.py
Browse files
sonic.py
CHANGED
@@ -61,6 +61,14 @@ def test(
|
|
61 |
audio_prompts.append(audio_prompt)
|
62 |
last_audio_prompts.append(last_audio_prompt)
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
audio_prompts = torch.cat(audio_prompts, dim=1)
|
65 |
# audio_len*2 부분은 모델 내부 로직에 따라 필요한 padding 처리
|
66 |
audio_prompts = audio_prompts[:, :audio_len*2]
|
@@ -281,7 +289,6 @@ class Sonic():
|
|
281 |
audio_video_path = output_path
|
282 |
|
283 |
# limit=config.frame_num 대신 오디오 전체를 쓰도록 수정
|
284 |
-
# 만약 config.frame_num이 작아 2초 제한을 걸고 있었다면 제거해야 함
|
285 |
test_data = image_audio_to_tensor(
|
286 |
self.face_det,
|
287 |
self.feature_extractor,
|
|
|
61 |
audio_prompts.append(audio_prompt)
|
62 |
last_audio_prompts.append(last_audio_prompt)
|
63 |
|
64 |
+
# ---------------------- [추가된 예외 처리] ----------------------
|
65 |
+
if len(audio_prompts) == 0:
|
66 |
+
raise ValueError(
|
67 |
+
"[ERROR] No speech recognized from the audio. "
|
68 |
+
"Please provide a valid speech audio (with clear voice)."
|
69 |
+
)
|
70 |
+
# -------------------------------------------------------------
|
71 |
+
|
72 |
audio_prompts = torch.cat(audio_prompts, dim=1)
|
73 |
# audio_len*2 부분은 모델 내부 로직에 따라 필요한 padding 처리
|
74 |
audio_prompts = audio_prompts[:, :audio_len*2]
|
|
|
289 |
audio_video_path = output_path
|
290 |
|
291 |
# limit=config.frame_num 대신 오디오 전체를 쓰도록 수정
|
|
|
292 |
test_data = image_audio_to_tensor(
|
293 |
self.face_det,
|
294 |
self.feature_extractor,
|