增加语音合成失败处理。 (#278)

This commit is contained in:
小飞 2023-03-25 15:29:09 +08:00 committed by GitHub
parent 1432723de5
commit 73689f4639
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -498,6 +498,7 @@ export class chatgpt extends plugin {
if (e.isGroup && !e.atme) {
return false
}
if (e.user_id == Bot.uin) return false
prompt = e.msg.trim()
} else {
let ats = e.message.filter(m => m.type === 'at')
@ -740,9 +741,15 @@ export class chatgpt extends plugin {
}
if (useTTS) {
if (Config.ttsSpace && response.length <= Config.ttsAutoFallbackThreshold) {
let audio_err = false
try {
let wav = await generateAudio(response, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
await e.reply(segment.record(wav))
if (Config.alsoSendText) {
} catch (err) {
await this.reply('合成语音发生错误,我用文本回复你吧')
audio_err = true
}
if (Config.alsoSendText || audio_err) {
await this.reply(`${response}`, e.isGroup)
if (quotemessage.length > 0) {
this.reply(await makeForwardMsg(this.e, quotemessage))