2

I am playing with the Dragonfly lib in python. I am working on Windows7 + python2.6. However when I try to run demo code (which is the example from Dragonfly)

from dragonfly.all import Grammar, CompoundRule

# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
    spec = "do something computer"                  # Spoken form of command.
    def _process_recognition(self, node, extras):   # Callback when command is spoken.
        print "Voice command spoken."

# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar")                # Create a grammar to contain the command rule.
grammar.add_rule(ExampleRule())                     # Add the command rule to the grammar.
grammar.load()                                      # Load the grammar.

I receive the following error:

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from dragonfly.all import Grammar, CompoundRule
ImportError: No module named all

How can I fix it?

Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
SKulibin
  • 719
  • 1
  • 6
  • 14

1 Answers1

1

Get rid of .all. That example seems to be outdated. It should look like this:

from dragonfly import Grammar, CompoundRule
synkarius
  • 324
  • 1
  • 8
  • 1
    Traceback (most recent call last): File "test.py", line 12, in grammar = Grammar("example grammar") # Create a grammar to contain the command rule. File "d:\server\usr\local\python\lib\site-packages\dragonfly-0.6.6b1-py2.6.egg\dragonfly\grammar\grammar_base.py", line 81, in __init__ self._engine = get_engine() File "d:\server\usr\local\python\lib\site-packages\dragonfly-0.6.6b1-py2.6.egg\dragonfly\engines\__init__.py", line 86, in get_engine raise EngineError("No usable engines found.") dragonfly.engines.base.engine.EngineError: No usable engines found – SKulibin Sep 20 '15 at 15:31
  • I have got this error after "from dragonfly import Grammar, CompoundRule" – SKulibin Sep 20 '15 at 15:32
  • Did you attempt to run this script directly? "python test.py"? That's not how these scripts get run. You need natlink, which will load macros when your speech recognition system loads. The directions here should help a lot: http://qh.antenna.nl/unimacro/installation/installation.html -- you don't need to enable unimacro or vocola, just get the natlink setup – Charles J. Daniels Sep 20 '15 at 16:09
  • @CharlesJ.Daniels, actually, that's incorrect. Running the script directly should launch WSR, and then terminate since there's no `pythoncom.PumpWaitingMessages()` loop, but it shouldn't produce the new error he's describing. – synkarius Sep 20 '15 at 19:13
  • @SKulibin, are you running Dragonfly on Linux? If so, you should know, presently, Dragonfly can only use Windows Speech Recognition and Dragon NaturallySpeaking (a Windows program) as speech recognition engines. It can be run on Linux via Aenea, but that significantly complicates the setup. – synkarius Sep 20 '15 at 19:14
  • Whoops, just reread the first sentence of your question. So you're running Windows 7. Why is your Python installed in that location then? Clearly something isn't standard. – synkarius Sep 21 '15 at 01:03
  • I guess they changed something @synkarius because last I used WSR you still had to use a special macro loader. Yes, not the mechanism I mentioned about natlink or whatever, but still, the script wasn't run directly. But you're for sure right I assumed DNS. – Charles J. Daniels Sep 21 '15 at 22:23