2

我正在使用 python 中的蜻蜓库。我正在使用 Windows7 + python2.6。但是,当我尝试运行演示代码时(这是 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.

我收到以下错误:

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

我该如何解决?

4

1 回答 1

1

摆脱.all. 这个例子似乎已经过时了。它应该如下所示:

from dragonfly import Grammar, CompoundRule
于 2015-09-20T15:00:53.137 回答