mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
update:ACGNTTS测试完成
This commit is contained in:
parent
b4ae211658
commit
adba4c2488
2 changed files with 2 additions and 15 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
Loading…
Reference in a new issue