mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
fishspeech key选配
This commit is contained in:
parent
85956c8928
commit
5c3486d98d
2 changed files with 7 additions and 9 deletions
|
|
@ -451,7 +451,7 @@ class ConnectionHandler:
|
||||||
opus_datas, text_index, tts_file = [], 0, None
|
opus_datas, text_index, tts_file = [], 0, None
|
||||||
try:
|
try:
|
||||||
self.logger.bind(tag=TAG).debug("正在处理TTS任务...")
|
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:
|
if text is None or len(text) <= 0:
|
||||||
self.logger.bind(tag=TAG).error(f"TTS出错:{text_index}: tts text is empty")
|
self.logger.bind(tag=TAG).error(f"TTS出错:{text_index}: tts text is empty")
|
||||||
elif tts_file is None:
|
elif tts_file is None:
|
||||||
|
|
|
||||||
|
|
@ -92,9 +92,8 @@ class TTSProvider(TTSProviderBase):
|
||||||
self.channels = config.get("channels", 1)
|
self.channels = config.get("channels", 1)
|
||||||
self.rate = config.get("rate", 44100)
|
self.rate = config.get("rate", 44100)
|
||||||
self.api_key = config.get("api_key", "YOUR_API_KEY")
|
self.api_key = config.get("api_key", "YOUR_API_KEY")
|
||||||
have_key = check_model_key("FishSpeech TTS", self.api_key)
|
self.have_key = check_model_key("FishSpeech TTS", self.api_key)
|
||||||
if not have_key:
|
|
||||||
return
|
|
||||||
self.normalize = config.get("normalize", True)
|
self.normalize = config.get("normalize", True)
|
||||||
self.max_new_tokens = config.get("max_new_tokens", 1024)
|
self.max_new_tokens = config.get("max_new_tokens", 1024)
|
||||||
self.chunk_length = config.get("chunk_length", 200)
|
self.chunk_length = config.get("chunk_length", 200)
|
||||||
|
|
@ -136,14 +135,13 @@ class TTSProvider(TTSProviderBase):
|
||||||
}
|
}
|
||||||
|
|
||||||
pydantic_data = ServeTTSRequest(**data)
|
pydantic_data = ServeTTSRequest(**data)
|
||||||
|
headers={"Content-Type": "application/msgpack"}
|
||||||
|
if self.have_key:
|
||||||
|
headers["Authorization"] = f"Bearer {self.api_key}"
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
self.api_url,
|
self.api_url,
|
||||||
data=ormsgpack.packb(pydantic_data, option=ormsgpack.OPT_SERIALIZE_PYDANTIC),
|
data=ormsgpack.packb(pydantic_data, option=ormsgpack.OPT_SERIALIZE_PYDANTIC),
|
||||||
headers={
|
headers=headers
|
||||||
"Authorization": f"Bearer {self.api_key}",
|
|
||||||
"Content-Type": "application/msgpack",
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue