👌 perf: 当响应头不为audio/wav时抛出报错

This commit is contained in:
Soulter
2025-02-08 21:11:32 +08:00
parent 5fa1979a46
commit 6bae9dc9ed

View File

@@ -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}")