mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-30 13:43:56 +08:00
update:优化公共方法
This commit is contained in:
@@ -22,12 +22,6 @@ class TTSProvider(TTSProviderBase):
|
||||
self.host = "api.siliconflow.cn"
|
||||
self.api_url = f"https://{self.host}/v1/audio/speech"
|
||||
|
||||
def generate_filename(self, extension=".wav"):
|
||||
return os.path.join(
|
||||
self.output_file,
|
||||
f"tts-{datetime.now().date()}@{uuid.uuid4().hex}{extension}",
|
||||
)
|
||||
|
||||
async def text_to_speak(self, text, output_file):
|
||||
request_json = {
|
||||
"model": self.model,
|
||||
@@ -47,4 +41,4 @@ class TTSProvider(TTSProviderBase):
|
||||
file_to_save = open(output_file, "wb")
|
||||
file_to_save.write(data)
|
||||
except Exception as e:
|
||||
raise Exception(f"{__name__} error: {e}")
|
||||
raise Exception(f"{__name__} error: {e}")
|
||||
|
||||
Reference in New Issue
Block a user