Mac TTS with Ruby Update

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

Affecting Positive Change

I’ve been running lately in an effort to be a healthier person. I’ve also been really watching my portion sizes of food to keep things a little more realistic. My soda intake is basically zero since I don’t drink regular sodas anymore and I can’t stand the taste of diet. So in effect I’ve been able to drastically change my behavior in a short period of time to achieve some pretty radical results.

I’ve lost over 40 pounds since starting back up on this routine, and now I feel it is time to take it a step further to tighten up the engine that is my body. I’ve also decided to post it here in my blog to help get me some accountability from my peers as I struggle to remain on track and reach my goals. I mean, look at the before and after pictures of my current progress:

Before and After

Note that I’m not looking for a diet. I’m not looking for a “get thin quick” scheme. Those only lead to failure as I have encountered many times before in the past. If I spend my days eating nothing but energy bars or shakes and spending all my free time at the gym, I *will* get burned out and will eventually balloon up to the scary morbidly obese weight I was at my worst.

Instead I’m looking to affect positive change by changing my lifestyle to gradually become healthier. I’m doing this for health reasons and losing weight will be a great side effect of this–but not the rubric or the goal. The goal is to be happier and healthier.

So what I’m deciding to do is to cut out a few things that are my trouble spots: temptations that lead to overindulgence and hurt my health instead of helping it.

To start with, I’m cutting out 90% of my alcohol intake. For the most part, alcohol is one of the worst things you can ingest. There’s always the threat of alcoholism, liver damage, and other really bad things, but the reason I want to cut it out is due to calories and fat. And it’s damn expensive. Also, I really hate being drunk as I feel like it is a waste of time. I could be spending my time doing something productive such as programming, writing my book, or even composing music. It’s hard to do that when you’re wasted. Believe me, I’ve tried. Plus when I’m tipsy I tend to buy more stuff online so it’ll help me cut down on clutter and save me some money, too! Besides, drinking leads to playing stupid games like Wisest Wizard:

Drinking leads to nerdy games like Wisest Wizard. Do you really want this?

The only alcohol I will allow myself will be the occasional glass of wine, as studies have shown that a glass of wine a day can actually help. I don’t think I can stomach having wine that often, but the occasional glass of wine or even champagne won’t be a big deal.

The next change is going to be really, really tough for me: Fried food. I grew up in a house where fried food was served with nearly every meal (which probably explains my size now) but the amount of fat in the oil and the carbohydrates in the batter is starting to get to me. I feel giddy every time I bite into a delicious, savory morsel of sauce-covered chicken at Buffalo Wild Wings. It’s so wonderful how the texture of the meat is complemented by the crunchiness of the fried coating… nom nom nom!

But I have to seriously limit my intake of fried food if I want to be healthier. That means not so many trips to OKC’s finest secret chicken trailer, Bobo’s Chicken:

Bobo's Chicken: Not only is everything fried, it is drenched in honey!

Wow this is already hard!

Seriously, this will be harder for me than any of my other mid-year resolutions. I will be tempted at every turn to eat something fried. But 9 times out of 10 there is a grilled alternative just waiting for me to ingest, so I’ll gravitate toward that, with the help of my loved ones.

Another change will be seriously limiting red meat intake. I won’t go into all the pros and cons of red meat, but with poultry, fish, and soy being better alternatives I don’t need to have red meat and the fattiness that usually accompanies it. So instead of slabs of pork in my Thai dish, I’ll opt for chicken, fish, or tofu.

nom nom nom

I’m already kicking tail on soda and sweets, so I just need to focus on the above things and I’ll be doing fine. With all this plus my running, it’ll just be a matter of time before I look and feel like a completely different person.

Hey look, I wrote a new song: Reaching

Here’s a little something I whipped up tonight. I was in a weird meloncholy-funky mood and needed to channel it into music. This song was done on an M-Audio Oxygen 61 controller connected to GarageBand. It’s not high tech but I’m still learning so cut me some slack. ;p

Play Reaching:

View the track on Alonetone.com

Fun with Ruby and OS X Text-to-Speech

I was playing with the Mac OS X text-to-speech functionality the other day after watching Wall-E. Silly, I know. For those who don’t know, OS X comes with a command-line utility “say” that will speak any text you send to it, with an optional voice. So why not utilize the power of Ruby (or really any language or script) to take advantage of it?

So I wrote a small script, which you can see here:

I use Ruby to create a say method, which opens a temporary file, writes what you want said to that file, then sends that data to the say command optionally using a voice you can specify. Why not just do `cat /usr/bin/say “My text here”`? The reason for that is because I want this method to be flexible and able to handle whatever text I throw at it, and just sending it as a parameter to the say command limits what I can do without screwing up the syntax.

So then I call the say command a couple of different ways. The first call is the ding_dong method, which I use to emulate the bells of a clock, using the “Bells” voice. Then I just have it say the time from the echo_date method, which I have just telling me the current hour (although you can alter strftime to whatever you wish).

I then added this to cron so it will run the command every hour on the hour when I’m sitting at the computer:

0 8,9,10,11,12,13,14,15,16,17,18 * * * /Users/tim/bin/clock

I’m sure it will get annoying after a couple of days, but it is a neat little trick.

A Hard Decision to Make

