tts未及时响应,多次尝试逻辑修复。(删除空文件,达成While的条件)
This commit is contained in:
wnk
2025-04-26 07:04:07 +08:00
parent 7d585615a9
commit 9a5aaea8ca
@@ -29,16 +29,20 @@ class TTSProviderBase(ABC):
try:
asyncio.run(self.text_to_speak(text, tmp_file))
except Exception as e:
logger.bind(tag=TAG).error(f"语音生成失败: {text},错误: {e}")
if not os.path.exists(tmp_file):
logger.bind(tag=TAG).warning(f"语音生成失败{5 - max_repeat_time + 1}: {text},错误: {e}")
# 未执行成功,删除文件
if os.path.exists(tmp_file):
os.remove(tmp_file)
max_repeat_time -= 1
if max_repeat_time > 0:
logger.bind(tag=TAG).error(f"再试{max_repeat_time}")
if max_repeat_time > 0:
logger.bind(tag=TAG).info(
f"语音生成成功: {text}:{tmp_file},重试{5 - max_repeat_time}"
)
else:
logger.bind(tag=TAG).error(
f"语音生成失败: {text},请检查网络或服务是否正常"
)
return tmp_file
except Exception as e: