我目前正在编写一个AI程序,它接收来自Dragon NaturallySpeaking(使用Natlink)的输入,处理它,并返回语音输出.我能够拿出一个Receiver GrammarBase来捕获Dragon的所有输入并将其发送给我的解析器.
class Receiver(GrammarBase):
gramSpec = """ <start> exported = {emptyList}; """
def initialize(self):
self.load(self.gramSpec, allResults = 1)
self.activateAll()
def gotResultsObject(self, recogType, resObj):
if recogType == 'reject':
inpt, self.best_guess = [], []
else:
inpt = extract_words(resObj)
inpt = process_input(inpt) # Forms a list of possible interpretations
self.best_guess = resObj.getWords(0)
self.send_input(inpt)
def send_input(self, inpt):
send = send_to_parser(inpt) # Sends first possible interpretation to parser
try:
while True:
send.next() # Sends the next possible interpretation if the first is rejected
except …Run Code Online (Sandbox Code Playgroud) python speech-recognition speech naturallyspeaking speech-to-text