Since late 2006 I’ve been among the millions of people who play World of Warcraft, the online game from Blizzard. It is an immersive game pitting you with and against people from all around the world in a grind to get to the highest level and obtain the coolest gear for your characters. It’s highly addictive, but I honestly think that if you haven’t played the game, you can’t fully understand how addictive it really is.

You sign in and suddenly you have access to a vast landscape. Exploring all the lands around you is dangerous and will take a long time to see all the detail put into the game. It is immense and beautiful. There are two worlds to explore consisting of several continents full of quests, cool items, massively difficult bosses to slay. To get far in the game you need to have coordinated teamwork, and that requires cooperation with people.

The most important thing you encounter in the game is the people. Everywhere you go there are other real life people doing the same thing you are doing–exploring, questing, grinding, dueling, killing other player characters, and so on. You get to know people, especially if you join a guild. You make friends and spend a lot of time with each other. I’ve even had the opportunity to meet several of those people in real life. The friendships are real and they are meaningful.

So when it comes time to hang up the hat and quit the game, it is difficult. Really difficult. Even though you know that you are done with the grind and don’t want to play anymore, you have real friendships that you feel like you are abandoning. You feel like you’re turning your back on your friends. But that’s not the case. You have to realize that if you are really friends with those you’ve met online, you’ll continue to keep in touch and be friends in spite of the game.

So it wasn’t easy for me to cancel the subscription. I stopped playing hardcore in November but signed in a few times a week, and that slowly dwindled. I haven’t signed into the game in a few months now, so it is time to officially quit. Goodbye, Azeroth.

Goodbye, World of Warcraft

Geeks Writing Books

So reading this article got me thinking about the writing process of the modern author and how different it is from traditional forms of writing.

When you think of an author sitting down to write the next Great American Novel, you often think about someone sitting in front of an IBM Selectric Typewriter, a dedicated Word Processor, or even using Microsoft Word. At least I do. My mental picture is of an unkempt guy in his pajamas sipping coffee and playing the “hunt and peck” game in front of a weary typewriter. That’s just me though. But in reality with this connected age, the writing of any type of prose can get fairly involved.

The tools I’ve used for my recent book are fairly involved. Here’s a name-dropping list of what I have used so far in the process: Apple Pages, TextMate, ruby, rake, AppleScript, git, github, Twitter, FreeMind, and crontab. And that’s just the list off the top of my head.

I take notes in TextMate (a powerful text editor) and in FreeMind (mind-mapping/brain storming software), write the actual document in Pages (an awesome word processor, imho), use ruby, rake, and AppleScript to automate processes such as word counts, updating Twitter, and exporting sections to various formats, and finally push it all to a private GitHub repository using git for version control. I then use cron to schedule regular pulls of the repo to an external hard drive to keep for a backup. The only nerdier thing I can think of doing would be incorporating an off-site backup of my writing.

So that is part of my workflow for writing prose. What kind of geekishness do you incorporate into your non-geeky activities? I’d love to hear about it in the comments.

New blog for tea

So I realized I drink an inordinate amount of tea. Why not blog about it? So I’ve created a blog about tea, called The Tea Kettle. Be sure to check it out and participate. I plan on keeping it updated a LOT more than the main blog. So there. :)

Your Language Can’t Scale!

So Twitter decides to change their backend daemon processes over from Ruby to Scala, and keep Ruby on Rails for the front-end of the website. Suddenly that has people all in a flutter over scalability and how this somehow signifies the death of Ruby.

Seriously? Are people really that dense?

First off, Twitter did not move from Ruby on the backend due to scalability issues. It was mainly due to architectural issues such as better threading support and static typing more than a language’s ability to “scale”.

Frankly, saying the word scale makes me angrier by the minute. It’s not the language that has issues. Sure, certain implementations may be lacking in areas, but by far it is the developer that cannot scale. I’ve seen some scary code out there and I’ve seen some great code. If you have a fundamental understanding of the language and have made sound architectural decisions based on your requirements and the language you are working with, you will be able to scale.

And the Ruby community is far from death. Oh, it is just the opposite. Ruby is maturing into something amazing. With the stable release of Ruby 1.9.1, or use of Ruby Enterprise Edition, you see massive improvements in performance that make the speed-related complaints obsolete. And just look at the job trends for ruby-related jobs. It’s through the roof. So don’t listen to alarmists who don’t know what they are talking about, Ruby is not a fad.

Sure, Twitter switching a major component away from the language is a blow for publicity. But they still use Ruby for their front-end, and there are many other very large Ruby-driven sites that showcase the kind of power and elegance you can achieve with the language.

I’d say if anything we’re in a place where the Ruby community can say, “It’s about damn time”.

OK.rb Meeting February 12th 2009

I’m speaking at the Oklahoma Ruby User’s Group tonight, Thursday February 12th 2009 at the Edmond Public Library at 6:30pm. The first half of the meeting will be a knock-down drag-out all-out code brawl between Grant and Brian as they put their Ruby skills to the test. After that I will be discussing some really cool Ruby tools I use to make life easier for me, and how it keeps me from writing hardly any code at all.

Come check it out and enjoy some free pizza sponsored by Engine Yard! I’ll post the full slides of my presentation after the meeting.

UPDATE: The slides are now available here. They don’t make the most sense without the talk to go with it, but hey–there are pictures for you to look at.

Playing with the Kaossilator

I’ve been playing with the Kaossilator, a little synth pad from Korg. It’s a neat toy and you can hear some of my experiments on the Kaoss page.