user2458048
user2458048

Reputation: 114

how to disable windows speech recognition commands?

I am creating a program with python that allows you to do commands with windows speech recognition, the only problem is that i don't want speech recognition to use their default commands. Is there a way to disable this either with python or just disabling it completely. I am using pyspeech for python.

Upvotes: 1

Views: 914

Answers (2)

Steven K
Steven K

Reputation: 441

Not sure if you're still looking for the answer or not but I found it for you!

On line 66 change the code to:

_recognizer = win32com.client.Dispatch("SAPI.SpInProcRecognizer")
_recognizer.AudioInputStream = win32com.client.Dispatch("SAPI.SpMMAudioIn")

And on line 112 change the code to:

_ListenerBase = win32com.client.getevents("SAPI.SpInProcRecoContext") 

This should prevent the windows commands from running while also not showing the widget which comes up. Good luck!

Upvotes: 1

Eric Brown
Eric Brown

Reputation: 13932

Well, what you need is an in-process recognition engine, and PySpeech uses a shared recognition engine. So you'll need to modify PySpeech a bit. Change

_recognizer = win32com.client.Dispatch("SAPI.SpSharedRecognizer")

to

_recognizer = win32com.client.Dispatch("SAPI.SpInprocRecognizer")

and in startlistening(phraselist, callback), you need to attach an audio stream (via _recognizer.SetInput) and a reco engine (via _recognizer.SetRecognizer). Unfortunately, I'm not familiar enough with Python to translate the SAPI helpers SpGetDefaultTokenFromCategoryId (to get the default audio stream) and SpGetDefaultSharedRecognizerToken (to get the default reco engine) to Python.

Upvotes: 2

Related Questions