From 6bae9dc9edd71c92a6101415066cc65c8a38a26a Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 8 Feb 2025 21:11:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20perf:=20=E5=BD=93=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=A4=B4=E4=B8=8D=E4=B8=BAaudio/wav=E6=97=B6=E6=8A=9B?= =?UTF-8?q?=E5=87=BA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/provider/sources/fishaudio_tts_api_source.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/astrbot/core/provider/sources/fishaudio_tts_api_source.py b/astrbot/core/provider/sources/fishaudio_tts_api_source.py index 3f07af9c9..84b4b677e 100644 --- a/astrbot/core/provider/sources/fishaudio_tts_api_source.py +++ b/astrbot/core/provider/sources/fishaudio_tts_api_source.py @@ -96,7 +96,10 @@ class ProviderFishAudioTTSAPI(TTSProvider): headers=self.headers, content=ormsgpack.packb(request, option=ormsgpack.OPT_SERIALIZE_PYDANTIC), ) as response: - with open(path, "wb") as f: - async for chunk in response.aiter_bytes(): - f.write(chunk) - return path + if response.headers["content-type"] == "audio/wav": + with open(path, "wb") as f: + async for chunk in response.aiter_bytes(): + f.write(chunk) + return path + text = await response.aread() + raise Exception(f"Fish Audio API请求失败: {text}")