mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
预防火山引擎(doubao)的appid填写为整数
This commit is contained in:
parent
b8364af0d9
commit
1f5962c312
2 changed files with 12 additions and 7 deletions
|
|
@ -136,7 +136,7 @@ class ASRProvider(ASRProviderBase):
|
|||
"""Construct the request payload."""
|
||||
return {
|
||||
"app": {
|
||||
"appid": self.appid,
|
||||
"appid": f"{self.appid}",
|
||||
"cluster": self.cluster,
|
||||
"token": self.access_token,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue