私は現在、Dragon NaturallySpeaking (Natlink を使用) から入力を受け取り、それを処理し、音声出力を返す AI プログラムを作成しています。Dragon からのすべての入力をキャプチャしてパーサーに送信する Receiver GrammarBase を思いつくことができました。
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 は入力を処理してからプログラムに送信します。たとえば、「Open Google Chrome.」と言うと、Google Chrome が開き、入力が Python に送信されます。最初に処理せずに入力を Python に送信する方法はありますか?
waitForSpeech() を呼び出すと、Python インタープリターが入力を待機していることを示すメッセージ ボックスが表示されます。(美学と利便性のために) メッセージ ボックスが表示されないようにすることはできますか? 代わりに、ユーザーからの大幅な一時停止の後、音声収集プロセスを終了しますか?
ありがとうございました!