tkbx tkbx - 9 months ago 51
Python Question

Using Voice instead of 'raw_input' in python for Mac OS X

I'm in the process of making a Python-based personal assistant/question answerer, which, in my wildest dreams, will rival the inevitable "Siri For Mac". However, as of now, it requires you type text into an infinite loop of raw_inputs, and processes the text each time. But if this is ever to be useful to, well, people, it can't be a .py in a terminal window. As of now, I'm thinking about making it a simple .app with Platypus. But, since there is no text input on the Window app style for Platypus, I would include no GUI, and just have it all be speech-based, for input and output. Output is simple, I can just replace all 'print' lines with 'speakString' from "macspeech". But input would be the tricky part. I can only find libraries to input speech on Windows (pyspeech is EXACTLY what I need, but it's windows-based). Anyone heard of something like pyspeech for mac/universal?


I would look at Sphinx4.0 from CMU.

Sadly, it is written in Java. I think the recognition is better than what is built into my mac. I am just learning java/python so am struggling with getting the two to talk to each other.

You can interface with the mac speech engine using Appkit.NSSpeechRecognizer:

from Foundation import *

The final method is to use the google voice search. But that requires shipping a voice snippet to the "cloud".

That approach is the most accurate but takes up to 10 seconds for a reply!