fishspeech key选配

This commit is contained in:
aileenfun 2025-03-15 21:44:19 +08:00
parent 85956c8928
commit 5c3486d98d
2 changed files with 7 additions and 9 deletions

View file

@ -451,7 +451,7 @@ class ConnectionHandler:
opus_datas, text_index, tts_file = [], 0, None
try:
self.logger.bind(tag=TAG).debug("正在处理TTS任务...")
tts_file, text, text_index = future.result(timeout=10)
tts_file, text, text_index = future.result(timeout=20)
if text is None or len(text) <= 0:
self.logger.bind(tag=TAG).error(f"TTS出错:{text_index}: tts text is empty")
elif tts_file is None:

View file

@ -92,9 +92,8 @@ class TTSProvider(TTSProviderBase):
self.channels = config.get("channels", 1)
self.rate = config.get("rate", 44100)
self.api_key = config.get("api_key", "YOUR_API_KEY")
have_key = check_model_key("FishSpeech TTS", self.api_key)
if not have_key:
return
self.have_key = check_model_key("FishSpeech TTS", self.api_key)
self.normalize = config.get("normalize", True)
self.max_new_tokens = config.get("max_new_tokens", 1024)
self.chunk_length = config.get("chunk_length", 200)
@ -136,14 +135,13 @@ class TTSProvider(TTSProviderBase):
}
pydantic_data = ServeTTSRequest(**data)
headers={"Content-Type": "application/msgpack"}
if self.have_key:
headers["Authorization"] = f"Bearer {self.api_key}"
response = requests.post(
self.api_url,
data=ormsgpack.packb(pydantic_data, option=ormsgpack.OPT_SERIALIZE_PYDANTIC),
headers={
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/msgpack",
},
headers=headers
)
if response.status_code == 200: