Doubao asr (#117)

* 添加豆包在线 ASR (#82)
---------
Co-authored-by: 胡垚 <qsct9501@163.com>
This commit is contained in:
欣南科技
2025-02-23 14:38:21 +08:00
committed by GitHub
co-authored by 胡垚
parent f054f66d92
commit 6c3fbd7a8f
25 changed files with 742 additions and 689 deletions
+11 -6
View File
@@ -25,7 +25,7 @@ class TTSProvider(TTSProviderBase):
async def text_to_speak(self, text, output_file):
request_json = {
"app": {
"appid": self.appid,
"appid": f"{self.appid}",
"token": "access_token",
"cluster": self.cluster
},
@@ -49,8 +49,13 @@ class TTSProvider(TTSProviderBase):
}
}
resp = requests.post(self.api_url, json.dumps(request_json), headers=self.header)
if "data" in resp.json():
data = resp.json()["data"]
file_to_save = open(output_file, "wb")
file_to_save.write(base64.b64decode(data))
try:
resp = requests.post(self.api_url, json.dumps(request_json), headers=self.header)
if "data" in resp.json():
data = resp.json()["data"]
file_to_save = open(output_file, "wb")
file_to_save.write(base64.b64decode(data))
else:
raise Exception(f"{__name__} status_code: {resp.status_code} response: {resp.content}")
except Exception as e:
raise Exception(f"{__name__} error: {e}")
+1 -1
View File
@@ -89,7 +89,7 @@ class TTSProvider(TTSProviderBase):
self.channels = config.get("channels",1)
self.rate = config.get("rate",44100)
self.api_key = config.get("api_key","YOUR_API_KEY")
if not self.api_key or "" in self.api_key:
if "" in self.api_key:
logger.bind(tag=TAG).error("你还没配置FishSpeech TTS的密钥,请在配置文件中配置密钥,否则无法正常工作")
return
self.normalize = config.get("normalize",True)