Merge branch 'v2' of github.com:ikechan8370/chatgpt-plugin into v2

This commit is contained in:
ikechan8370 2023-04-03 12:31:20 +08:00
commit 0d5ebc073f
6 changed files with 82 additions and 48 deletions

View file

@ -798,27 +798,9 @@ export class chatgpt extends plugin {
})
}
if (useTTS) {
if (Config.ttsSpace && response.length <= Config.ttsAutoFallbackThreshold) {
let audioErr = false
try {
let wav = await generateAudio(response, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
await e.reply(segment.record(wav))
} catch (err) {
await this.reply('合成语音发生错误,我用文本回复你吧')
audioErr = true
}
if (Config.alsoSendText || audioErr) {
await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup)
if (quotemessage.length > 0) {
this.reply(await makeForwardMsg(this.e, quotemessage))
}
if (Config.enableSuggestedResponses && chatMessage.suggestedResponses) {
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
}
}
} else {
await this.reply('你没有配置转语音API或者文字太长了哦我用文本回复你吧')
await this.reply(`${response}`, e.isGroup)
// 先把文字回复发出去,避免过久等待合成语音
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))
}
@ -826,6 +808,18 @@ export class chatgpt extends plugin {
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
}
}
// 过滤‘括号’的内容不读,减少违和感
let ttsResponse = response.replace(/[(\[{<【《「『【〖【【【“‘'"@][^()\]}>】》」』】〗】】”’'@]*[)\]}>】》」』】〗】】”’'@]/g, '')
if (Config.ttsSpace && ttsResponse.length <= Config.ttsAutoFallbackThreshold) {
try {
let wav = await generateAudio(ttsResponse, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
await e.reply(segment.record(wav))
} catch (err) {
await this.reply('合成语音发生错误~')
}
} else {
await this.reply('你没有配置转语音API或者文字太长了哦')
}
} else if (userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
// todo use next api of chatgpt to complete incomplete respoonse
try {