mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 15:20:22 +00:00
百度tts自行指定 id&secret
This commit is contained in:
@@ -2,6 +2,7 @@ package aireply
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/RomiChan/syncx"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -57,6 +58,7 @@ const defaultttsindexkey = -2905
|
||||
var (
|
||||
原 = newapikeystore("./data/tts/o.txt")
|
||||
ཆཏ = newapikeystore("./data/tts/c.txt")
|
||||
百 = newapikeystore("./data/tts/b.txt")
|
||||
)
|
||||
|
||||
type replymode []string
|
||||
@@ -202,7 +204,8 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) {
|
||||
if !ok || ins == nil {
|
||||
switch mode {
|
||||
case extrattsname[0]:
|
||||
ins = baidutts.NewBaiduTTS(int(i&0x0f00) >> 8)
|
||||
id, sec, _ := strings.Cut(百.k, ",")
|
||||
ins = baidutts.NewBaiduTTS(int(i&0x0f00)>>8, id, sec)
|
||||
case extrattsname[1]:
|
||||
var err error
|
||||
ins, err = ttscn.NewTTSCN("中文(普通话,简体)", ttscnspeakers[int(i&0xf000)>>12], ttscn.KBRates[0])
|
||||
|
||||
@@ -28,6 +28,7 @@ func init() { // 插件主体
|
||||
"- 设置默认语音模式[原神人物/百度/TTSCN] 数字(百度/TTSCN说话人)\n" +
|
||||
"- 恢复成默认语音模式\n" +
|
||||
"- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" +
|
||||
"- 设置百度语音 api id xxxxxx secret xxxxxx (请自行获得)\n" +
|
||||
"当前适用的原神人物含有以下: \n" + list(genshin.SoundList[:], 5) +
|
||||
"\n当前适用的TTSCN人物含有以下(以数字顺序代表): \n" + list(ttscnspeakers[:], 5),
|
||||
PrivateDataFolder: "tts",
|
||||
@@ -103,7 +104,7 @@ func init() { // 插件主体
|
||||
}
|
||||
})
|
||||
|
||||
ent.OnRegex(`^设置语音模式\s*([\S\D]*)\s*(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
ent.OnRegex(`^设置语音模式\s*(.*)\s+(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
num := ctx.State["regex_matched"].([]string)[2]
|
||||
n := 0
|
||||
@@ -190,4 +191,13 @@ func init() { // 插件主体
|
||||
}
|
||||
ctx.SendChain(message.Text("设置成功"))
|
||||
})
|
||||
|
||||
ent.OnRegex(`^设置百度语音\s*api\s*id\s*(.*)\s*secret\s*(.*)\s*$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
err := 百.set(ctx.State["regex_matched"].([]string)[1] + "," + ctx.State["regex_matched"].([]string)[2])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("设置成功"))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user