mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 01:43:53 +08:00
update:优化空asr语音
This commit is contained in:
@@ -168,6 +168,7 @@ class ASRProvider(ASRProviderBase):
|
||||
if (
|
||||
"payload_msg" in result
|
||||
and result["payload_msg"]["code"] != self.success_code
|
||||
and result["payload_msg"]["code"] != 1013 # 忽略无有效语音的错误
|
||||
):
|
||||
logger.bind(tag=TAG).error(f"ASR error: {result}")
|
||||
return None
|
||||
@@ -203,6 +204,9 @@ class ASRProvider(ASRProviderBase):
|
||||
if len(result["payload_msg"]["result"]) > 0:
|
||||
return result["payload_msg"]["result"][0]["text"]
|
||||
return None
|
||||
elif "payload_msg" in result and result["payload_msg"]["code"] == 1013:
|
||||
# 无有效语音,返回空字符串
|
||||
return ""
|
||||
else:
|
||||
logger.bind(tag=TAG).error(f"ASR error: {result}")
|
||||
return None
|
||||
|
||||
@@ -157,6 +157,11 @@ class ASRProvider(ASRProviderBase):
|
||||
|
||||
if "payload_msg" in result:
|
||||
payload = result["payload_msg"]
|
||||
# 检查是否是错误码1013(无有效语音)
|
||||
if "code" in payload and payload["code"] == 1013:
|
||||
# 静默处理,不记录错误日志
|
||||
continue
|
||||
|
||||
if "result" in payload:
|
||||
utterances = payload["result"].get("utterances", [])
|
||||
# 检查duration和空文本的情况
|
||||
|
||||
Reference in New Issue
Block a user