Spaces:
Running on Zero
Running on Zero
app.py
CHANGED
|
@@ -289,8 +289,8 @@ def extract_voice_clone_prompt(ref_audio,ref_text,use_xvector_only):
|
|
| 289 |
uxo = use_xvector_only
|
| 290 |
|
| 291 |
# 如果没有提供参考文本且未开启仅 x-vector 模式,尝试使用 Whisper 自动识别
|
| 292 |
-
if not
|
| 293 |
-
whisper_size = "
|
| 294 |
logger.info(f"未提供参考文本,开始使用 Whisper 自动识别。模型: {whisper_size}")
|
| 295 |
try:
|
| 296 |
whisper_model = load_whisper_model(whisper_size)
|
|
@@ -306,6 +306,7 @@ def extract_voice_clone_prompt(ref_audio,ref_text,use_xvector_only):
|
|
| 306 |
result = whisper_model.transcribe(whisper_audio)
|
| 307 |
r_text = result["text"].strip()
|
| 308 |
logger.info(f"Whisper 识别成功:{r_text}")
|
|
|
|
| 309 |
except Exception as e:
|
| 310 |
logger.error(f"Whisper 识别失败: {str(e)}", exc_info=True)
|
| 311 |
return None, f"错误:语音识别失败且未提供参考文本。{str(e)}"
|
|
|
|
| 289 |
uxo = use_xvector_only
|
| 290 |
|
| 291 |
# 如果没有提供参考文本且未开启仅 x-vector 模式,尝试使用 Whisper 自动识别
|
| 292 |
+
if not r_text or (isinstance(r_text, str) and not r_text.strip()):
|
| 293 |
+
whisper_size = "base"
|
| 294 |
logger.info(f"未提供参考文本,开始使用 Whisper 自动识别。模型: {whisper_size}")
|
| 295 |
try:
|
| 296 |
whisper_model = load_whisper_model(whisper_size)
|
|
|
|
| 306 |
result = whisper_model.transcribe(whisper_audio)
|
| 307 |
r_text = result["text"].strip()
|
| 308 |
logger.info(f"Whisper 识别成功:{r_text}")
|
| 309 |
+
uxo = False
|
| 310 |
except Exception as e:
|
| 311 |
logger.error(f"Whisper 识别失败: {str(e)}", exc_info=True)
|
| 312 |
return None, f"错误:语音识别失败且未提供参考文本。{str(e)}"
|