Example #1
0
        private void SpeechRecognizedEventHandler(object sender, SpeechRecognizedEventArgs e)
        {
            ASR_Module.ASR.RecognitionEngine.RecognizeAsyncCancel();
            string speechRecognized = e.Result.Text;

            Console.WriteLine("Speech recognized: " + speechRecognized);

            SaveResponseToDatabase(speechRecognized);

            String nextFormId = CurrentForm.Field.Filled.Execute(speechRecognized);

            NextForm = FormList.Find(form => form.Id == nextFormId);
        }
Example #2
0
 private void FormInterpretationAlgorithm(FormTag Form)
 {
     CurrentForm = Form;
     if (Form.Field != null)
     {
         Form.Field.ExecuteField();
         DisplayOptionsOnList();
     }
     else
     {
         Form.Block.Execute();
     }
 }
Example #3
0
 private void Button1_Click(object sender, EventArgs e)
 {
     CurrentForm = FormList[0];
     NextForm    = FormList[0];
     FormInterpretationAlgorithm(CurrentForm);
 }
        public List <FormTag> ParseDocument()
        {
            XmlTextReader reader = new XmlTextReader(documentPath);
            XmlNodeType   type;
            FormTag       FormTag   = null;
            String        condition = null;

            while (reader.Read())
            {
                type = reader.NodeType;
                if (type == XmlNodeType.Element)
                {
                    if (reader.Name == "form")
                    {
                        FormTag = new FormTag(reader.GetAttribute("id"));
                        FormList.Add(FormTag);
                    }
                    if (reader.Name == "field")
                    {
                        FormTag.Field = new Field(reader.GetAttribute("name"), RecognitionEngine);
                    }
                    if (reader.Name == "block")
                    {
                        FormTag.Block = new Block();
                    }
                    if (reader.Name == "prompt")
                    {
                        if (FormTag.Field != null && FormTag.Field.Prompt == null)
                        {
                            FormTag.Field.Prompt = new Prompt(reader.ReadString());
                        }
                        if (FormTag.Block != null && FormTag.Block.Prompt == null)
                        {
                            String Message = reader.ReadString();
                            FormTag.Block.Prompt = new Prompt(Message);
                        }
                    }
                    if (reader.Name == "grammar")
                    {
                        FormTag.Field.GrammarXmlFile = reader.GetAttribute("src");
                    }
                    if (reader.Name == "nomatch")
                    {
                        if (FormTag.Field != null && FormTag.Field.NoMatch == null)
                        {
                            reader.ReadToDescendant("prompt");
                            FormTag.Field.NoMatch = new Prompt(reader.ReadString());
                        }
                    }
                    if (reader.Name == "filled")
                    {
                        FormTag.Field.Filled = new Filled();
                    }
                    if (reader.Name == "if")
                    {
                        condition = reader.GetAttribute("cond").Split('\'', '\'')[1];
                    }
                    if (reader.Name == "elseif")
                    {
                        condition = reader.GetAttribute("cond").Split('\'', '\'')[1];
                    }
                    if (reader.Name == "goto")
                    {
                        FormTag.Field.Filled.ConditionsDictionary.Add(condition, reader.GetAttribute("next").Trim(new Char[] { '#' }));
                        condition = "default";
                    }
                }
            }
            return(FormList);
        }