Skip to content

djangulo/go-espeak

Repository files navigation

PkgGoDev CI status

go-espeak

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.

Requirements

  • Go >= 1.15 with cgo support
  • espeak.

Install

Install requirements

Arch

~# pacman -S espeak

Ubuntu

~# apt-get install espeak

Install go-espeak

~$ go get -u github.com/djangulo/go-espeak

Usage

examples/basic-usage.

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)
}

About

Golang C bindings for the `espeak` voice synthesizer.

Resources

License

Stars

Watchers

Forks

Packages

No packages published