forked from yihong0618/xiaogpt
-
Notifications
You must be signed in to change notification settings - Fork 18
/
xiaobot_test.go
70 lines (62 loc) · 1.35 KB
/
xiaobot_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package xiaobot
import (
"github.com/BurntSushi/toml"
"log"
"os"
"testing"
"time"
)
func TestMiBot(t *testing.T) {
user := os.Getenv("MI_USER")
if user == "" {
t.Skip("MI_USER not set")
}
p := "tmp.token"
opt := map[string]interface{}{
"hardware": "LX01",
"token_path": p,
"openai_key": "test",
"enable_edge_tts": true,
}
cfg, err := NewConfigFromOptions(opt)
if err != nil {
t.Error(err)
}
bt := NewMiBot(cfg)
err = bt.initAllData()
if err != nil {
t.Error(err)
}
j := bt.needAskJarvis("帮我看看今天的天气怎么样")
if !j {
t.Error("needAskJarvis failed")
}
r, err := bt.getLatestAsk()
if err != nil {
t.Error(err)
}
log.Println(r)
b, err := bt.speakerIsPlaying()
if err != nil {
t.Error(err)
}
log.Println(b)
err = bt.stopSpeaker()
if err != nil {
t.Error(err)
}
err = bt.miTTS("小爱同学吃了一条鱼", false)
if err != nil {
t.Error(err)
}
time.Sleep(1 * time.Second)
err = bt.edgeTTS("小爱同学吃了两条鱼", "zh-CN-XiaoxiaoNeural")
if err != nil {
t.Error(err)
}
os.Remove(p)
}
func TestMi0(t *testing.T) {
b := Config{}
toml.NewEncoder(os.Stdout).Encode(b)
}