mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
撤回 9685277 cosmetic 改写
9685277 误判 silent success bug,实为 cosmetic + error 文案详细化;旧代码已正确处理 5 次空 audio_bytes 场景。base.py 不在 PR #3442 scope,留待另起小改。
This commit is contained in:
parent
968527752b
commit
e77c72cf02
1 changed files with 4 additions and 12 deletions
|
|
@ -130,7 +130,6 @@ class TTSProviderBase(ABC):
|
|||
if self._correct_words_pattern:
|
||||
text = self._correct_words_pattern.sub(lambda m: self.correct_words[m.group(0)], text)
|
||||
max_repeat_time = 5
|
||||
success = False
|
||||
if self.delete_audio_file:
|
||||
# 需要删除文件的直接转为音频数据
|
||||
while max_repeat_time > 0:
|
||||
|
|
@ -147,7 +146,6 @@ class TTSProviderBase(ABC):
|
|||
sample_rate=self.conn.sample_rate,
|
||||
opus_encoder=self.opus_encoder,
|
||||
)
|
||||
success = True
|
||||
break
|
||||
else:
|
||||
max_repeat_time -= 1
|
||||
|
|
@ -156,16 +154,13 @@ class TTSProviderBase(ABC):
|
|||
f"语音生成失败{5 - max_repeat_time + 1}次: {original_text},错误: {e}"
|
||||
)
|
||||
max_repeat_time -= 1
|
||||
if success:
|
||||
if max_repeat_time > 0:
|
||||
logger.bind(tag=TAG).info(
|
||||
f"语音生成成功: {original_text},重试{5 - max_repeat_time}次"
|
||||
)
|
||||
else:
|
||||
# 区分异常失败和"无异常但 audio_bytes 空"两种情况:
|
||||
# 后者常见于网络到上游 ws 服务不通、stream() 内没收到 audio 帧
|
||||
logger.bind(tag=TAG).error(
|
||||
f"语音生成失败: {original_text},重试 {5} 次未产出音频,"
|
||||
"请检查网络或上游 TTS 服务"
|
||||
f"语音生成失败: {original_text},请检查网络或服务是否正常"
|
||||
)
|
||||
return None
|
||||
else:
|
||||
|
|
@ -204,7 +199,6 @@ class TTSProviderBase(ABC):
|
|||
if self._correct_words_pattern:
|
||||
text = self._correct_words_pattern.sub(lambda m: self.correct_words[m.group(0)], text)
|
||||
max_repeat_time = 5
|
||||
success = False
|
||||
if self.delete_audio_file:
|
||||
# 需要删除文件的直接转为音频数据
|
||||
while max_repeat_time > 0:
|
||||
|
|
@ -219,7 +213,6 @@ class TTSProviderBase(ABC):
|
|||
callback=lambda data: audio_datas.append(data),
|
||||
sample_rate=self.conn.sample_rate,
|
||||
)
|
||||
success = True
|
||||
return audio_datas
|
||||
else:
|
||||
max_repeat_time -= 1
|
||||
|
|
@ -228,14 +221,13 @@ class TTSProviderBase(ABC):
|
|||
f"语音生成失败{5 - max_repeat_time + 1}次: {original_text},错误: {e}"
|
||||
)
|
||||
max_repeat_time -= 1
|
||||
if success:
|
||||
if max_repeat_time > 0:
|
||||
logger.bind(tag=TAG).info(
|
||||
f"语音生成成功: {original_text},重试{5 - max_repeat_time}次"
|
||||
)
|
||||
else:
|
||||
logger.bind(tag=TAG).error(
|
||||
f"语音生成失败: {original_text},重试 {5} 次未产出音频,"
|
||||
"请检查网络或上游 TTS 服务"
|
||||
f"语音生成失败: {original_text},请检查网络或服务是否正常"
|
||||
)
|
||||
return None
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue