Jia*_*ian 6 python speech-recognition speech naturallyspeaking speech-to-text
我目前正在编写一个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 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()
Run Code Online (Sandbox Code Playgroud)
此代码按预期工作,但有几个问题:
Dragon在将输入发送到我的程序之前处理输入.例如,如果我要说"打开谷歌浏览器",它将打开谷歌浏览器,然后将输入发送到Python.有没有办法将输入发送到Python而不先处理它?
当我调用waitForSpeech()时,会弹出一个消息框,说明Python解释器正在等待输入.是否有可能(为了美观和方便)阻止消息框显示,而是在用户显着停顿后终止语音收集过程?
谢谢!
关于你的第一个问题,事实证明 DNS 使用“Open ...”话语作为其内部命令解析过程的一部分。这意味着 DNS 在 natlink 有机会之前解析语音并执行命令方式。解决这个问题的唯一方法是在 natlink 语法中将话语从“Open ...”更改为“Trigger ...”(或者更改为除“Trigger”之外 DNS 不使用的其他话语)。
一些 natlink 开发人员常在 Speechcomputing.com 上闲逛。您可能会在那里得到更好的答复。
祝你好运!