2015-09-19 41 views
2

我正在玩python中的Dragonfly lib。我正在使用Windows7 + python2.6。然而,當我嘗試運行演示代碼(這是從蜻蜓爲例)在python2.6上使用python蜻蜓python2.6問題

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 

我怎樣才能解決呢?

+0

上面的演示腳本是否保存爲「dragonfly.py」? –

+0

它被保存爲test.py – SKulibin

回答

1

擺脫.all。這個例子似乎已經過時了。它應該看起來像這樣:

from dragonfly import Grammar, CompoundRule 
+1

回溯(最近一次調用最後一次): 文件「test.py」,第12行,在 語法=語法(「示例語法」)#創建包含命令規則的語法。 文件「d:\ server \ usr \ local \ python \ lib \ site-packages \ dragonfly-0.6.6b1-py2.6.egg \ dragonfly \ grammar \ grammar_base.py」,第81行,在__init__中 self._engine = get_engine() get_engine中的第86行的文件「d:\ server \ usr \ local \ python \ lib \ site-packages \ dragonfly-0.6.6b1-py2.6.egg \ dragonfly \ engines \ __ init__.py」 raise EngineError(「沒有找到可用的引擎」) dragonfly.engines.base.engine.EngineError:沒有找到可用的引擎 – SKulibin

+0

「從蜻蜓導入語法,複合規則」後出現此錯誤 – SKulibin

+0

您是否嘗試運行此腳本直? 「python test.py」?這不是這些腳本如何運行的。你需要natlink,當你的語音識別系統加載時,它會加載宏。這裏的方向應該有很大的幫助:http://qh.antenna.nl/unimacro/installation/installation.html - 你不需要啓用unimacro或vocola,只需獲得natlink設置 –