mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
feat: 自定义tts音频格式兼容
This commit is contained in:
parent
58f26077bc
commit
cba153be79
2 changed files with 11 additions and 9 deletions
|
|
@ -416,17 +416,18 @@ TTS:
|
||||||
output_file: tmp/
|
output_file: tmp/
|
||||||
CustomTTS:
|
CustomTTS:
|
||||||
# 自定义的TTS接口服务,请求参数可自定义
|
# 自定义的TTS接口服务,请求参数可自定义
|
||||||
# 要求接口使用GET方式请求,返回wav格式音频
|
# 要求接口使用GET方式请求,并返回音频文件
|
||||||
type: custom
|
type: custom
|
||||||
url: "http://127.0.0.1:9880/tts"
|
url: "http://127.0.0.1:9880/tts"
|
||||||
params: # 自定义请求参数
|
params: # 自定义请求参数
|
||||||
text: "{prompt_text}" # {prompt_text}会被替换为实际的提示词内容
|
# text: "{prompt_text}" # {prompt_text}会被替换为实际的提示词内容
|
||||||
speaker: jok老师
|
# speaker: jok老师
|
||||||
speed: 1
|
# speed: 1
|
||||||
foo: bar
|
# foo: bar
|
||||||
testabc: 123456
|
# testabc: 123456
|
||||||
headers: # 自定义请求头
|
headers: # 自定义请求头
|
||||||
Authorization: Bearer xxxx
|
# Authorization: Bearer xxxx
|
||||||
|
format: wav # 接口返回的音频格式
|
||||||
output_file: tmp/
|
output_file: tmp/
|
||||||
# 模块测试配置
|
# 模块测试配置
|
||||||
module_test:
|
module_test:
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,11 @@ class TTSProvider(TTSProviderBase):
|
||||||
self.url = config.get("url")
|
self.url = config.get("url")
|
||||||
self.headers = config.get("headers", {})
|
self.headers = config.get("headers", {})
|
||||||
self.params = config.get("params")
|
self.params = config.get("params")
|
||||||
|
self.format = config.get("format", "wav")
|
||||||
self.output_file = config.get("output_file", "tmp/")
|
self.output_file = config.get("output_file", "tmp/")
|
||||||
|
|
||||||
def generate_filename(self, extension=".wav"):
|
def generate_filename(self):
|
||||||
return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}{extension}")
|
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):
|
async def text_to_speak(self, text, output_file):
|
||||||
request_params = {}
|
request_params = {}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue