mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
fix(core): 修复语音识别结果异常的问题
- 在 ASRProvider 的 receive 方法中添加正则匹配,过滤掉不必要的前缀信息- 优化了语音识别结果的处理流程,提高了结果的准确性和可用性
This commit is contained in:
parent
55d66e2cc7
commit
5790ec837e
1 changed files with 4 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import re
|
||||
from typing import Optional, Tuple, List
|
||||
import opuslib_next
|
||||
from core.providers.asr.base import ASRProviderBase
|
||||
|
|
@ -136,6 +137,9 @@ class ASRProvider(ASRProviderBase):
|
|||
|
||||
# Get the result from the receive task
|
||||
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)
|
||||
|
||||
except websockets.exceptions.ConnectionClosed as e:
|
||||
|
|
|
|||
Loading…
Reference in a new issue