Skip to content

Instantly share code, notes, and snippets.

@vijayabose
Created June 30, 2020 07:05
Show Gist options
  • Save vijayabose/239e0f6a14195848d649ef9a9f1067d6 to your computer and use it in GitHub Desktop.
Save vijayabose/239e0f6a14195848d649ef9a9f1067d6 to your computer and use it in GitHub Desktop.
Mac Text to speech sample (Golang)
package main
import (
"os/exec"
)
func main() {
textsound := `Once upon a time there was an old woman who loved baking gingerbread. She would bake gingerbread cookies, cakes, houses and gingerbread people, all decorated with chocolate and peppermint, caramel candies and colored frosting.
She lived with her husband on a farm at the edge of town. The sweet spicy smell of gingerbread brought children skipping and running to see what would be offered that day.
Unfortunately the children gobbled up the treats so fast that the old woman had a hard time keeping her supply of flour and spices to continue making the batches of gingerbread. Sometimes she suspected little hands of having reached through her kitchen window because gingerbread pieces and cookies would disappear. One time a whole gingerbread house vanished mysteriously. She told her husband, "Those naughty children are at it again. They don't understand all they have to do is knock on the door and I'll give them my gingerbread treats.""`
cmd := exec.Command("say", "-r", "175", textsound)
//For output file generation
//"-o","fileName.aiff" use lame to convert
cmd.Run()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment