Search code examples
pythonspeech-recognitionpython-dragonfly

Disable Windows Speech Recognition using Dragonfly


Is it possible to disable certain aspects of Windows Speech Recognition (WSR) when I only wish to accept specific Dragonfly commands? I am programming a (simple) voice-controlled interaction system in Python using built-in WSR and Dragonfly. WSR attempts to insert random text whenever it doesn't understand a command:

misheard command

I would like to disable this text insertion and other undesired built-ins (i.e. keywords with default WSR activity) programmatically within Python/Dragonfly, if possible. A minimal, functional example of my voice-control system is below:

from dragonfly.all import Grammar, CompoundRule
import dragonfly, time, pythoncom

hablador = dragonfly.get_engine()

class TimeRule(CompoundRule):
    spec = "what time is it"
    def _process_recognition(self, node, extras):
        hablador.speak(time.ctime()[11:16])

grammar = Grammar("example grammar")
grammar.add_rule(TimeRule())
grammar.load()

while True:
    pythoncom.PumpWaitingMessages()
    time.sleep(.1)

Solution

  • You can disable the dictation scratchpad, but not from within Python. From the Microsoft help article:

    Say "show Speech Options," say "Options," and then say "Enable dictation scratchpad."

    The commands are the same in order to disable it. As for overriding or disabling the builtins, I do not believe this is possible.