This commit is contained in:
seven 2025-03-26 00:06:45 +08:00
parent 959457a6b2
commit f00d665918
2 changed files with 14 additions and 9 deletions

View file

@ -302,7 +302,15 @@ TTS:
cluster: volcano_tts cluster: volcano_tts
LinkeraiTTS: LinkeraiTTS:
# 定义TTS API类型 # 定义TTS API类型
# 支持克隆音色,文档地址:https://tts.linkerai.top/docs#/ # 支持克隆音色、方言:
# 四川话
# 粤语
# 上海话
# 郑州话
# 长沙话
# 天津话
# 普通话
# 文档地址:https://tts.linkerai.top/docs#/
type: linkerai type: linkerai
api_url: https://tts.linkerai.top/tts api_url: https://tts.linkerai.top/tts
voice: OUeAo1mhq6IBExi voice: OUeAo1mhq6IBExi

View file

@ -37,9 +37,12 @@ class TTSProvider(TTSProviderBase):
"Authorization": f"Bearer {self.access_token}", "Authorization": f"Bearer {self.access_token}",
"Content-Type": "application/json" "Content-Type": "application/json"
} }
with open(output_file,'w',encoding='utf-8') as f: with open(output_file,'w',encoding='utf-8') as f:
f.write('%s\n'%(json.dumps(params,ensure_ascii=False))) f.write('%s\n'%(json.dumps(params,ensure_ascii=False)))
f.write('%s'%(json.dumps(headers,ensure_ascii=False))) f.write('%s'%(json.dumps(headers,ensure_ascii=False)))
with open('%s.linkerai'%output_file,'w',encoding='utf-8') as f:
f.write('linkerai\n')
def yield_data(self,params,headers): def yield_data(self,params,headers):
response = requests.get(self.api_url, headers=headers, params=params, stream=True) response = requests.get(self.api_url, headers=headers, params=params, stream=True)
@ -52,13 +55,7 @@ class TTSProvider(TTSProviderBase):
print(f"错误信息: {response.text}") print(f"错误信息: {response.text}")
def audio_to_opus_data(self, audio_file_path): def audio_to_opus_data(self, audio_file_path):
fsize = 0 if os.path.exists('%s.linkerai'%audio_file_path):
if os.path.exists(audio_file_path):
fsize = os.path.getsize(audio_file_path)
else:
return None,None
if fsize < 1000:
duration = 100 duration = 100
code = [] code = []
with open(audio_file_path,encoding='utf-8') as f: with open(audio_file_path,encoding='utf-8') as f:
@ -66,7 +63,7 @@ class TTSProvider(TTSProviderBase):
code.append(json.loads(line.strip())) code.append(json.loads(line.strip()))
params = code[0] params = code[0]
headers = code[1] headers = code[1]
os.remove('%s.linkerai'%audio_file_path)
return self.yield_data(params=params,headers=headers),duration return self.yield_data(params=params,headers=headers),duration
else: else:
"""音频文件转换为Opus编码""" """音频文件转换为Opus编码"""