Redirecting all input from Dragon NaturallySpeaking to Python? (Using Natlink)

I am currently writing an AI program that receives input from Dragon NaturallySpeaking (using Natlink), processes it, and returns speech output. I was able to come up with a GrammarBase receiver that captures all the data from Dragon and sends it to my parser.

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() 

This code works as expected, but there are a few problems:

  • The dragon processes the input data before sending it to my program. For example, if I said “Open Google Chrome”, it will open Google Chrome and send the input to Python. Is there a way to send input to Python without first processing it?

  • When I call waitForSpeech (), a window appears saying that the Python interpreter is awaiting input. Is it possible (for aesthetics and convenience) to prevent the message box from appearing and instead to stop the process of collecting speech after a significant pause from the user?

Thanks!

+6
source share
1 answer

As for your first question, it turns out that DNS uses "Open ..." Utterance as part of the internal command processing process. This means that DNS solves speech and executes the command path before natlink has a chance. The only way around this is to change the statement from “Open ...” to “Trigger ...” in your natlink grammar (or to another statement that DNS does not use besides “Trigger”).

Some natlink developers go to the speech computer. There you can get the best answers.

Good luck

+3
source

Source: https://habr.com/ru/post/904791/


All Articles