Wrote this module to expose a simple API for speech generation from a given text. The adopted approach is to make use of the espeak TTS engine. Espeak is small, free and the results are crude, but supports many languages (run
espeak --voices to chec k the ones available in your machine) and is enough for some scenarios. Later on I may offer alternative engines support (you want to help out?).
You can use browser APIs for Chrome, Safari and such, if available. You can also use third-party web services for TTS. The point here is that you keep the dependency on your side, at the server level. Currently espeak can be run in browsers but that's heavy on CPU and memory - using this approach you request the text's speech and get back an encoded mp3/ogg of the generated audio sample.
I'm by no means an expert in TTS usage. Feel free to contribute with optimizations, sample usages of alternate engines and/or pull requests of changes to make this work in additional OSs. I've marked this linux-only because I didn't have the chance to try it out in different environments and because I figured out loads of servers run a debian-like flavour of linux anyway.
npm install simple-tts
var speak = ;// usage case 1 - writes the binary audio sample to the response stream (for returning it in an HTTP handler)response;;// usage case 2 - creates the file /tmp/hello_world.mp3 in your OS (for caching or other purposes, the filename extension is automatically appended to the give filename);
sudo apt-get install espeak lame vorbis-tools git clone firstname.lastname@example.org:JosePedroDias/simple-tts.git cd simple-tts node simple-tts-server &
go to http://127.0.0.1:8888