mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
increase interval
This commit is contained in:
parent
1b890a619e
commit
058bf11052
2 changed files with 10 additions and 8 deletions
|
|
@ -130,9 +130,9 @@ class ASRProvider(ASRProviderBase):
|
||||||
await self._send_audio_chunk(b"".join(pcm_frame))
|
await self._send_audio_chunk(b"".join(pcm_frame))
|
||||||
conn.asr_audio.clear()
|
conn.asr_audio.clear()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await self.stop_ws_connection()
|
|
||||||
logger.bind(tag=TAG).error(f"Error sending audio data: {e}", exc_info=True)
|
logger.bind(tag=TAG).error(f"Error sending audio data: {e}", exc_info=True)
|
||||||
|
await self.stop_ws_connection()
|
||||||
|
|
||||||
# Finish the session if end-of-utterance is detected.
|
# Finish the session if end-of-utterance is detected.
|
||||||
if self.ws and self.session_started and self.is_eou(conn, self.text) :
|
if self.ws and self.session_started and self.is_eou(conn, self.text) :
|
||||||
logger.bind(tag=TAG).info(f"Finishing session: {self.current_session_id}")
|
logger.bind(tag=TAG).info(f"Finishing session: {self.current_session_id}")
|
||||||
|
|
@ -340,12 +340,13 @@ class ASRProvider(ASRProviderBase):
|
||||||
logger.bind(tag=TAG).info(f"Connecting to {self.ws_url}")
|
logger.bind(tag=TAG).info(f"Connecting to {self.ws_url}")
|
||||||
headers = {"Authorization": f"Bearer {self.api_key}"}
|
headers = {"Authorization": f"Bearer {self.api_key}"}
|
||||||
# 使用内置的 ping/pong 机制来维持连接和检查健康状况
|
# 使用内置的 ping/pong 机制来维持连接和检查健康状况
|
||||||
# 每 20 秒发送一次 ping,等待 10 秒超时
|
# 每 60 秒发送一次 ping,等待 30 秒超时
|
||||||
self.ws = await websockets.connect(
|
self.ws = await websockets.connect(
|
||||||
self.ws_url,
|
self.ws_url,
|
||||||
additional_headers=headers,
|
additional_headers=headers,
|
||||||
ping_interval=20,
|
ping_interval=60, # Increased from 20
|
||||||
ping_timeout=10
|
ping_timeout=30, # Increased from 10
|
||||||
|
close_timeout=10 # Added for graceful close
|
||||||
)
|
)
|
||||||
logger.bind(tag=TAG).info("WebSocket connection established.")
|
logger.bind(tag=TAG).info("WebSocket connection established.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -312,12 +312,13 @@ class TTSProvider(TTSProviderBase):
|
||||||
logger.bind(tag=TAG).info(f"Connecting to {self.ws_url}")
|
logger.bind(tag=TAG).info(f"Connecting to {self.ws_url}")
|
||||||
headers = {"Authorization": f"Bearer {self.api_key}"}
|
headers = {"Authorization": f"Bearer {self.api_key}"}
|
||||||
# 使用内置的 ping/pong 机制来维持连接和检查健康状况
|
# 使用内置的 ping/pong 机制来维持连接和检查健康状况
|
||||||
# 每 20 秒发送一次 ping,等待 10 秒超时
|
# 每 60 秒发送一次 ping,等待 30 秒超时
|
||||||
self.ws = await websockets.connect(
|
self.ws = await websockets.connect(
|
||||||
self.ws_url,
|
self.ws_url,
|
||||||
additional_headers=headers,
|
additional_headers=headers,
|
||||||
ping_interval=20,
|
ping_interval=60,
|
||||||
ping_timeout=10
|
ping_timeout=30,
|
||||||
|
close_timeout=10
|
||||||
)
|
)
|
||||||
logger.bind(tag=TAG).info("WebSocket connection established.")
|
logger.bind(tag=TAG).info("WebSocket connection established.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue