Add SayWithVoice to yaegi symbols
This commit is contained in:
parent
dabe5b0fe2
commit
aafa36ad61
@ -93,4 +93,4 @@ func configEnv() (gopath, configDir, execDir, confPath string) {
|
|||||||
}
|
}
|
||||||
// Return all variables
|
// Return all variables
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
4
main.go
4
main.go
@ -208,7 +208,7 @@ func main() {
|
|||||||
// Create goroutine to clean stream every minute
|
// Create goroutine to clean stream every minute
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(20*time.Second)
|
time.Sleep(20 * time.Second)
|
||||||
// Lock mutex of stream
|
// Lock mutex of stream
|
||||||
safeStream.Lock()
|
safeStream.Lock()
|
||||||
// Reset stream and buffer
|
// Reset stream and buffer
|
||||||
@ -224,7 +224,7 @@ func main() {
|
|||||||
var tts string
|
var tts string
|
||||||
listenForActivation := true
|
listenForActivation := true
|
||||||
for {
|
for {
|
||||||
time.Sleep(200*time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
// Convert captured raw audio to slice of int16
|
// Convert captured raw audio to slice of int16
|
||||||
slice, err := convToInt16Slice(captured)
|
slice, err := convToInt16Slice(captured)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -100,4 +100,3 @@ func initPlugins(gopath string) map[string]pluginFunc {
|
|||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
symbols.go
18
symbols.go
@ -25,11 +25,21 @@ import (
|
|||||||
|
|
||||||
// Create custom package for trident
|
// Create custom package for trident
|
||||||
var tridentSymbols = interp.Exports{"trident": {
|
var tridentSymbols = interp.Exports{"trident": {
|
||||||
"Say": reflect.ValueOf(Say),
|
"Say": reflect.ValueOf(Say),
|
||||||
|
"SayWithVoice": reflect.ValueOf(SayWithVoice),
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// Function to say text using mimic text-to-speech
|
// Function to say text using mimic text-to-speech
|
||||||
func Say(text string) {
|
func Say(text string) {
|
||||||
voice, _ := flite.VoiceSelect("slt")
|
fliteVoice, _ := flite.VoiceSelect("slt")
|
||||||
flite.TextToSpeech(text, voice, "play")
|
flite.TextToSpeech(text, fliteVoice, "play")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SayWithVoice(text, voice string) error {
|
||||||
|
fliteVoice, err := flite.VoiceSelect(voice)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
flite.TextToSpeech(text, fliteVoice, "play")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user