From d03d0d0982df2fef24873a523cbb731e9fa5006f Mon Sep 17 00:00:00 2001 From: henson957 <202114553+henson957@users.noreply.github.com> Date: Wed, 12 Aug 2026 17:37:04 +0800 Subject: [PATCH 1/2] fix(tts): add HTTP timeout and error handling to SiliconFlow provider - requests.request() had no timeout: when the SiliconFlow API slows down, the request hangs forever and the device produces no audio intermittently - non-200 responses (rate limit, error page) were written to disk as audio; now the status code is checked and an exception is raised with the body --- main/xiaozhi-server/core/providers/tts/siliconflow.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main/xiaozhi-server/core/providers/tts/siliconflow.py b/main/xiaozhi-server/core/providers/tts/siliconflow.py index b5c618ec1..feefb9ae7 100644 --- a/main/xiaozhi-server/core/providers/tts/siliconflow.py +++ b/main/xiaozhi-server/core/providers/tts/siliconflow.py @@ -39,8 +39,13 @@ class TTSProvider(TTSProviderBase): } try: response = requests.request( - "POST", self.api_url, json=request_json, headers=headers + "POST", self.api_url, json=request_json, headers=headers, + timeout=15, ) + if response.status_code != 200: + raise Exception( + f"{__name__} HTTP {response.status_code}: {response.text[:200]}" + ) data = response.content if output_file: with open(output_file, "wb") as file_to_save: From db7db3de67de18f899a5c637503f8a2f0202b61d Mon Sep 17 00:00:00 2001 From: henson957 Date: Thu, 13 Aug 2026 13:28:17 +0800 Subject: [PATCH 2/2] fix(tts): reuse base tts_timeout config instead of hardcoded 15 --- main/xiaozhi-server/core/providers/tts/siliconflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/xiaozhi-server/core/providers/tts/siliconflow.py b/main/xiaozhi-server/core/providers/tts/siliconflow.py index feefb9ae7..584c9654e 100644 --- a/main/xiaozhi-server/core/providers/tts/siliconflow.py +++ b/main/xiaozhi-server/core/providers/tts/siliconflow.py @@ -40,7 +40,7 @@ class TTSProvider(TTSProviderBase): try: response = requests.request( "POST", self.api_url, json=request_json, headers=headers, - timeout=15, + timeout=self.tts_timeout, ) if response.status_code != 200: raise Exception(