From b3122e5c04ca7aa92b08a281e040b6767318ac99 Mon Sep 17 00:00:00 2001 From: ifeif <36729028+ifeif@users.noreply.github.com> Date: Fri, 14 Apr 2023 00:16:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9=E8=BF=87=E9=95=BF=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=BD=AC=E4=B8=BA=E6=96=87=E6=9C=AC=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E3=80=82=20(#344)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/chat.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/chat.js b/apps/chat.js index ccae4e2..f8fe18a 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -834,16 +834,6 @@ export class chatgpt extends plugin { if (quote.imageLink) imgUrls.push(quote.imageLink) } if (useTTS) { - // 先把文字回复发出去,避免过久等待合成语音 - if (Config.alsoSendText) { - await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup) - if (quotemessage.length > 0) { - this.reply(await makeForwardMsg(this.e, quotemessage.map(msg => `${msg.text} - ${msg.url}`))) - } - if (Config.enableSuggestedResponses && chatMessage.suggestedResponses) { - this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`) - } - } // 处理tts输入文本 let ttsResponse, ttsRegex const regex = /^\/(.*)\/([gimuy]*)$/ @@ -856,6 +846,19 @@ export class chatgpt extends plugin { ttsRegex = '' } ttsResponse = response.replace(ttsRegex, '') + // 先把文字回复发出去,避免过久等待合成语音 + if (Config.alsoSendText || ttsResponse.length > Config.ttsAutoFallbackThreshold) { + if(ttsResponse.length > Config.ttsAutoFallbackThreshold){ + await this.reply('回复的内容过长,已转为文本模式') + } + await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup) + if (quotemessage.length > 0) { + this.reply(await makeForwardMsg(this.e, quotemessage.map(msg => `${msg.text} - ${msg.url}`))) + } + if (Config.enableSuggestedResponses && chatMessage.suggestedResponses) { + this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`) + } + } if (Config.ttsSpace && ttsResponse.length <= Config.ttsAutoFallbackThreshold) { try { let wav = await generateAudio(ttsResponse, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)') @@ -873,8 +876,8 @@ export class chatgpt extends plugin { } catch (err) { await this.reply('合成语音发生错误~') } - } else { - await this.reply('你没有配置转语音API或者文字太长了哦') + } else if(!Config.ttsSpace){ + await this.reply('你没有配置转语音API哦') } } else if (userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) { // todo use next api of chatgpt to complete incomplete respoonse