A simple text to speech library for Go applications.
The example below uses the Google text to speech driver provided by the included gtts package. See the Engines section for available text to speech engines.
Playback can be done asynchronously if you choose as shown below. Currently language is configured by changing the constant in tts.go
.
import (
"github.com/kladd/tts"
"github.com/kladd/tts/engines/gtts"
)
func main() {
speaker := new(gtts.Speaker)
speaker.Say("Hello, World!")
aspeaker := tts.MakeAsync(speaker)
aspeaker.Say("Hello, asynchronous World!")
<-aspeaker.Done
}
Currently audio playback uses a shell command. On Darwin hosts this is afplay
, on Linux mpg123
. No support for Windows right now.
go get github.com/kladd/tts
See LICENSE
Appreciated. Fork, branch, commit, push, pull request.