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 = {}