fix(core): 修复语音识别结果异常的问题

- 在 ASRProvider 的 receive 方法中添加正则匹配,过滤掉不必要的前缀信息- 优化了语音识别结果的处理流程,提高了结果的准确性和可用性
This commit is contained in:
whosmyqueen 2025-04-28 17:31:22 +08:00
parent 55d66e2cc7
commit 5790ec837e

View file

@ -1,3 +1,4 @@
import re
from typing import Optional, Tuple, List from typing import Optional, Tuple, List
import opuslib_next import opuslib_next
from core.providers.asr.base import ASRProviderBase from core.providers.asr.base import ASRProviderBase
@ -136,6 +137,9 @@ class ASRProvider(ASRProviderBase):
# Get the result from the receive task # Get the result from the receive task
result = receive_task.result() result = receive_task.result()
match = re.match(r'<\|(.*?)\|><\|(.*?)\|><\|(.*?)\|>(.*)', result)
if match:
result = match.group(4).strip()
return result, None # Return the recognized text and timestamp (if any) return result, None # Return the recognized text and timestamp (if any)
except websockets.exceptions.ConnectionClosed as e: except websockets.exceptions.ConnectionClosed as e: