mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +00:00
新增:回复的内容过长时,自动转为文本模式。 (#344)
This commit is contained in:
parent
9b9b69634e
commit
b3122e5c04
1 changed files with 15 additions and 12 deletions
27
apps/chat.js
27
apps/chat.js
|
|
@ -834,16 +834,6 @@ export class chatgpt extends plugin {
|
||||||
if (quote.imageLink) imgUrls.push(quote.imageLink)
|
if (quote.imageLink) imgUrls.push(quote.imageLink)
|
||||||
}
|
}
|
||||||
if (useTTS) {
|
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输入文本
|
// 处理tts输入文本
|
||||||
let ttsResponse, ttsRegex
|
let ttsResponse, ttsRegex
|
||||||
const regex = /^\/(.*)\/([gimuy]*)$/
|
const regex = /^\/(.*)\/([gimuy]*)$/
|
||||||
|
|
@ -856,6 +846,19 @@ export class chatgpt extends plugin {
|
||||||
ttsRegex = ''
|
ttsRegex = ''
|
||||||
}
|
}
|
||||||
ttsResponse = response.replace(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) {
|
if (Config.ttsSpace && ttsResponse.length <= Config.ttsAutoFallbackThreshold) {
|
||||||
try {
|
try {
|
||||||
let wav = await generateAudio(ttsResponse, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
|
let wav = await generateAudio(ttsResponse, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
|
||||||
|
|
@ -873,8 +876,8 @@ export class chatgpt extends plugin {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await this.reply('合成语音发生错误~')
|
await this.reply('合成语音发生错误~')
|
||||||
}
|
}
|
||||||
} else {
|
} else if(!Config.ttsSpace){
|
||||||
await this.reply('你没有配置转语音API或者文字太长了哦')
|
await this.reply('你没有配置转语音API哦')
|
||||||
}
|
}
|
||||||
} else if (userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
|
} else if (userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
|
||||||
// todo use next api of chatgpt to complete incomplete respoonse
|
// todo use next api of chatgpt to complete incomplete respoonse
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue