feat: 支持腾讯TTS声音一句话复刻后的合成

This commit is contained in:
kevin1sMe 2025-05-03 23:58:58 +08:00
parent 0f3806d358
commit 8f126e6e2a

View file

@ -20,6 +20,7 @@ class TTSProvider(TTSProviderBase):
self.voice = config.get("private_voice") self.voice = config.get("private_voice")
else: else:
self.voice = int(config.get("voice")) self.voice = int(config.get("voice"))
self.fast_voice_type = config.get("fast_voice_type")
self.api_url = "https://tts.tencentcloudapi.com" # 正确的API端点 self.api_url = "https://tts.tencentcloudapi.com" # 正确的API端点
self.region = config.get("region") self.region = config.get("region")
self.output_file = config.get("output_dir") self.output_file = config.get("output_dir")
@ -135,6 +136,9 @@ class TTSProvider(TTSProviderBase):
"VoiceType": int(self.voice), # 音色 "VoiceType": int(self.voice), # 音色
} }
if self.fast_voice_type: # 如果不为空则添加,在使用声音复刻时可能需要此参数
request_json["FastVoiceType"] = str(self.fast_voice_type)
try: try:
# 获取请求头(每次请求都重新生成,以确保时间戳和签名是最新的) # 获取请求头(每次请求都重新生成,以确保时间戳和签名是最新的)
headers = self._get_auth_headers(request_json) headers = self._get_auth_headers(request_json)