Speech synthesis: Difference between revisions

Go solution
m (→‎{{header|Sidef}}: removed an unneeded semicolon)
(Go solution)
Line 130:
<lang clojure>(use 'speech-synthesis.say)
(say "This is an example of speech synthesis.")</lang>
 
=={{header|Go}}==
Here's a library solution, but using a library written from scratch in Go.
<lang go>package main
 
import (
"go/build"
"log"
"path/filepath"
 
"github.com/unixpickle/gospeech"
"github.com/unixpickle/wav"
)
 
const pkgPath = "github.com/unixpickle/gospeech"
const input = "This is an example of speech synthesis."
 
func main() {
p, err := build.Import(pkgPath, ".", build.FindOnly)
if err != nil {
log.Fatal(err)
}
d := filepath.Join(p.Dir, "dict/cmudict-IPA.txt")
dict, err := gospeech.LoadDictionary(d)
if err != nil {
log.Fatal(err)
}
phonetics := dict.TranslateToIPA(input)
synthesized := gospeech.DefaultVoice.Synthesize(phonetics)
wav.WriteFile(synthesized, "output.wav")
}</lang>
 
=={{header|Groovy}}==
1,707

edits