Example #1
0
        public Form1()
        {
            InitializeComponent();



            //var clt = ;

            //var vlt = clt.DisplayName;

            helper = new SpeechHelper(CultureInfo.CurrentCulture.Name);//
            //helper.SetInputCulture();
            helper.GatherConverters(typeof(Form1), this);

            //helper.OnParameterValueConvert = (p, value) =>
            //{
            //    int i;
            //    if(int.TryParse(value, out i))
            //    {
            //        return i;
            //    }
            //    return null;
            //};

            //grab some speech methods
            //helper.GatherCommands(Assembly.GetExecutingAssembly());
            helper.GatherCommands(typeof(Form1), this);


            helper.AddSimpleCommand("de-de", "abbrechen", "abc", () =>
            {
                if (helper.State == ExecutingState.ListeningForParameterValue)
                {
                    helper.Speak("ab jetzt wird wieder ausschau nach parametern gehalten");
                    helper.AbortListeningForCurrentParameterValue();
                }
                else if (helper.State == ExecutingState.ListeningForParameters)
                {
                    helper.Speak("ab jetzt werden wieder methoden überwacht");
                    helper.AbortListeningForParameters();
                }
            });

            //helper.ChangeSpeechGroup("groupKey", false)

            helper.OnBeforeSimpleCommandInvoked.Subscribe(p =>
            {
                if (checkBox1.Checked)
                {
                    helper.Speak("simpler befehlt " + p.Text + " wird ausgeführt");
                }
            });

            helper.OnAfterSimpleCommandInvoked.Subscribe(p =>
            {
                if (checkBox1.Checked)
                {
                    helper.Speak("simpler befehl " + p.Text + " wurde ausgeführt");
                }
            });

            //helper.ChangeCommand("", false);
            //helper.ChangeSimpleCommand("de-de", "abbrechen", false);

            //helper.ChangeSpeechGroup("", true);
            //helper.ChangeSimpleSpeechGroup("de-de", "abc", true);


            helper.AddSimpleCommand("de-de", "los", "", () =>
            {
                textBox1.Text += "los" + Environment.NewLine;
            });

            /*
             * helper.AddSimpleCommand("de-de", "ja", () =>
             * {
             * helper.ChangeSimpleCommand("de-de", "los", false);
             * });
             *
             * helper.AddSimpleCommand("de-de", "nein", () =>
             * {
             * helper.ChangeSimpleCommand("de-de", "los", true);
             * });
             * */

            //build the speech recognition (words)
            helper.RebuildAllCommands();

            helper.OnTextRecognized.Subscribe(p =>
            {
                listBox1.Items.Add(p.Text);
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
                //helper.Speak("ok");
            });

            helper.OnListeningParameters.Subscribe(tuple =>
            {
                textBox1.Text += tuple.RecognizedText + "(";
                if (checkBox1.Checked)
                {
                    helper.Speak("jetzt die parameter");
                }
            });

            helper.OnParameterRecognized.Subscribe(p =>
            {
                textBox1.Text += p.RecognizedParameterNameText + ": ";
                if (checkBox1.Checked)
                {
                    helper.Speak("wert für " + p.SpeechParameterInfo.Parameter.ParameterInfo.Name + " wird erwartet");
                }
            });

            helper.OnParameterFinished.Subscribe(p =>
            {
                textBox1.Text += p.SpeechParameterInfo.Value + ", ";
                if (checkBox1.Checked)
                {
                    helper.Speak("parameter " + p.SpeechParameterInfo.Parameter.ParameterInfo.Name + " fertig");
                }
            });

            helper.OnBeforeMethodInvoked.Subscribe(p =>
            {
                //p.Method.
                if (checkBox1.Checked)
                {
                    helper.Speak("methode wird ausgeführt");
                }
            });

            helper.OnLastParameterFinished.Subscribe(p =>
            {
                textBox1.Text += ")" + Environment.NewLine;
                if (checkBox1.Checked)
                {
                    helper.Speak("methode " + p.RecognizedText + " wird jetzt ausgeführt");
                }
            });


            items = new List <string>();

            var mmmMax = 11;

            for (int i = 0; i < mmmMax; i++)
            {
                items.Add("item " + (10 - i).ToString());
                listBox2.Items.Add(items[i]);

                if (i == mmmMax - 1)
                {
                    helper.AddPlainPhrase(true, items[i]);
                }
                else
                {
                    helper.AddPlainPhrase(false, items[i]);
                }
            }

            //de
            //helper.AddPlainPhrase(true, "rot","blau");

            //en
            helper.AddPlainPhrase(true, "red", "blue");

            //helper.ChangeCommand("", false);
            var test = helper.AllCommands.Commands;

            //helper.AddCommand();
        }
