How do I recognize with a multi-grammar context?

Last reviewed: 7/15/2011

HOW Article ID: H071108

The information in this article applies to:

  • Developer Workbench 2011
  • GrammarKit 4
  • SpeechKit 7

Summary

Chant Developer Workbench 2011, GrammarKit 4, and SpeechKit 7 provide support for a new speech resource type CSRContext that serves as a container object for one or more grammars.

More Information

The CSRContext resource provides a way to combine two or more grammars to be compiled and loaded together when activated. This is required in cases where grammar rules are exported by one grammar and imported by another.

You can precompile a CSRContext resource with GrammarKit and presist the binary to a file. You can define, enable, and disable the compiled binary a CSRNativeGrammarVocab resource with SpeechKit.

Testing multi-grammar context with Chant Developer Workbench

Chant Developer Workbench 2011 introduces support for a new document type: Speech Recognition Context. The editor for this document type is XML-based and provides a way to define and test one or more command, grammar, and dictation vocabularies. It provides a way to test dynamic grammars by defining phrase lists that are set programmatically at runtime.

A speech recognition context is a runtime object comprised of one or more vocabulary resources from which to recognize speech. Some recognizers load context binary instead of grammar binary for runtime efficiency and to support importing and exporting rules across grammars. The steps to create a context with Chant GrammarKit are as follows:

  1. Select the File->New->Speech Recognition Context menu item or click the New Standard toolbar button and select Speech Recognition Context to create one in a document window.
  2. Select the Speech->Create Context... menu item, click the Create Context Speech toolbar button and select the speech engine API for which this context is based, or enter <recocontext and follow the intelliprompt suggestions will prompt you for the attribute in the declaration.
  3. Save your new context to a file by selecting the File->Save menu item or click the Save Standard toolbar button. You are prompted to confirm the file name.

A context consists of one or more vocabulary resource elements. You must add at least one valid vocabulary resource element to a context.

ElementChild ElementsAttributeDescription
recocontextcsrcontext
csrgrammarvocab
csrnativegrammarvocab
csrcommandvocab
csrremotevocab
apiThe speech recognition engine API used to compile and activate the context.
csrcontextcsrgrammarvocabsyntaxThe grammar syntax of the context grammars.
csrcommandvocabcsrvocabphrasenameThe name of the command vocabulary.
csrdictationvocabnameThe name of recognizer's dictation vocabulary.
csrgrammarvocabcsrvocablistname
syntax
compileroption
The file name of the grammar vocabulary.
The grammar syntax.
Grammar compiler option used when compiling grammar.
csrnativegrammarvocabcsrvocablistname
syntax
activatefield
startfield
stopfield
The file name of the grammar binary.
The grammar syntax.
The VoCon 1-shot (2-pass) activate field.
The VoCon 1-shot (2-pass) start field.
The VoCon 1-shot (2-pass) stop field.
csrvocablistcsrvocabphrasenameThe name of the rule for this list.
csrvocabphraseCommand vocabulary or list phrase text.
csrremotevocabVoCon Hybrid NMAS query.

Compiling multi-grammar context with GrammarKit

The GrammarKit 4 CompileResource2 method is for compiling CSRContext resources. CSRContext resources enable VoCon 3 and later grammars that import/export rules to be compiled under the same context.

If compiled output is to be saved, you must specify the type of result object format needed.

The following example illustrates compiling grammars.


