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.
后面应该跟着
import time
import pythoncom
while True:
pythoncom.PumpWaitingMessages()
time.sleep(.1)
见pyspeech (python) - Transcribe mp3 files?
关于http://code.google.com/p/pyspeech/。你可能还想看看http://code.google.com/p/dragonfly/
蜻蜓示例代码在https://pythonhosted.org/dragonfly/提供代码示例时遗漏了一个片段
后面应该跟着
如前所述-http://dragonfly.googlecode.com/svn-history/r46/trunk/dragonfly/examples/dragonfly-main.py
相关问题 更多 >
编程相关推荐