我一直在试图弄清楚如何使用 Dragonfly 模块。我查看了文档,但似乎不知道如何使用它。我只想能够识别一些短语并根据这些短语采取行动。
是的,这个例子将终止。我已经看过这个特定的例子很多了,它缺少一些关键功能。
首先是 pythoncom 没有导入。这为程序提供了一个主循环。以上
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.
while True:
pythoncom.PumpWaitingMessages()
sleep(.1)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)