I have already coded using the System.Speech.Recognition namespace and use a XML SRGS file for grammer and the SpeechRecognitionEngine.
I want to be able to lead the
A simpler alternative is to run the existing training UI with your own training text. The automation-compatible APIs (Microsoft Speech Object Library, aka SpeechLib) expose IspRecognizer::DisplayUI, and you can call that with your own training text.
The training text needs to be a double-null terminated string, also known as a multistring. Here's some code that converts a string array to a multistring:
static string StringArrayToMultiString(
ICollection stringArray
)
{
StringBuilder multiString = new StringBuilder();
if (stringArray != null)
{
foreach (string s in stringArray)
{
multiString.Append(s);
multiString.Append('\0');
}
}
return multiString.ToString();
}
Then, to actually call DisplayUI, you would do something like this:
static void RunTraining(string[] TrainingText)
{
SpSharedRecoContext RC = new SpSharedRecoContext();
string Title = "My App's Additional Training";
ISpeechRecognizer spRecog = RC.Recognizer;
spRecog.DisplayUI(hWnd, Title, SpeechLib.SpeechUserTraining, StringArrayToMultiString(TrainingText);
}