Given the variety of sophisticated web services available today, it is surprising that a good Text To Speech API (TTS) is not readily available.
Google has one as part of its Translation API but it is not publicized or actively supported. The Bing/Microsoft Translate API also has a TTS feature and this is supported. In my experience this works very well and allows you to specify the language of the text, which changes the voice and pronunciation that is used.
Accessing this API is easy enough using a wrapper library, such as https://github.com/CodeBlock/bing_translator-gem (disclaimer: I added the speak() function to this ruby gem) but it returns binary data that represents an MP3 file. The HTML5 audio tag allows you play audio files, but not, apparently, to play the data itself.
The result is that the TTS output must be first written to a file and then played via the audio tag.
The Live Demo for this is at http://bing-translate-tts-demo.craic.com/ and the code required to implement the whole thing is freely available at https://github.com/craic/bing_translate_text_to_speech
The demo has several moving parts and setting it up for yourself requires experience with Sinatra, S3, etc.
Archive of Tips
- ▼ April (5)
- ► 2012 (28)
- ► 2011 (44)
- ► 2010 (40)
- ► 2009 (53)
- ► 2008 (21)