Can i use two or more Microsoft Speech Recognition engines at the same machine (with same language)?
I have task on speech recognition and i try to recognize too big grammar (2000+ words).
So, i think to divide this big grammar on two grammars. One grammar load to first engine and other-at second.
But i do not know- is this SpeechRecognitinEngine instances referenced to 2 difference speech engines or it just linked to one engine?
Here is my code:
List<String> words1 = new List<string>();
words1.Add("one");
List<String> words2 = new List<string>();
words2.Add("two");
var gr1 = MakeGrammar("gr1", words1);
var gr2 = MakeGrammar("gr2", words2);
var gr3 = MakeGrammar("gr1", words1); // create new grammar with name gr1- to check on grammar unic name exception.
MicSpeechRecEngine1.LoadGrammar(gr1); (where MicSpeechRecEngine is SpeechRecognitionEngine)
MicSpeechRecEngine2.LoadGrammar(gr2);
MicSpeechRecEngine2.LoadGrammar(gr3);
public static Grammar MakeGrammar(String name,List<String> words)
{
Choices choises = new Choices();
GrammarBuilder gb = new GrammarBuilder();
gb.Culture = new CultureInfo("en-US");
if (choises == null)
throw new NullReferenceException("choises is null!");
if (words == null)
throw new NullReferenceException("Words is null!");
choises.Add(words.ToArray());
if (gb != null)
{
//gb.Append(choises);
gb.Append(choises, 0, 10);
}
Grammar g = new Grammar(gb);
g.Name = name;
g.Priority = 0;
g.Weight = 1.0f;
g.Enabled = true;
return g;
}
This code works well- when i say -"one" - it types "one one"-from both engines.
My point is to make 2 or more engines, load two or more big grammar and if it is recognize on difference engines- get performance (and validate) recognition.
Thank you!
P.S. Thank you for responce!
Ok, i rewrite some piece of code:
var gr3 = MakeGrammar("gr3", words3);
So, at that line i create a new grammar. And i can load it to second engine.
So, gr1 will load to Engine1, gr2,g3- to Engine2.
I know,it is stupid question, but: Can be that Engine1 and Engine2 is just references to some Engine that recognize this grammars (grammars are big)? I hope that is not,because i want to create 1 to N engines at my machine, load 1 to N grammar (one big grammar to one engine) and try to recognize it. Thank you!
gr1
to both engines. Try creating completely separate grammar objects. – Chris