From cba153be79d00034b02134916873221a4aac488f Mon Sep 17 00:00:00 2001 From: journey-ad Date: Thu, 13 Mar 2025 16:06:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=AE=9A=E4=B9=89tts=E9=9F=B3?= =?UTF-8?q?=E9=A2=91=E6=A0=BC=E5=BC=8F=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/config.yaml | 15 ++++++++------- main/xiaozhi-server/core/providers/tts/custom.py | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index d536eafc3..6f93e9c10 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -416,17 +416,18 @@ TTS: output_file: tmp/ CustomTTS: # 自定义的TTS接口服务,请求参数可自定义 - # 要求接口使用GET方式请求,返回wav格式音频 + # 要求接口使用GET方式请求,并返回音频文件 type: custom url: "http://127.0.0.1:9880/tts" params: # 自定义请求参数 - text: "{prompt_text}" # {prompt_text}会被替换为实际的提示词内容 - speaker: jok老师 - speed: 1 - foo: bar - testabc: 123456 + # text: "{prompt_text}" # {prompt_text}会被替换为实际的提示词内容 + # speaker: jok老师 + # speed: 1 + # foo: bar + # testabc: 123456 headers: # 自定义请求头 - Authorization: Bearer xxxx + # Authorization: Bearer xxxx + format: wav # 接口返回的音频格式 output_file: tmp/ # 模块测试配置 module_test: diff --git a/main/xiaozhi-server/core/providers/tts/custom.py b/main/xiaozhi-server/core/providers/tts/custom.py index 6334f3167..d5447878f 100644 --- a/main/xiaozhi-server/core/providers/tts/custom.py +++ b/main/xiaozhi-server/core/providers/tts/custom.py @@ -14,10 +14,11 @@ class TTSProvider(TTSProviderBase): self.url = config.get("url") self.headers = config.get("headers", {}) self.params = config.get("params") + self.format = config.get("format", "wav") self.output_file = config.get("output_file", "tmp/") - def generate_filename(self, extension=".wav"): - return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}{extension}") + def generate_filename(self): + return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}.{self.format}") async def text_to_speak(self, text, output_file): request_params = {}