From adba4c2488a70dedc2136ead469af54cceae12de Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Fri, 7 Mar 2025 18:23:41 +0800 Subject: [PATCH] =?UTF-8?q?update:ACGNTTS=E6=B5=8B=E8=AF=95=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/config.yaml | 2 +- main/xiaozhi-server/core/providers/tts/ttson.py | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index f998a2018..a7c5357ba 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -339,7 +339,7 @@ TTS: volume_change_dB: 0 to_lang: ZH url: https://u95167-bd74-2aef8085.westx.seetacloud.com:8443/flashsummary/tts?token= - format: wav + format: mp3 output_file: tmp/ emotion: 1 OpenAITTS: diff --git a/main/xiaozhi-server/core/providers/tts/ttson.py b/main/xiaozhi-server/core/providers/tts/ttson.py index b9c4e3b53..e56fd02df 100644 --- a/main/xiaozhi-server/core/providers/tts/ttson.py +++ b/main/xiaozhi-server/core/providers/tts/ttson.py @@ -6,9 +6,6 @@ import shutil from datetime import datetime from core.providers.tts.base import TTSProviderBase -import http.client -import urllib.parse - class TTSProvider(TTSProviderBase): def __init__(self, config, delete_audio_file): @@ -22,7 +19,7 @@ class TTSProvider(TTSProviderBase): self.stream = config.get("stream", False) self.output_file = config.get("output_file") self.pitch_factor = config.get("pitch_factor", 0) - self.format = config.get("format", "wav") + self.format = config.get("format", "mp3") self.emotion = config.get("emotion", 1) self.header = { "Content-Type": "application/json" @@ -34,7 +31,6 @@ class TTSProvider(TTSProviderBase): async def text_to_speak(self, text, output_file): url = f'{self.url}{self.token}' result = "firefly" - print(url) payload = json.dumps({ "to_lang": self.to_lang, "text": text, @@ -47,13 +43,8 @@ class TTSProvider(TTSProviderBase): "token": self.token }) - print("请求编成") resp = requests.request("POST", url, data=payload) - print(resp.status_code) - print("请求开始") - print("完整请求参数:", payload) if resp.status_code != 200: - print(f"Error: {resp.status_code}") return None resp_json = resp.json() try: @@ -61,17 +52,13 @@ class TTSProvider(TTSProviderBase): resp_json[ 'port']) + '/flashsummary/retrieveFileData?stream=True&token=' + self.token + '&voice_audio_path=' + \ resp_json['voice_path'] - print("result已写入") except Exception as e: print("error:", e) audio_content = requests.get(result) with open(output_file, "wb") as f: f.write(audio_content.content) - print("音频写入成功") return True voice_path = resp_json.get("voice_path") des_path = output_file shutil.move(voice_path, des_path) - print(voice_path, "value") - print("API响应原始内容:", resp.text) \ No newline at end of file