fix: nwife dup slash & genshin vits

This commit is contained in:
源文雨
2022-10-10 10:12:23 +08:00
parent c4c3f79c8c
commit 77f7567b29
4 changed files with 16 additions and 17 deletions

View File

@@ -12,7 +12,7 @@ import (
)
const (
cnapi = "http://233366.proxy.nscc-gz.cn:8888?speaker=%s&text=%s"
cnapi = "https://genshin.azurewebsites.net/api/speak?format=mp3&id=%d&text=%s"
// testString = "这是测试语音......"
)
@@ -133,14 +133,14 @@ func (tts *ttsmode) setSoundMode(ctx *zero.Ctx, name string) error {
return m.SetData(gid, int64(i))
}
func (tts *ttsmode) getSoundMode(ctx *zero.Ctx) (name string) {
func (tts *ttsmode) getSoundMode(ctx *zero.Ctx) (i int64) {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
tts.RLock()
defer tts.RUnlock()
return soundList[tts.mode[gid]]
return tts.mode[gid]
}
func (tts *ttsmode) resetSoundMode(ctx *zero.Ctx) {

View File

@@ -43,10 +43,8 @@ func init() { // 插件主体
r := aireply.NewAIReply(getReplyMode(ctx))
// 获取回复的文本
reply := r.TalkPlain(msg, zero.BotConfig.NickName[0])
// 获取角色
name := tts.getSoundMode(ctx)
// 获取语音
record := message.Record(fmt.Sprintf(cnapi, url.QueryEscape(name), url.QueryEscape(
record := message.Record(fmt.Sprintf(cnapi, tts.getSoundMode(ctx), url.QueryEscape(
// 将数字转文字
re.ReplaceAllStringFunc(reply, func(s string) string {
f, err := strconv.ParseFloat(s, 64)
@@ -81,12 +79,12 @@ func init() { // 插件主体
return
}
// 设置验证
name := tts.getSoundMode(ctx)
if _, ok := testRecord[name]; !ok {
i := tts.getSoundMode(ctx)
if _, ok := testRecord[soundList[i]]; !ok {
ctx.SendChain(message.Text("配置的语音人物数据丢失!请重新设置语音人物。"))
return
}
record := message.Record(fmt.Sprintf(cnapi, url.QueryEscape(name), url.QueryEscape(testRecord[name]))).Add("cache", 0)
record := message.Record(fmt.Sprintf(cnapi, i, url.QueryEscape(testRecord[soundList[i]]))).Add("cache", 0)
if ID := ctx.SendChain(record); ID.ID() == 0 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置失败!无法发送测试语音,请重试。"))
return