// Initialization public jarvis() { recognizer = new SpeechRecognitionEngine(); dictationGrammar = new DictationGrammar(); recognizer.LoadGrammar(dictationGrammar); recognizer.SetInputToDefaultAudioDevice(); synthesizer = new SpeechSynthesizer(); lexicon = (PhraseTrie) FileOperations.FileToObject(lexPath); if (lexicon == null) { lexicon = new PhraseTrie(); } responseGraph = (PhraseGraph) FileOperations.FileToObject(resPath); if (responseGraph == null) { responseGraph = new PhraseGraph(""); } responseNode = responseGraph.getHead(); }
public static void run(PhraseGraph g) { PhraseGraph.PhraseNode currNode; String text = FileOperations.readText(path); String[] textConvos = Regex.Split(text, "\r\n\r\n"); foreach (String convo in textConvos) { currNode = g.getHead(); String[] textLines = Regex.Split(convo, "\r\n"); foreach (String line in textLines) { currNode = g.add(line, currNode); } } // Write to the lexicon file FileOperations.ObjectToFile(g, jarvis.resPath); }