Hi,
I'm developing a System.Speech application (under SAPI 5.3 on Vista SP1) which, among other things, includes a search facility to let me retrieve a list of items. I use the Alternates list that comes back in the RecognitionResult object to get a list of matches, ordered by probability
I use SubsetMatchingMode.OrderedSubset when creating my list of alternatives, so that users can say just a couple of words from the item name rather than the exact name. The item names are things like movie & song titles.
It works quite well, but I've run into a strange problem: there seems to be an internal limit on how many simultaneous choices can be loaded into a grammar. The limit for my application is between 16,300 and 16,370 items (close enough to 16384 to make me suspicious).
Specifically, if I load a list of 16,300 items, everything works fine. A list of 16,370 items doesn't work: no failure message is generated, the grammar builds fine, the speech engine initialises fine, my code continues to run, but no recognition of any kind (of this or any other grammars I have loaded) will take place. In addition, the CPU level stays around 50% (on my dual core system), with the thread running the speech code showing as constantly busy.
It took me a while to narrow down the size to this range, since it takes a few minutes to load the full grammar even when things are working correctly. What I've discovered is:
- The limit is independent of the content of the choices I present; seems related to the total quantity rather than what they are
- Splitting the single grammar into multiple smaller grammars of, say, 1000 choices each didn't correct the problem
- There doesn't seem to be an obvious way to detect when the speech engine is finished its background initialisation, and actually ready for action. It can often take 20-30 seconds even after the grammar has been loaded before the first phrase will be successfully recognised (when things are working correctly, that is).
The docs don't mention any restrictions, so I suspect this may be a bug or undocumented limitation of SAPI 5.3.
Has anyone else run into a similar limit, and are there any workarounds? My total selection set could be as high as 50,000 items.
Here's some sample code showing how I build the FIND grammar:
void LoadItemGrammar(string itemlist[])
{
Choices items = new Choices();
for (int i = 0; i < itemlist.Length; i++)
{
GrammarBuilder itemresultValueBuilder = new itemlist[i], SubsetMatchingMode.OrderedSubset);
items.Add(itemresultValueBuilder);
}
SemanticResultKey ItemChoiceResultKey = new SemanticResultKey("WhichSongTitle", items);
GrammarBuilder ItemChoiceBuilder = new GrammarBuilder(ItemChoiceResultKey);
GrammarBuilder makeBackgroundBuilderItem = new GrammarBuilder();
makeBackgroundBuilderItem.Append("Find Item");
makeBackgroundBuilderItem.Append(ItemChoiceBuilder);
Grammar gram = new Grammar(makeBackgroundBuilderItem);
__SR.LoadGrammarAsync(gram);
}
Later, I activate it using a call to __SR.RecognizeAsync(RecognizeMode.Single);
Eddy