Skip to content

Commit aed1a7c

Browse files
committed
🐛 fix: 修复请求参数序列化,更新为使用request.dict();简化请求参数模型
1 parent 72859ba commit aed1a7c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

nonebot_plugin_fishspeech_tts/fish_audio_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ async def generate_tts(self, request: ServeTTSRequest) -> bytes:
151151
self.url,
152152
headers=self.headers,
153153
content=ormsgpack.packb(
154-
request, option=ormsgpack.OPT_SERIALIZE_PYDANTIC
154+
request.dict(),
155155
),
156156
timeout=60,
157157
) as resp,

nonebot_plugin_fishspeech_tts/fish_speech_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ async def generate_tts(self, request: ServeTTSRequest) -> bytes:
8989
self.api_url,
9090
headers=self.headers,
9191
content=ormsgpack.packb(
92-
request, option=ormsgpack.OPT_SERIALIZE_PYDANTIC
93-
), # type: ignore
92+
request.dict(),
93+
),
9494
timeout=120,
9595
)
9696
return response.content

nonebot_plugin_fishspeech_tts/request_params.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import enum
2-
from typing import Annotated, Literal
2+
from typing import Literal
33

44
from pydantic import BaseModel
5-
from pydantic.fields import Field
65

76

87
class ChunkLength(enum.Enum):
@@ -25,8 +24,8 @@ class ServeReferenceAudio(BaseModel):
2524
class ServeTTSRequest(BaseModel):
2625
"""TTS请求"""
2726

28-
text: str = "" # 待合成文本
29-
chunk_length: Annotated[int, Field(ge=100, le=300, strict=True)] = 200 # 分片长度
27+
text: str # 待合成文本
28+
chunk_length: int = 200 # 分片长度
3029
format: Literal["wav", "pcm", "mp3"] = "mp3" # 音频格式
3130
mp3_bitrate: Literal[64, 128, 192] = 64 # mp3比特率
3231
references: list[ServeReferenceAudio] = [] # 参考音频

0 commit comments

Comments
 (0)