private Chant.GrammarKit.NChantGM NChantGM1;
// Instantiate NChantGM object
NChantGM1 = new NChantGM(this);
NChantGM1.SetNumberProperty(ChantNumberProperty.CNPEngineAPI, (int)ChantEngineAPI.CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
NChantGM1.SetStringProperty(ChantStringProperty.CSPEnginePath, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
NChantGM1.SetStringProperty(ChantStringProperty.CSPCLCModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//NChantGM1.SetStringProperty(ChantStringProperty.CSPDDG2PModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
int contextID = NChantGM1.DefineResource(ChantSpeechResource.CSRContext, "mycontext", ChantGrammarSyntax.CGSVoConBNF2);

// Define Grammars
int vocab1ID = NChantGM1.DefineResource(ChantSpeechResource.CSRGrammarVocab, "myvocab1.bnf", ChantGrammarSyntax.CGSVoConBNF2);
int vocab2ID = NChantGM1.DefineResource(ChantSpeechResource.CSRGrammarVocab, "myvocab2.bnf", ChantGrammarSyntax.CGSVoConBNF2);

// Add grammars to context
NChantGM1.AddResource(ChantSpeechResource.CSRContext, contextID, vocab1ID);
NChantGM1.AddResource(ChantSpeechResource.CSRContext, contextID, vocab2ID);

// Compile a grammar resource
NChantGM1.CompileResource2(ChantSpeechResource.CSRContext, contextID);
// Compile a grammar resource and save results to file
NChantGM1.CompileResource2(ChantSpeechResource.CSRContext, contextID, "mycontext.dat", ChantCompileResult.CCRFile, 0, ChantCompileOption.CCPAsynchronous);
    

CChantGM* m_pChantGM;  // ChantGM object
// Instantiate ChantGM object
m_pChantGM = new CChantGM();
m_pChantGM->SetNumberProperty(CNPEngineAPI, CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
m_pChantGM->SetStringProperty(CSPEnginePath, L"C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
m_pChantGM->SetStringProperty(CSPCLCModel, L"C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//m_pChantGM->SetStringProperty(CSPDDG2PModel, L"C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
int contextID = pChantGM->DefineResource(CSRContext, L"mycontext", CGSVoConBNF2);

// Define Grammars
int vocab1ID = pChantGM->DefineResource(CSRGrammarVocab, L"myvocab1.bnf", CGSVoConBNF2);
int vocab2ID = pChantGM->DefineResource(CSRGrammarVocab, L"myvocab2.bnf", CGSVoConBNF2);

// Add grammars to context
pChantGM->AddResource(CSRContext, contextID, vocab1ID);
pChantGM->AddResource(CSRContext, contextID, vocab2ID);

// Compile a grammar resource
pChantGM->CompileResource2(CSRContext, contextID);
// Compile a grammar resource and save results to file
pChantGM->CompileResource2(CSRContext, contextID, L"mycontext.dat", CCRFile, 0, CCPAsynchronous);
    

CChantGM* ChantGM1;  // ChantGM object
// Instantiate ChantGM object
ChantGM1 = new CChantGM();
ChantGM1->SetNumberProperty(CNPEngineAPI, CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
ChantGM1->SetStringProperty(CSPEnginePath, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
ChantGM1->SetStringProperty(CSPCLCModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//ChantGM1->SetStringProperty(CSPDDG2PModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
int contextID = ChantGM1->DefineResource(CSRContext, "mycontext", CGSVoConBNF2);

// Define Grammars
int vocab1ID = ChantGM1->DefineResource(CSRGrammarVocab, "myvocab1.bnf", CGSVoConBNF2);
int vocab2ID = ChantGM1->DefineResource(CSRGrammarVocab, "myvocab2.bnf", CGSVoConBNF2);

// Add grammars to context
ChantGM1->AddResource(CSRContext, contextID, vocab1ID);
ChantGM1->AddResource(CSRContext, contextID, vocab2ID);

// Compile a grammar resource
ChantGM1->CompileResource2(CSRContext, contextID);
// Compile a grammar resource and save results to file
ChantGM1->CompileResource2(CSRContext, contextID, "mycontext.dat", CCRFile, 0, CCPAsynchronous);
    

var ChantGM1: TChantGM;
contextID: Integer;
vocab1ID: Integer;
vocab2ID: Integer;
// Instantiate ChantGM object
ChantGM1 := TChantGM.Create();
ChantGM1.SetNumberProperty(CNPEngineAPI, CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
ChantGM1.SetStringProperty(CSPEnginePath, 'C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls');
// Win32 - Set the file name of CLC model
ChantGM1.SetStringProperty(CSPCLCModel, 'C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat');
// Win32 - Or set the file name of DDG2P model
//ChantGM1.SetStringProperty(CSPDDG2PModel, 'C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat');

// Define Context
contextID := ChantGM1.DefineResource(CSRContext, 'mycontext', CGSVoConBNF2);

// Define Grammars
vocab1ID := ChantGM1.DefineResource(CSRGrammarVocab, "myvocab1.bnf", CGSVoConBNF2);
vocab2ID := ChantGM1.DefineResource(CSRGrammarVocab, "myvocab2.bnf", CGSVoConBNF2);

// Add grammars to context
ChantGM1.AddResource(CSRContext, contextID, vocab1ID);
ChantGM1.AddResource(CSRContext, contextID, vocab2ID);

// Compile a grammar resource
ChantGM1.CompileResource2(CSRContext, contextID);
// Compile a grammar resource and save results to file
ChantGM1.CompileResource2(CSRContext, contextID, 'mycontext.dat', CCRFile, 0, CCPAsynchronous);
    

private JChantGM JChantGM1;
// Create ChantGM object
JChantGM1 = new JChantGM();
JChantGM1.setNumberProperty(ChantNumberProperty.CNPEngineAPI, ChantEngineAPI.CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
JChantGM1.setStringProperty(ChantStringProperty.CSPEnginePath, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
JChantGM1.setStringProperty(ChantStringProperty.CSPCLCModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//JChantGM1.setStringProperty(ChantStringProperty.CSPDDG2PModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
int contextID = JChantGM1.defineResource(ChantSpeechResource.CSRContext, "mycontext", ChantGrammarSyntax.CGSVoConBNF2);

// Define Grammars
int vocab1ID = JChantGM1.defineResource(ChantSpeechResource.CSRContext, "myvocab1.bnf", ChantGrammarSyntax.CGSVoConBNF2);
int vocab2ID = JChantGM1.defineResource(ChantSpeechResource.CSRContext, "myvocab2.bnf", ChantGrammarSyntax.CGSVoConBNF2);

// Add grammars to context
JChantGM1.addResource(ChantSpeechResource.CSRContext, contextID, vocab1ID);
JChantGM1.addResource(ChantSpeechResource.CSRContext, contextID, vocab2ID);

// Compile a grammar resource
JChantGM1.compileResource2(ChantSpeechResource.CSRContext, contextID);
// Compile a grammar resource and save results to file
JChantGM1.compileResource2(ChantSpeechResource.CSRContext, contextID, "mycontext.dat", ChantCompileResult.CCRFile, 0, ChantCompileOption.CCPAsynchronous);
    

WChantGM1.SetNumberProperty(CNPEngineAPI, CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
WChantGM1.SetStringProperty(CSPEnginePath, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
WChantGM1.SetStringProperty(CSPCLCModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//WChantGM1.SetStringProperty(CSPDDG2PModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
var contextID = WChantGM1.DefineResource(CSRContext, "mycontext", CGSVoConBNF2);

// Define Grammars
var vocab1ID = WChantGM1.DefineResource(CSRGrammarVocab, "myvocab1.bnf", CGSVoConBNF2);
var vocab2ID = WChantGM1.DefineResource(CSRGrammarVocab, "myvocab2.bnf", CGSVoConBNF2);

// Add grammars to context
WChantGM1.AddResource(CSRContext, contextID, vocab1ID);
WChantGM1.AddResource(CSRContext, contextID, vocab2ID);

// Compile a grammar resource
WChantGM1.CompileResource2(CSRContext, contextID);
// Compile a grammar resource and save results to file
WChantGM1.CompileResource2(CSRContext, contextID, "mycontext.dat", CCRFile, 0, CCPAsynchronous);
    

Dim WithEvents XChantGM1 As XChantGM
Dim contextID AS Integer
Dim vocab1ID AS Integer
Dim vocab2ID AS Integer
XChantGM1.SetNumberProperty CNPEngineAPI, CEVoCon4
' Win32 - Set the path to the VoCon runtime libraries
XChantGM1.SetStringProperty CSPEnginePath, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\bin\winx86rls"
' Win32 - Set the file name of CLC model
XChantGM1.SetStringProperty ChantStringProperty.CSPCLCModel, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\models\clc_enu_cfg3_v1_0_0.dat"
' Win32 - Or set the file name of DDG2P model
'XChantGM1.SetStringProperty ChantStringProperty.CSPDDG2PModel, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\models\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat"

' Define Context
contextID = XChantGM1.DefineResource(CSRContext, "mycontext", CGSVoConBNF2)

' Define Grammars
vocab1ID = XChantGM1.DefineResource(CSRGrammarVocab, "myvocab1.bnf", CGSVoConBNF2)
vocab2ID = XChantGM1.DefineResource(CSRGrammarVocab, "myvocab2.bnf", CGSVoConBNF2)

' Add grammars to context
XChantGM1.AddResource CSRContext, contextID, vocab1ID
XChantGM1.AddResource CSRContext, contextID, vocab2ID

' Compile a grammar resource
XChantGM1.CompileResource CSRContext, contextID
' Compile a grammar resource and save results to file
XChantGM1.CompileResource CSRContext, contextID, "mycontext.dat", CCRFile, 0, CCPAsynchronous
    

Dim WithEvents NChantGM1 As NChantGM
' Instantiate ChantGM object
NChantGM1 = New NChantGM(Me)
NChantGM1.SetNumberProperty(ChantNumberProperty.CNPEngineAPI, ChantEngineAPI.CEVoCon4)
' Win32 - Set the path to the VoCon runtime libraries
NChantGM1.SetStringProperty(ChantStringProperty.CSPEnginePath, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\bin\winx86rls")
' Win32 - Set the file name of CLC model
NChantGM1.SetStringProperty(ChantStringProperty.CSPCLCModel, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\models\clc_enu_cfg3_v1_0_0.dat")
' Win32 - Or set the file name of DDG2P model
'NChantGM1.SetStringProperty(ChantStringProperty.CSPDDG2PModel, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\models\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat")

' Define Context
int contextID = NChantGM1.DefineResource(ChantSpeechResource.CSRContext, "mycontext", ChantGrammarSyntax.CGSVoConBNF2)

' Define Grammars
int vocab1ID = NChantGM1.DefineResource(ChantSpeechResource.CSRGrammarVocab, "myvocab1.bnf", ChantGrammarSyntax.CGSVoConBNF2)
int vocab2ID = NChantGM1.DefineResource(ChantSpeechResource.CSRGrammarVocab, "myvocab2.bnf", ChantGrammarSyntax.CGSVoConBNF2)

' Add grammars to context
NChantGM1.AddResource(ChantSpeechResource.CSRContext, contextID, vocab1ID)
NChantGM1.AddResource(ChantSpeechResource.CSRContext, contextID, vocab2ID)

' Compile a grammar resource
NChantGM1.CompileResource2(ChantSpeechResource.CSRContext, contextID)
' Compile a grammar resource and save results to file
NChantGM1.CompileResource2(ChantSpeechResource.CSRContext, contextID, "mycontext.dat", ChantCompileResult.CCRFile, 0, ChantCompileOption.CCPAsynchronous)
    

Recognizing with multi-grammar context with SpeechKit

The SpeechKit 7 DefineResource method supports the CSRContext resource. CSRContext resources enable VoCon 3 and later grammars that import/export rules to be compiled under the same context.

To recognize with a multi-grammar context, define a CSRContext resource and add the grammar to the context.

The following example illustrates recognizing with multi-grammar context:


private Chant.GrammarKit.NChantSR NChantSR1;
private NChantGrammar _NChantGrammar = null;
// Instantiate NChantSR object
NChantSR1 = new NChantSR(this);
NChantSR1.SetNumberProperty(ChantNumberProperty.CNPEngineAPI, (int)ChantEngineAPI.CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
NChantSR1.SetStringProperty(ChantStringProperty.CSPEnginePath, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
NChantSR1.SetStringProperty(ChantStringProperty.CSPCLCModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//NChantSR1.SetStringProperty(ChantStringProperty.CSPDDG2PModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
int contextID = NChantSR1.DefineResource(ChantSpeechResource.CSRContext, "mycontext", ChantResourceFunction.CRFNone, null, null, (int)ChantGrammarSyntax.CGSVoConBNF2, 0);

// Add grammars to context
NChantSR1.AddResource(ChantSpeechResource.CSRContext, contextID, "myvocab1.bnf");
NChantSR1.AddResource(ChantSpeechResource.CSRContext, contextID, "myvocab2.bnf");

// Load and enable context
NChantSR1.EnableResource(ChantSpeechResource.CSRContext, contextID);

// Disable it
NChantSR1.DisableResource(ChantSpeechResource.CSRContext, contextID);
    

CChantSR* m_pChantSR;  // ChantSR object
CChantGrammar* m_pChantGrammar;  // ChantGrammar object
// Instantiate ChantSR object
m_pChantSR = new CChantSR();
m_pChantSR->SetNumberProperty(CNPEngineAPI, CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
m_pChantSR->SetStringProperty(CSPEnginePath, L"C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
m_pChantSR->SetStringProperty(CSPCLCModel, L"C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//m_pChantSR->SetStringProperty(CSPDDG2PModel, L"C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
int contextID = pChantSR->DefineResource(CSRContext, L"mycontext", CRFNone, NULL, NULL, CGSVoConBNF2, 0);

// Add grammars to context
pChantSR->AddResource(CSRContext, contextID, L"myvocab1.bnf");
pChantSR->AddResource(CSRContext, contextID, L"myvocab2.bnf");

// Load and enable context
pChantSR->EnableResource(CSRContext, contextID);

// Disable it
pChantSR->DisableResource(CSRContext, contextID);
    

CChantSR* ChantSR1;  // ChantSR object
CChantGrammar* ChantGrammar1;  // ChantGrammar object
// Instantiate ChantSR object
ChantSR1 = new CChantSR();
ChantSR1->SetNumberProperty(CNPEngineAPI, CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
ChantSR1->SetStringProperty(CSPEnginePath, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
ChantSR1->SetStringProperty(CSPCLCModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//ChantSR1->SetStringProperty(CSPDDG2PModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
int contextID = ChantSR1->DefineResource(CSRContext, "mycontext", CRFNone, NULL, NULL, CGSVoConBNF2, 0);

// Add grammars to context
ChantSR1->AddResource(CSRContext, contextID, "myvocab1.bnf");
ChantSR1->AddResource(CSRContext, contextID, "myvocab2.bnf");

// Load and enable context
ChantSR1->EnableResource(CSRContext, contextID);

// Disable it
ChantSR1->DisableResource(CSRContext, contextID);
    

var ChantSR1: TChantSR;
contextID: Integer;
vocab1ID: Integer;
vocab2ID: Integer;
// Instantiate ChantSR object
ChantSR1 := TChantSR.Create();
ChantSR1.SetNumberProperty(CNPEngineAPI, CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
ChantSR1.SetStringProperty(CSPEnginePath, 'C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls');
// Win32 - Set the file name of CLC model
ChantSR1.SetStringProperty(CSPCLCModel, 'C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat');
// Win32 - Or set the file name of DDG2P model
//ChantSR1.SetStringProperty(CSPDDG2PModel, 'C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat');

// Define Context
contextID := ChantSR1.DefineResource(CSRContext, 'mycontext', CRFNone, nil, nil, CGSVoConBNF2, 0);

// Add grammars to context
ChantSR1.AddResource(CSRContext, contextID, "myvocab1.bnf");
ChantSR1.AddResource(CSRContext, contextID, "myvocab2.bnf");

// Load and enable context
ChantSR1.EnableResource(CSRContext, contextID);

// Disable it
ChantSR1.DisableResource(CSRContext, contextID);
    

private JChantSR JChantSR1;
// Create ChantSR object
JChantSR1 = new JChantSR();
JChantSR1.setNumberProperty(ChantNumberProperty.CNPEngineAPI, ChantEngineAPI.CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
JChantSR1.setStringProperty(ChantStringProperty.CSPEnginePath, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
JChantSR1.setStringProperty(ChantStringProperty.CSPCLCModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//JChantSR1.setStringProperty(ChantStringProperty.CSPDDG2PModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
int contextID = JChantSR1.defineResource(ChantSpeechResource.CSRContext, "mycontext", ChantResourceFunction.CRFNone, null, null, ChantGrammarSyntax.CGSVoConBNF2, 0);

// Add grammars to context
JChantSR1.addResource(ChantSpeechResource.CSRContext, contextID, "myvocab1.bnf");
JChantSR1.addResource(ChantSpeechResource.CSRContext, contextID, "myvocab2.bnf");

// Load and enable context
JChantSR1.enableResource(ChantSpeechResource.CSRContext, contextID);

// Disable it
JChantSR1.disableResource(ChantSpeechResource.CSRContext, contextID);
    

WChantSR1.SetNumberProperty(CNPEngineAPI, CEVoCon4);
// Win32 - Set the path to the VoCon runtime libraries
WChantSR1.SetStringProperty(CSPEnginePath, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\bin\\winx86rls");
// Win32 - Set the file name of CLC model
WChantSR1.SetStringProperty(CSPCLCModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\clc_enu_cfg3_v1_0_0.dat");
// Win32 - Or set the file name of DDG2P model
//WChantSR1.SetStringProperty(CSPDDG2PModel, "C:\\Program Files\\Nuance\\vocon3200\\EDS_v4_1\\models\\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat");

// Define Context
var contextID = WChantSR1.DefineResource(CSRContext, "mycontext", CRFNone, 0, 0, CGSVoConBNF2, 0);

// Add grammars to context
WChantSR1.AddResource(CSRContext, contextID, "myvocab1.bnf");
WChantSR1.AddResource(CSRContext, contextID, "myvocab2.bnf");

// Load and enable context
WChantSR1.EnableResource(CSRContext, contextID);

// Disable it
WChantSR1.DisableResource(CSRContext, contextID);
    

Dim WithEvents XChantSR1 As XChantSR
Dim contextID AS Integer
Dim vocab1ID AS Integer
Dim vocab2ID AS Integer
XChantSR1.SetNumberProperty CNPEngineAPI, CEVoCon4
' Win32 - Set the path to the VoCon runtime libraries
XChantSR1.SetStringProperty CSPEnginePath, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\bin\winx86rls"
' Win32 - Set the file name of CLC model
XChantSR1.SetStringProperty ChantStringProperty.CSPCLCModel, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\models\clc_enu_cfg3_v1_0_0.dat"
' Win32 - Or set the file name of DDG2P model
'XChantSR1.SetStringProperty ChantStringProperty.CSPDDG2PModel, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\models\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat"

' Define Context
contextID = XChantSR1.DefineResource(CSRContext, "mycontext", CRFNone, 0, 0, CGSVoConBNF2, 0)

' Add grammars to context
XChantSR1.AddResource CSRContext, contextID, "myvocab1.bnf"
XChantSR1.AddResource CSRContext, contextID, "myvocab2.bnf"

' Load and enable context
XChantSR1.EnableResource CSRContext, contextID

' Disable it
XChantSR1.DisableResource CSRContext, contextID
    

Dim WithEvents NChantSR1 As NChantSR
' Instantiate ChantSR object
NChantSR1 = New NChantSR(Me)
NChantSR1.SetNumberProperty(ChantNumberProperty.CNPEngineAPI, ChantEngineAPI.CEVoCon4)
' Win32 - Set the path to the VoCon runtime libraries
NChantSR1.SetStringProperty(ChantStringProperty.CSPEnginePath, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\bin\winx86rls")
' Win32 - Set the file name of CLC model
NChantSR1.SetStringProperty(ChantStringProperty.CSPCLCModel, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\models\clc_enu_cfg3_v1_0_0.dat")
' Win32 - Or set the file name of DDG2P model
'NChantSR1.SetStringProperty(ChantStringProperty.CSPDDG2PModel, "C:\Program Files\Nuance\vocon3200\EDS_v4_1\models\ddg2p_enu_vadvde_ttsasr_large_v2_1_3.dat")

' Define Context
int contextID = NChantSR1.DefineResource(ChantSpeechResource.CSRContext, "mycontext", ChantResourceFunction.CRFNone, 0, 0, ChantGrammarSyntax.CGSVoConBNF2, 0)

' Add grammars to context
NChantSR1.AddResource(ChantSpeechResource.CSRContext, contextID, "myvocab1.bnf")
NChantSR1.AddResource(ChantSpeechResource.CSRContext, contextID, "myvocab2.bnf")

' Load and enable context
NChantSR1.EnableResource(ChantSpeechResource.CSRContext, contextID)

' Disable it
NChantSR1.DisableResource(ChantSpeechResource.CSRContext, contextID)