This section describes the following class:
- dragonfly.grammar.rule.Rule – the base rule class
Rule class for implementing complete or partial voice-commands.
This rule class represents a voice-command or part of a voice- command. It contains a root element, which defines the language construct of this rule.
The self._log logger objects should be used in methods of derived classes for logging purposes. It is a standard logger object from the logger module in the Python standard library.
Start of phrase callback.
This method is called when the speech recognition engine detects that the user has begun to speak a phrase. It is called by the rule’s containing grammar if the grammar and this rule are active.
The default implementation of this method checks whether this rule’s context matches, and if it does this method calls dragonfly.grammar.rule.Rule._process_begin().
Start of phrase detection callback.
This is generally the method which developers should override in derived rule classes to give them custom functionality when the start of a phrase is detected.
This method is called when the speech recognition engine detects that the user has begun to speak a phrase. It is called by this rule’s dragonfly.grammar.rule.Rule.process_begin() after some context checks.
The default implementation of this method does nothing.
Start of phrase callback.
This is generally the method which developers should override in derived rule classes to change the default semantic value of a recognized rule.
This method is called to obtain the semantic value associated with a particular recognition. It could be called from another rule’s dragonfly.grammar.rule.Rule.value() if that rule references this rule. If also be called from this rule’s dragonfly.grammar.rule.Rule.process_recognition() if that method has been overridden to do so in a derived class.
The default implementation of this method returns the value of this rule’s root element.
Rule recognition callback.
This is generally the method which developers should override in derived rule classes to give them custom functionality when a top-level rule is recognized.
This method is called when the user has spoken words matching this rule’s contents. This method is called only once for each recognition, and only for the matching top-level rule.
The default implementation of this method does nothing.