我目前正在编写一个人工智能程序,接收来自Dragon NaturallySpeaking(使用Natlink)的输入,对其进行处理,并返回一个语音输出。我能够想出一个接收器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 StopIteration: # If all interpretations are rejected, try sending the input to Dragon
try:
recognitionMimic(parse(self.best_guess))
except MimicFailed: # If that fails too, execute all_failed
all_failed()
此代码按预期工作,但存在以下几个问题:
Dragon在将输入发送到我的程序之前对其进行处理。例如,如果我说“opengooglechrome”,它将打开googlechrome,然后将输入发送到Python。有没有一种方法可以在不进行处理的情况下将输入发送到Python?
当我调用waitForSpeech()时,会弹出一个消息框,说明Python解释器正在等待输入。是否有可能(为了美观和方便起见)阻止消息框出现,而是在用户明显停顿后终止语音收集过程?
谢谢你!在
关于你的第一个问题,DNS在内部使用“Open…”语句作为命令解析过程的一部分。这意味着DNS在natlink有机会之前解析语音并执行命令。解决这一问题的唯一方法是将natlink语法中的语句从“Open…”更改为“Trigger…”(或者改为DNS除了“Trigger”之外没有使用的其他语句)。在
一些natlink开发人员在speechcomputing.com公司. 你可能会得到更好的回应。在
祝你好运!在
相关问题 更多 >
编程相关推荐