mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
Merge branch 'develop' into stream
This commit is contained in:
commit
b98e5898d6
3 changed files with 23 additions and 22 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -174,3 +174,4 @@ main/xiaozhi-server/mysql
|
|||
uploadfile
|
||||
*.json
|
||||
.vscode
|
||||
deploy/
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ class ASRProvider(ASRProviderBase):
|
|||
if self.ws:
|
||||
logger.bind(tag=TAG).info(f"Checking WebSocket connection health: {self.ws_url}")
|
||||
# 发送ping并设置200ms超时
|
||||
#await asyncio.wait_for(self.ws.ping(), timeout=0.2)
|
||||
await asyncio.wait_for(self.ws.ping(), timeout=0.2)
|
||||
logger.bind(tag=TAG).debug("WebSocket ping successful")
|
||||
return True
|
||||
logger.bind(tag=TAG).warning("WebSocket connection not open")
|
||||
|
|
@ -345,16 +345,16 @@ class ASRProvider(ASRProviderBase):
|
|||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to ping WebSocket: {e}")
|
||||
await self.stop_ws_connection()
|
||||
|
||||
try:
|
||||
logger.bind(tag=TAG).info(f"Connecting to {self.ws_url}")
|
||||
headers = {"Authorization": f"Bearer {self.api_key}"}
|
||||
self.ws = await websockets.connect(self.ws_url, additional_headers=headers)
|
||||
logger.bind(tag=TAG).info("WebSocket connection established.")
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to connect to WebSocket: {e}")
|
||||
self.ws = None
|
||||
raise
|
||||
if self.ws is None:
|
||||
try:
|
||||
logger.bind(tag=TAG).info(f"Connecting to {self.ws_url}")
|
||||
headers = {"Authorization": f"Bearer {self.api_key}"}
|
||||
self.ws = await websockets.connect(self.ws_url, additional_headers=headers)
|
||||
logger.bind(tag=TAG).info("WebSocket connection established.")
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to connect to WebSocket: {e}")
|
||||
self.ws = None
|
||||
raise
|
||||
|
||||
async def stop_ws_connection(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ class TTSProvider(TTSProviderBase):
|
|||
if self.ws:
|
||||
logger.bind(tag=TAG).info(f"Checking WebSocket connection health: {self.ws_url}")
|
||||
# 发送ping并设置200ms超时
|
||||
#await asyncio.wait_for(self.ws.ping(), timeout=0.2)
|
||||
await asyncio.wait_for(self.ws.ping(), timeout=0.2)
|
||||
logger.bind(tag=TAG).debug("WebSocket ping successful")
|
||||
return True
|
||||
logger.bind(tag=TAG).warning("WebSocket connection not open")
|
||||
|
|
@ -315,16 +315,16 @@ class TTSProvider(TTSProviderBase):
|
|||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to ping WebSocket: {e}")
|
||||
await self.stop_ws_connection()
|
||||
|
||||
try:
|
||||
logger.bind(tag=TAG).info(f"Connecting to {self.ws_url}")
|
||||
headers = {"Authorization": f"Bearer {self.api_key}"}
|
||||
self.ws = await websockets.connect(self.ws_url, additional_headers=headers)
|
||||
logger.bind(tag=TAG).info("WebSocket connection established.")
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to connect to WebSocket: {e}")
|
||||
self.ws = None
|
||||
raise
|
||||
if self.ws is None:
|
||||
try:
|
||||
logger.bind(tag=TAG).info(f"Connecting to {self.ws_url}")
|
||||
headers = {"Authorization": f"Bearer {self.api_key}"}
|
||||
self.ws = await websockets.connect(self.ws_url, additional_headers=headers)
|
||||
logger.bind(tag=TAG).info("WebSocket connection established.")
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to connect to WebSocket: {e}")
|
||||
self.ws = None
|
||||
raise
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue