mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-26 04:39:53 +01:00
Merge pull request #3320 from henson957/fix/siliconflow-http-timeout
fix(tts): SiliconFlow provider 增加请求超时与 HTTP 错误处理
This commit is contained in:
commit
17560a7d29
1 changed files with 6 additions and 1 deletions
|
|
@ -39,8 +39,13 @@ class TTSProvider(TTSProviderBase):
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
response = requests.request(
|
response = requests.request(
|
||||||
"POST", self.api_url, json=request_json, headers=headers
|
"POST", self.api_url, json=request_json, headers=headers,
|
||||||
|
timeout=self.tts_timeout,
|
||||||
)
|
)
|
||||||
|
if response.status_code != 200:
|
||||||
|
raise Exception(
|
||||||
|
f"{__name__} HTTP {response.status_code}: {response.text[:200]}"
|
||||||
|
)
|
||||||
data = response.content
|
data = response.content
|
||||||
if output_file:
|
if output_file:
|
||||||
with open(output_file, "wb") as file_to_save:
|
with open(output_file, "wb") as file_to_save:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue