Speech Recognition on Mac OS X in Java

When I got my first Mac, I discovered the voice-controlled Chess app. Well, sort of voice-controlled. “Pawn e2 to e4″, I would say, and my bishop would move. I don’t even enjoy chess but I was in Mac-awe, and showed anyone who would look how amazing it was that I could play voice-controlled chess.

Due to a recent e-mail conversation I got curious as to what it takes to add voice control to a Mac OS X app. I played around this evening for fun and was surprised how simple it is. My aim was to create an app that listens to basic poker commands, such as “Call”, “Fold”, and “Raise”.

With help from Google, I managed to do it in Java, via the Rococoa bridge between Cocoa and Java. Here’s pretty much the entire program, once the Rococoa boiler-plate code is removed: