Add SayWithVoice to yaegi symbols
This commit is contained in:
parent
dabe5b0fe2
commit
aafa36ad61
@ -100,4 +100,3 @@ func initPlugins(gopath string) map[string]pluginFunc {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
|
14
symbols.go
14
symbols.go
@ -26,10 +26,20 @@ import (
|
||||
// Create custom package for trident
|
||||
var tridentSymbols = interp.Exports{"trident": {
|
||||
"Say": reflect.ValueOf(Say),
|
||||
"SayWithVoice": reflect.ValueOf(SayWithVoice),
|
||||
}}
|
||||
|
||||
// Function to say text using mimic text-to-speech
|
||||
func Say(text string) {
|
||||
voice, _ := flite.VoiceSelect("slt")
|
||||
flite.TextToSpeech(text, voice, "play")
|
||||
fliteVoice, _ := flite.VoiceSelect("slt")
|
||||
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