Example #2
0
        public Form1()
        {
            InitializeComponent();

            //var clt = ;

            //var vlt = clt.DisplayName;

            helper = new SpeechHelper(CultureInfo.CurrentCulture.Name);//
            //helper.SetInputCulture();
            helper.GatherConverters(typeof(Form1), this);

            //helper.OnParameterValueConvert = (p, value) =>
            //{
            //    int i;
            //    if(int.TryParse(value, out i))
            //    {
            //        return i;
            //    }
            //    return null;
            //};

            //grab some speech methods
            //helper.GatherCommands(Assembly.GetExecutingAssembly());
            helper.GatherCommands(typeof(Form1), this);

            helper.AddSimpleCommand("de-de", "abbrechen", "abc", () =>
            {
                if (helper.State == ExecutingState.ListeningForParameterValue)
                {
                    helper.Speak("ab jetzt wird wieder ausschau nach parametern gehalten");
                    helper.AbortListeningForCurrentParameterValue();
                }
                else if (helper.State == ExecutingState.ListeningForParameters)
                {
                    helper.Speak("ab jetzt werden wieder methoden überwacht");
                    helper.AbortListeningForParameters();

                }
            });

            //helper.ChangeSpeechGroup("groupKey", false)

            helper.OnBeforeSimpleCommandInvoked.Subscribe(p =>
            {
                if (checkBox1.Checked)
                    helper.Speak("simpler befehlt " + p.Text + " wird ausgeführt");
            });

            helper.OnAfterSimpleCommandInvoked.Subscribe(p =>
            {
                if (checkBox1.Checked)
                    helper.Speak("simpler befehl " + p.Text + " wurde ausgeführt");
            });

            //helper.ChangeCommand("", false);
            //helper.ChangeSimpleCommand("de-de", "abbrechen", false);

            //helper.ChangeSpeechGroup("", true);
            //helper.ChangeSimpleSpeechGroup("de-de", "abc", true);

            helper.AddSimpleCommand("de-de", "los", "", () =>
            {
                textBox1.Text += "los" + Environment.NewLine;

            });
            /*
               helper.AddSimpleCommand("de-de", "ja", () =>
               {
               helper.ChangeSimpleCommand("de-de", "los", false);
               });

               helper.AddSimpleCommand("de-de", "nein", () =>
               {
               helper.ChangeSimpleCommand("de-de", "los", true);
               });
            * */

            //build the speech recognition (words)
            helper.RebuildAllCommands();

            helper.OnTextRecognized.Subscribe(p =>
            {
                listBox1.Items.Add(p.Text);
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
                //helper.Speak("ok");
            });

            helper.OnListeningParameters.Subscribe(tuple =>
            {
                textBox1.Text += tuple.RecognizedText + "(";
                if (checkBox1.Checked)
                    helper.Speak("jetzt die parameter");
            });

            helper.OnParameterRecognized.Subscribe(p =>
            {
                textBox1.Text += p.RecognizedParameterNameText + ": ";
                if (checkBox1.Checked)
                    helper.Speak("wert für " + p.SpeechParameterInfo.Parameter.ParameterInfo.Name + " wird erwartet");
            });

            helper.OnParameterFinished.Subscribe(p =>
            {
                textBox1.Text += p.SpeechParameterInfo.Value + ", ";
                if (checkBox1.Checked)
                    helper.Speak("parameter " + p.SpeechParameterInfo.Parameter.ParameterInfo.Name + " fertig");
            });

            helper.OnBeforeMethodInvoked.Subscribe(p =>
            {
                //p.Method.
                if (checkBox1.Checked)
                    helper.Speak("methode wird ausgeführt");
            });

            helper.OnLastParameterFinished.Subscribe(p =>
            {
                textBox1.Text += ")" + Environment.NewLine;
                if (checkBox1.Checked)
                    helper.Speak("methode " + p.RecognizedText + " wird jetzt ausgeführt");
            });

            items = new List<string>();

            var mmmMax = 11;
            for (int i = 0; i < mmmMax; i++)
            {
                items.Add("item " + (10 - i).ToString());
                listBox2.Items.Add(items[i]);

                if (i == mmmMax - 1)
                    helper.AddPlainPhrase(true,items[i]);
                else
                    helper.AddPlainPhrase(false,items[i]);
            }

            //de
            //helper.AddPlainPhrase(true, "rot","blau");

            //en
            helper.AddPlainPhrase(true, "red","blue");

            //helper.ChangeCommand("", false);
            var test = helper.AllCommands.Commands;

            //helper.AddCommand();
        }