mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 01:23:55 +08:00
Merge pull request #2940 from xinnan-tech/py_fix_stream_asr
fix: 讯飞自动设备适应,阿里云等待时机过短
This commit is contained in:
@@ -144,7 +144,7 @@ class ASRProvider(ASRProviderBase):
|
|||||||
await self.asr_ws.send(pcm_frame)
|
await self.asr_ws.send(pcm_frame)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.bind(tag=TAG).warning(f"发送音频失败: {str(e)}")
|
logger.bind(tag=TAG).warning(f"发送音频失败: {str(e)}")
|
||||||
await self._cleanup(conn)
|
await self._cleanup()
|
||||||
|
|
||||||
async def _start_recognition(self, conn):
|
async def _start_recognition(self, conn):
|
||||||
"""开始识别会话"""
|
"""开始识别会话"""
|
||||||
@@ -199,7 +199,7 @@ class ASRProvider(ASRProviderBase):
|
|||||||
# 获取当前连接的音频数据
|
# 获取当前连接的音频数据
|
||||||
audio_data = conn.asr_audio
|
audio_data = conn.asr_audio
|
||||||
try:
|
try:
|
||||||
response = await asyncio.wait_for(self.asr_ws.recv(), timeout=1.0)
|
response = await self.asr_ws.recv()
|
||||||
result = json.loads(response)
|
result = json.loads(response)
|
||||||
|
|
||||||
header = result.get("header", {})
|
header = result.get("header", {})
|
||||||
@@ -332,7 +332,7 @@ class ASRProvider(ASRProviderBase):
|
|||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
"""关闭资源"""
|
"""关闭资源"""
|
||||||
await self._cleanup(None)
|
await self._cleanup()
|
||||||
if hasattr(self, 'decoder') and self.decoder is not None:
|
if hasattr(self, 'decoder') and self.decoder is not None:
|
||||||
try:
|
try:
|
||||||
del self.decoder
|
del self.decoder
|
||||||
|
|||||||
@@ -226,9 +226,8 @@ class ASRProvider(ASRProviderBase):
|
|||||||
self.text += w
|
self.text += w
|
||||||
|
|
||||||
if status == 2:
|
if status == 2:
|
||||||
if conn.client_listen_mode == "manual":
|
logger.bind(tag=TAG).debug("收到最终识别结果,触发处理")
|
||||||
logger.bind(tag=TAG).debug("收到最终识别结果,触发处理")
|
await self.handle_voice_stop(conn, conn.asr_audio)
|
||||||
await self.handle_voice_stop(conn, conn.asr_audio)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
|||||||
Reference in New Issue
Block a user