mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 15:20:22 +00:00
🔖 1.4.0-beta6
This commit is contained in:
@@ -60,9 +60,13 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msg := ctx.ExtractPlainText()
|
||||
r := aireply.NewAIReply(getReplyMode(ctx))
|
||||
tts := t.new(t.getSoundMode(ctx))
|
||||
tts, err := t.new(t.getSoundMode(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
if tts != nil {
|
||||
ctx.SendChain(message.Record(tts.Speak(ctx.Event.UserID, func() string {
|
||||
rec, err := tts.Speak(ctx.Event.UserID, func() string {
|
||||
reply := r.TalkPlain(msg, zero.BotConfig.NickName[0])
|
||||
reply = re.ReplaceAllStringFunc(reply, func(s string) string {
|
||||
f, err := strconv.ParseFloat(s, 64)
|
||||
@@ -74,7 +78,10 @@ func init() {
|
||||
})
|
||||
log.Debugln("[tts]:", reply)
|
||||
return reply
|
||||
})))
|
||||
})
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Record(rec))
|
||||
}
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^设置语音模式(.*)$`, ctxext.FirstValueInList(t)).SetBlock(true).
|
||||
@@ -96,7 +103,7 @@ func init() {
|
||||
}
|
||||
|
||||
// new 语音简单工厂
|
||||
func (t *ttsInstances) new(name string) (ts tts.TTS) {
|
||||
func (t *ttsInstances) new(name string) (ts tts.TTS, err error) {
|
||||
t.RLock()
|
||||
ts = t.m[name]
|
||||
t.RUnlock()
|
||||
@@ -104,11 +111,11 @@ func (t *ttsInstances) new(name string) (ts tts.TTS) {
|
||||
switch name {
|
||||
case "拟声鸟阿梓":
|
||||
t.Lock()
|
||||
ts, _ = mockingbird.NewMockingBirdTTS(0)
|
||||
ts, err = mockingbird.NewMockingBirdTTS(0)
|
||||
t.Unlock()
|
||||
case "拟声鸟药水哥":
|
||||
t.Lock()
|
||||
ts, _ = mockingbird.NewMockingBirdTTS(1)
|
||||
ts, err = mockingbird.NewMockingBirdTTS(1)
|
||||
t.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user