So I updated my text-to-speech clock by abstracting out the text-to-speech code to its own Ruby gem: bratta-mactts on the githubs. It’s a neat little tool that allows you to write the following Ruby code (if you are on a Mac running OS X):

That will pipe out the phrase “Hello, world!” through your Mac’s speakers with the scary Deranged voice. A full list of voices is available in your Speech preferences panel, or you can view the symbolized versions used by the gem by doing something like this: puts Mac::TTS.valid_voices

In fact, you can write a simple program to preview each of the voices pretty easily:

That will loop over all the valid voices and say “My name is ______” with a one-second pause in-between phrases.

So why did I do this? Mainly because I thought of a couple more uses for automated text-to-speech ideas that can help me when I want to stay focused on work and not be distracted visually, but can afford to listen to something instead. Like hearing the current time, or listening to new entries from key RSS feeds as they come in. Yeah, it’s not for everyone, but it is a neat exercise if anything. I whipped the code together really quickly and so it’s pretty raw. But hey, there are specs and they all pass. Regardless, get the gem today and fiddle around!

sudo gem install bratta-mactts –source http://gems.github.com