Search code examples
pythonspeech-recognitiontext-to-speech

Usage of win32com.client text to speech/speech recognition in Python


So I have the text to speech part down with this, for example:

from win32com.client import constants
import win32com.client
import pythoncom
speaker = win32com.client.Dispatch("SAPI.SpVoice")
speaker.Speak("message")

But what I don't know how to do is use the above system for speech recognition (if this even has speech recognition). More Specifically, a verbal alternate to the text system

variable = string(input("Question")).

I need to use this to make a system that will parse my speech and then use present keywords in order to call different functions. Indeed, I need the voice recognition equivalent of doing this:

WORD_LIST_ONE = ('term', 'term'...)
variable = string(input("Question?"))
if variable in WORD_LIST_ONE:
    function()

So basically, what do I use to parse user speech? Also, if this systems doesn't include speech recognition, please point me to something that does.

Thanks


Solution

  • Take a look at https://stackoverflow.com/a/6351055/90236. You don't say what OS you are running on, but Windows 7 and Vista both come with complete speech recognition engines. For Microsoft's Windows Servers you can download free server speech engine, see http://www.microsoft.com/en-us/download/details.aspx?id=27226.

    There is also a Python module I've seen people mention that you might find helpful. See http://code.google.com/p/pyspeech/

    If you are using the SAPI API you are accessing the C++/COM interface to Microsoft speech. See http://msdn.microsoft.com/en-us/library/ms723627(v=vs.85).aspx.

    You may find it easier if you can access the .NET inteface (System.Speech). See http://msdn.microsoft.com/en-us/library/hh361625 and http://msdn.microsoft.com/en-us/magazine/cc163663.aspx