Golang C bindings for the espeak
voice synthesizer.
There is a live demo of its usage at https://go-espeak-demo.djangulo.com, source code in examples/demo.
Sub-package native
contains a mostly C implementation, minimizing the amount of Go used. This implementation is slightly faster than the go implementation, with the inconvenience of being a black box from the input to the .wav
.
- Go >= 1.15 with
cgo
support espeak
.
Arch
~# pacman -S espeak
Ubuntu
~# apt-get install espeak
~$ go get -u github.com/djangulo/go-espeak
package main
import (
"github.com/djangulo/go-espeak"
)
func main() {
// need to call terminate so espeak can clean itself out
defer espeak.Terminate()
params := espeak.NewParameters().WithDir(".")
espeak.TextToSpeech(
"Hello World!", // Text to speak
nil, // voice to use, nil == DefaultVoice (en-us male)
"hello.wav", // if "" or "play", it plays to default audio out
params, // Parameters for voice modulation, nil == DefaultParameters
)
// get a random spanish voice
v, _ := espeak.VoiceFromSpec(&espeak.Voice{Languages: "es"})
espeak.TextToSpeech("¡Hola mundo!", v, "hola.wav", params)
}