-
Notifications
You must be signed in to change notification settings - Fork 4
/
speech.go
60 lines (52 loc) · 1.45 KB
/
speech.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
package main
import (
"aigen/aigenAudioAutoPlay"
"aigen/aigenRest"
"log"
)
const notificationSoundFile = "notification.mp3"
const welcomeNotificationSoundFile = "welcome.mp3"
func pressPlayAudio(messageCall string) (bool, string) {
//Azure Speech
//TODO:: Allow switching of speech providers to allow for easy management of resources in cases
//were Azure Speech starts to act real funny we can pull the plug real quick
//soundFileName, checkError := aigenRest.SpeakOut(messageCall)
//soundFileName, checkError := aigenRest.GCloudSpeakOUt(messageCall)
soundFileName, checkError := aigenRest.GptSpeakOut(messageCall)
if checkError == nil {
log.Println(soundFileName)
playSound := aigenAudioAutoPlay.PlayAudioPlayback(soundFileName)
if playSound != nil {
return true, soundFileName
}
log.Printf("Sound file %s played successfully", soundFileName)
} else {
log.Println(checkError)
}
return true, soundFileName
}
func notificationSound() {
err := aigenAudioAutoPlay.PlayAudioPlayback(notificationSoundFile)
if err != nil {
log.Println(err)
}
}
func playVoiceNote(filename string) {
err := aigenAudioAutoPlay.PlayAudioPlayback(filename)
if err != nil {
log.Println(err)
}
}
func playWelcomeSound() {
err := aigenAudioAutoPlay.PlayAudioPlayback(welcomeNotificationSoundFile)
if err != nil {
return
}
}
func getAudioFile(message string) {
audioFile, err := getAudio(message)
if err != nil {
log.Println(err)
}
playVoiceNote(audioFile)
}