fix: 修复tts报错body alreay used问题

This commit is contained in:
ikechan8370 2023-03-05 15:35:07 +08:00
parent 75a060b86c
commit d3cea768f7

View file

@ -56,8 +56,9 @@ export async function generateAudio (text, speaker = '随机', language = '中
'content-type': 'application/json'
}
})
let responseBody = await response.text()
try {
let json = await response.json()
let json = JSON.parse(responseBody)
if (Config.debug) {
logger.info(json)
}
@ -71,7 +72,7 @@ export async function generateAudio (text, speaker = '随机', language = '中
return audioLink
} catch (err) {
logger.error('生成语音api发生错误请检查是否配置了正确的api且仓库是否开放为public', response.status)
throw new Error(await response.text())
throw new Error(responseBody)
}
}
export function convertSpeaker (speaker) {