-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (43 loc) · 981 Bytes
/
main.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
package main
import (
"fmt"
"os"
"strings"
)
var DEBUG = os.Getenv("GOOGLE_HOME_DEBUG") == "on"
func main() {
settings, err := ReadSettings()
if err != nil {
fmt.Println("Failed to read settings.", err)
return
}
ttsinput, ttsoutput, err := StartTTS(settings.Voicevox)
if err != nil {
fmt.Println("Failed to StartTTS.", err)
return
}
slacktextchan, slackdonechan := StartSlack(settings.Slack)
fmt.Println("Start waiting messages...")
var sound TtsOutputAttr
for text := range slacktextchan {
text = strings.TrimSpace(text)
if text == "" {
continue
}
if sound.FilePath != "" {
os.Remove(sound.FilePath)
}
ttsinput <- text
sound = <-ttsoutput
if sound.Error != nil {
slackdonechan <- fmt.Errorf("Failed to synthesize sound: %s", sound.Error)
continue
}
err = Play(sound, settings.GoogleHome)
if err != nil {
slackdonechan <- fmt.Errorf("Failed to play sound: %v", err)
continue
}
slackdonechan <- nil
}
}