我正在使用 wsr 做一个带有 Dragon fly 的程序,它必须分析一个单词,任何匹配该单词的语音都应该输出“是的,它匹配”
如果我说“czechoslovakia”,那么即使对于这个世界上所有类似的匹配,它也必须打印为 true,比如“circle slovakia, cat on slavia,seko vakia...”
我应该使用什么具体方法?
我的程序
from dragonfly.all import *
import pythoncom
import time
# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
spec = "czechoslovakia|circle slovalia|sceko bakia|cat on ania" # 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()
time.sleep(.1)