This section describes the following classes:
- Grammar – the base grammar class.
- ConnectionGrammar – a derived class which makes it very easy to maintain a COM connections while the target application is in the foreground.
Grammar class for managing a set of rules.
This base grammar class takes care of the communication between Dragonfly’s object model and the backend speech recognition engine. This includes compiling rules and elements, loading them, activating and deactivating them, and unloading them. It may, depending on the engine, also include receiving recognition results and dispatching them to the appropriate rule.
- name – name of this grammar
- description (str, default: None) – description for this grammar
- context (Context, default: None) – context within which to be active. If None, the grammar will always be active.
Start of phrase callback.
This method is called when the speech recognition engine detects that the user has begun to speak a phrase.
Start of phrase callback.
This usually the method which should be overridden to give derived grammar classes custom behavior.
This method is called when the speech recognition engine detects that the user has begun to speak a phrase. This method is only called when this grammar’s context does match positively. It is called by the Grammar.process_begin method.
Enter context callback.
This method is called when a phrase-start has been detected. It is only called if this grammar’s context previously did not match but now does match positively.
Exit context callback.
This method is called when a phrase-start has been detected. It is only called if this grammar’s context previously did match but now doesn’t match positively anymore.
Grammar class for maintaining a COM connection well within a given context. This is useful for controlling applications through COM while they are in the foreground. This grammar class will take care of dispatching the correct COM interface when the application comes to the foreground, and releasing it when the application is no longer there.
- name – name of this grammar.
- description – description for this grammar.
- context – context within which to maintain the COM connection.
- app_name – COM name to dispatch.
Method called immediately after entering this instance’s context and successfully setting up its connection.
By default this method doesn’t do anything. This method should be overridden by derived classes if they need to synchronize some internal state with the application. The COM connection is available through the self.application attribute.
Method called immediately after exiting this instance’s context and disconnecting from the application.
By default this method doesn’t do anything. This method should be overridden by derived classes if they need to clean up after disconnection.