Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. speech;
Using system. Speech. recognition;
Using system. Speech. synthesis;
Using system. Speech. audioformat;
Using system. Speech. Recognition. srgsgrammar;
Namespace voice
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}
Private void form1_load (Object sender, eventargs E)
{
// load the custom XML file
/*
speechrecognizer recognizer = new speechrecognizer ();
srgsdocument Doc = new srgsdocument ("gaarmmar. XML ");
recognizer. loadgrammar (new grammar (DOC);
*/
// example of loading in-memory sgrs syntax file
/*
speechrecognizer recognizer = new speechrecognizer ();
srgsdocument Doc = new srgsdocument ();
srgsrule command = new srgsrule ("command", new srgsoneof ("Yin Cheng is a Eldest Brother", "Yin Cheng is a second brother", "Yin Cheng is a third brother "));
Doc. rules. add (command);
Doc. root = command;
recognizer. loadgrammar (new grammar (DOC);
*/
// Example of complex syntax file Definition
Speechrecognizer recognizer = new speechrecognizer ();
Srgsdocument Doc = new srgsdocument ();
Srgsrule command = new srgsrule ("command ");
Srgsrule Rank = new srgsrule ("rank ");
Srgsitem of = new srgsitem ("");
Srgsrule suit = new srgsrule ("Suit ");
Srgsitem card = new srgsitem (New srgsruleref (rank), of, new srgsruleref (suit ));
Command. Add (card );
Rank. add (New srgsoneof ("1", "2", "3", "4", "5", "6", "7", "8 ", "9 "));
Of. setrepeat (0, 1 );
Suit. Add (New srgsoneof ("Yamada", "Yamada", "times "));
Doc. Rules. Add (command, rank, suit );
Doc. Root = command;
Recognizer. loadgrammar (new grammar (DOC ));
}
}
}
If you need source code, leave an email