feat: 自定义tts音频格式兼容

This commit is contained in:
journey-ad 2025-03-13 16:06:44 +08:00
parent 58f26077bc
commit cba153be79
2 changed files with 11 additions and 9 deletions

View file

@ -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:

View file

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