Created
September 15, 2019 05:37
-
-
Save drmfinlay/e2b8579e8babc6afd13a73216fc3e213 to your computer and use it in GitHub Desktop.
Natlink steak orange example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This example is related to a Natlink/DNS bug. | |
# Place this file in the Natlink user folder (MacroSystem) to use it. | |
from natlinkutils import GrammarBase | |
class NatGrammar(GrammarBase): | |
# Quotes in rule <1> seem to fix the bug where commands aren't recognised. | |
gramSpec = """ | |
<dgndictation> imported; | |
<1> = 'testing' ('an orange' | 'a steak' ) <dgndictation>; | |
<any> = <1>; | |
<sequence> exported = <any>; | |
""" | |
def initialize(self): | |
self.load(self.gramSpec) | |
self.activateAll() | |
def unload(self): | |
GrammarBase.unload(self) | |
def gotResults_1(self,words,fullResults): | |
print("Recognised grammar words '%s'" % words) | |
def gotResults_dgndictation(self,words,fullResults): | |
print("Recognised dictation words '%s'" % words) | |
# Initialize and load the grammar. | |
thisGrammar = NatGrammar() | |
thisGrammar.initialize() | |
def unload(): | |
global thisGrammar | |
if thisGrammar: thisGrammar.unload() | |
thisGrammar = None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment