-
Notifications
You must be signed in to change notification settings - Fork 1
/
speechd_test.go
127 lines (126 loc) · 2.23 KB
/
speechd_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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package speechd
import "testing"
import "time"
func TestOpen(t *testing.T) {
t.Log("opening connection with default settings")
c,err := Open()
if err != nil {
t.Fatal(err)
}
defer c.Close()
t.Run("ClientName", func(t *testing.T) {
t.Log("setting client name")
err := c.SetClientName("user", "tester", "tester")
if err != nil {
t.Fatal(err)
}
})
t.Run("PlainSpeak", func(t *testing.T) {
_,err := c.Speak("plain1")
if err != nil {
t.Fatal(err)
}
time.Sleep(3 * time.Second)
_,err = c.Speak("plain2")
if err != nil {
t.Fatal(err)
}
})
time.Sleep(3 * time.Second)
t.Run("rate", func(t *testing.T) {
t.Log("low rate")
err := c.SetRate(-100)
if err != nil {
t.Fatal(err)
}
_,err = c.Speak("low rate")
if err != nil {
t.Fatal(err)
}
time.Sleep(3 * time.Second)
t.Log("high rate")
err = c.SetRate(100)
if err != nil {
t.Fatal(err)
}
_,err = c.Speak("high rate")
if err != nil {
t.Fatal(err)
}
time.Sleep(3 * time.Second)
t.Log("normal rate")
err = c.SetRate(0)
if err != nil {
t.Fatal(err)
}
_,err = c.Speak("normal")
if err != nil {
t.Fatal(err)
}
})
t.Run("pitch", func(t *testing.T) {
t.Log("low pitch")
err := c.SetPitch(-100)
if err != nil {
t.Fatal(err)
}
_,err = c.Speak("low pitch")
if err != nil {
t.Fatal(err)
}
time.Sleep(3 * time.Second)
t.Log("high pitch")
err = c.SetPitch(100)
if err != nil {
t.Fatal(err)
}
_,err = c.Speak("high pitch")
if err != nil {
t.Fatal(err)
}
time.Sleep(3 * time.Second)
t.Log("normal pitch")
err = c.SetPitch(0)
if err != nil {
t.Fatal(err)
}
_,err = c.Speak("normal")
if err != nil {
t.Fatal(err)
}
})
t.Run("SpeakWithWait", func(t *testing.T) {
t.Log("enabling event notifications")
err := c.SetEventNotifications(true)
if err != nil {
t.Fatal(err)
}
t.Log("speaking first word")
tn := time.Now()
msg,err := c.Speak("this is an eventful speaking")
if err != nil {
t.Fatal(err)
}
msg.Wait()
tt := time.Since(tn)
t.Logf("ok speaking eventful, time taken %v", tt / time.Millisecond)
})
t.Run("ListOutputModules", func(t *testing.T) {
t.Log("requesting outmod list")
vl,err := c.ListOutputModules()
if err != nil {
t.Fatal(err)
}
for _,v := range vl {
t.Run("SetOutputModule", func(t *testing.T) {
t.Logf("setting outmod to %s", v)
err := c.SetOutputModule(v)
if err != nil {
t.Fatal(err)
}
c.Speak("module test")
time.Sleep(3 * time.Second)
})
}
})
}