The Poker Copilot Blog

Tracking the development of Poker Copilot, Mac OS X software for poker analysis and statistics.

Thursday, 17 December 2009

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:

   
private static void setUpSpeechRecognition() {
NSSpeechRecognizer recog = NSSpeechRecognizer.CLASS.alloc().init();
recog.setDelegate(new NSSpeechRecognizer.NSSpeechRecognizerDelegate() {
public void speechRecognizer_didRecognizeCommand(
NSSpeechRecognizer sender, NSString command) {
System.out.println("You said " + command);
}
});
NSArray commands = NSArray.CLASS.arrayWithObjects(
NSString.stringWithString("Check"),
NSString.stringWithString("Raise"),
NSString.stringWithString("Call"));
recog.setCommands(commands);
recog.setListensInForegroundOnly(false);
recog.setDisplayedCommandsTitle("Poker Copilot");
recog.startListening();
}


Now I too can have an app that responds haphazardly to voice control. Here's some evidence:

Screen shot 2009-12-17 at 9.46.17 PM.png


No comments:

 

Poker Copilot

Free 30 Day Trial

Only $69

Order risk free with our 30-day money back guarantee.

  • Poker tracking software for Mac OS X
  • Supports PokerStars, Winamax, Merge Network, Ongame Network
  • Analyses your opponents while you play
  • On-table HUD for Mac
  • Easy to use, easy to understand

Watch a demo of the major features of Poker Copilot