コード例 #1
0
        public void speekRecognigetion()
        {
            SpeechRecognizer recognizer = new SpeechRecognizer();
            // Create a new SpeechRecognitionEngine instance.


            // Create a simple grammar that recognizes "red", "green", or "blue".
            Choices colors = new Choices();

            colors.Add(new string[] { "Amit", "blue", "pause", "stop", "play" });

            // Create a GrammarBuilder object and append the Choices object.
            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            // Create the Grammar instance and load it into the speech recognition engine.
            Grammar g = new Grammar(gb);

            recognizer.LoadGrammar(g);

            // Register a handler for the SpeechRecognized event.
            recognizer.SpeechRecognized +=
                new EventHandler <SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        }
コード例 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                // Create a new SpeechRecognitionEngine instance.
                SpeechRecognizer recognizer = new SpeechRecognizer();

                // Create a simple grammar that recognizes "red", "green", or "blue".
                Choices commands = new Choices();
                commands.Add(new string[] { "1", "b" });

                // Create a GrammarBuilder object and append the Choices object.
                GrammarBuilder gb = new GrammarBuilder();
                gb.Append(commands);

                // Create the Grammar instance and load it into the speech recognition engine.
                Grammar g = new Grammar(gb);
                recognizer.LoadGrammar(g);

                // Register a handler for the SpeechRecognized event.
                recognizer.SpeechRecognized +=
                    new EventHandler <SpeechRecognizedEventArgs>(sre_SpeechRecognized);
            }
            catch (System.IO.FileNotFoundException)
            {
                MessageBox.Show("Windows Speech Recognizer must be started before running Voice Recognition", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                Application.Exit();
            }
            catch (System.InvalidOperationException)
            {
                MessageBox.Show("Windows Speech Recognizer must be started before running Voice Recognition", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                Application.Exit();
            }
        }
コード例 #3
0
 private void RecordButton2_Click(object sender, EventArgs e)
 {
     recognizer = new SpeechRecognizer();
     g          = CreateLogInGrammar();
     recognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(plane_ser_SpeechRecognized);
     recognizer.LoadGrammar(g);
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: mellonball/vs
        private void Form1_Load(object sender, EventArgs e)
        {
            Console.WriteLine("Form 1 load");
            // Create a new SpeechRecognitionEngine instance.
            SpeechRecognizer recognizer = new SpeechRecognizer();

            // Create a simple grammar that recognizes "red", "green", or "blue".
            Choices colors = new Choices();

            colors.Add(new string[] { "red", "green", "blue" });

            // Create a GrammarBuilder object and append the Choices object.
            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            // Create the Grammar instance and load it into the speech recognition engine.
            Grammar g = new Grammar(gb);

            recognizer.LoadGrammar(g);

            // Register a handler for the SpeechRecognized event.
            recognizer.SpeechRecognized +=
                new EventHandler <SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        }
コード例 #5
0
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     sharedRecognizer.LoadGrammar(grammar);
     sharedRecognizer.SpeechRecognized          += SpeechRecognized;
     sharedRecognizer.SpeechRecognitionRejected += SpeechRecognitionRejected;
     sharedRecognizer.SpeechDetected            += SpeechDetected;
 }
コード例 #6
0
ファイル: Form2.cs プロジェクト: CMU-VOR/VoiceFormApp
 private void button2_Click(object sender, EventArgs e)
 {
     recognizer = new SpeechRecognizer();
     g          = CreateFormGrammar();
     recognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(jobType_ser_SpeechRecognized);
     recognizer.LoadGrammar(g);
 }
コード例 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            Choices colors = new Choices();

            colors.Add(new string[] { "hello" });

            string grammer = "select title from img2";

            {
                using (SqlCommand cm = new SqlCommand(grammer, con))
                {
                    con.Close();
                    con.Open();
                    SqlDataReader reader = cm.ExecuteReader();
                    while (reader.Read())
                    {
                        colors.Add(reader.GetString(0));
                    }
                }

                con.Close();
            }

            //string grammer2 = "select Title from BookUpdate2";
            string grammer2 = "select title from img2";


            {
                using (SqlCommand cmd = new SqlCommand(grammer2, con))
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        colors.Add(reader.GetString(0));
                    }
                }

                con.Close();
            }



            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            /* foreach(var item in colors)
             * {
             *   Console.WriteLine(item.ToString());
             * }*/
            Grammar g = new Grammar(gb);

            recognizer.LoadGrammar(g);


            recognizer.SpeechRecognized +=
                new EventHandler <SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        }
コード例 #8
0
 void Form1_Load(object sender, EventArgs e)
 {
   var c = new Choices();
   for (var i = 0; i <= 100; i++)
     c.Add(i.ToString());
   var gb = new GrammarBuilder(c);
   var g = new Grammar(gb);
   rec.LoadGrammar(g);
   rec.Enabled = true;
 }
コード例 #9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var sre = new SpeechRecognitionEngine();
            var sr  = new SpeechRecognizer();
            var gb  = new GrammarBuilder("hello computer");
            var g   = new Grammar(gb);

            sr.LoadGrammar(g);
            //sr.SpeechRecognized += new EventHandler(sr_)
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: Tarang1993/Laugh-Meter
 private void button1_Click(object sender, EventArgs e)
 {
     SpeechRecognizer r = new SpeechRecognizer();
     Choices c = new Choices();
     c.Add(new String[] {"haha","hahaha","hahahaha","hahahahaha","hahahahahaha","hahahahahahaha","hahahahahahahaha","hahahahahahahahahah"});
     GrammarBuilder gb = new GrammarBuilder();
     gb.Append(c);
     Grammar g = new Grammar(gb);
     r.LoadGrammar(g);
     r.SpeechRecognized+=new EventHandler<SpeechRecognizedEventArgs>(r_SpeechRecognized);
 }
コード例 #11
0
 public SpeechInput()
 {
     SpeechRecognizer recognizer = new SpeechRecognizer();
     Choices numbers = new Choices();
     numbers.Add(this.allowedPhrases);
     GrammarBuilder gb = new GrammarBuilder();
     gb.Append(numbers);
     Grammar g = new Grammar(gb);
     recognizer.LoadGrammar(g);
     recognizer.SpeechRecognized +=
         new EventHandler<SpeechRecognizedEventArgs>(this.Sre_SpeechRecognized);
 }
        public static void AddPassGrammar(SpeechRecognizer recognizer)
        {
            DictationGrammar defaultDictationGrammar = new DictationGrammar();

            defaultDictationGrammar.Name              = "default dictation";
            defaultDictationGrammar.Enabled           = true;
            defaultDictationGrammar.SpeechRecognized +=
                new EventHandler <SpeechRecognizedEventArgs>(
                    NameSpeechRecognized);

            recognizer.LoadGrammar(defaultDictationGrammar);
        }
コード例 #13
0
        static void Main_prev(string[] args)
        {
            // Initialize an instance of the shared recognizer.
            using (SpeechRecognizer recognizer = new SpeechRecognizer())
            {
                //GrammarBuilder


                // Create and load a sample grammar.


                recognizer.LoadGrammar(/*testGrammar*/ GetGrammar());
                //grammar.SetDictationContext("How do you", null);

                // Attach event handlers for recognition events.
                recognizer.SpeechRecognized +=
                    new EventHandler <SpeechRecognizedEventArgs>(
                        SpeechRecognizedHandler);
                //recognizer.EmulateRecognizeCompleted +=
                //    new EventHandler<EmulateRecognizeCompletedEventArgs>(
                //    EmulateRecognizeCompletedHandler);

                completed = false;

                // Start asynchronous emulated recognition.
                // This matches the grammar and generates a SpeechRecognized event.
                //recognizer.EmulateRecognizeAsync("testing testing");

                // Wait for the asynchronous operation to complete.
                while (!completed)
                {
                    Thread.Sleep(333);
                }

                completed = false;

                // Start asynchronous emulated recognition.
                // This does not match the grammar or generate a SpeechRecognized event.
                //recognizer.EmulateRecognizeAsync("testing one two three");

                // Wait for the asynchronous operation to complete.
                while (!completed)
                {
                    Thread.Sleep(333);
                }
                //}

                Console.WriteLine();
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }
コード例 #14
0
        /// <summary>
        /// Add a grammar to the active list
        /// </summary>
        /// <param name="name"></param>
        internal void ActivateGrammar(string name)
        {
            if (rec == null)
            {
                return;
            }

            if (!cGrammars.ContainsKey(name) || rec.Grammars.Contains(cGrammars[name]))
            {
                return;
            }
            rec.LoadGrammar(cGrammars[name]);
        }
コード例 #15
0
ファイル: VoiceCommand.cs プロジェクト: preetum/archive
        public VoiceCommand(World w, Faction f)
        {
            genVerbs();
            Grammar grammar = new Grammar(new GrammarBuilder(genChoices()));

            recognizer = new SpeechRecognizer();
            recognizer.LoadGrammar(grammar);
            recognizer.Enabled           = true;
            recognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);

            world = w;
            fac   = f;
        }
コード例 #16
0
        private void Stop_Click(object sender, RoutedEventArgs e)
        {
            //using (SpeechSynthesizer synth = new SpeechSynthesizer())
            //{

            //    // Configure the audio output.
            //    synth.SetOutputToDefaultAudioDevice();

            //    // Create a PromptBuilder object and define the data types for some of the added strings.
            //    PromptBuilder sayAs = new PromptBuilder();
            //    sayAs.AppendText("Your");
            //    sayAs.AppendTextWithHint("1st", SayAs.NumberOrdinal);
            //    sayAs.AppendText("request was for");
            //    sayAs.AppendTextWithHint("1", SayAs.NumberCardinal);
            //    sayAs.AppendText("room, on");
            //    sayAs.AppendTextWithHint("10/19/2012,", SayAs.MonthDayYear);
            //    sayAs.AppendText("with early arrival at");
            //    sayAs.AppendTextWithHint("12:35pm", SayAs.Time12);

            //    // Speak the contents of the SSML prompt.
            //    synth.Speak(sayAs);
            //}

            using (SpeechRecognizer recognizer = new SpeechRecognizer())
            {
                // Create and load a sample grammar.
                Grammar testGrammar =
                    new Grammar(new GrammarBuilder("testing testing"));
                testGrammar.Name = "Test Grammar";

                recognizer.LoadGrammar(testGrammar);

                RecognitionResult result;

                // This EmulateRecognize call matches the grammar and returns a
                // recognition result.
                result = recognizer.EmulateRecognize("testing testing");
                if (result != null)
                {
                    TextInFile.Text = result.Text;
                }

                // This EmulateRecognize call does not match the grammar and
                // returns null.
                result = recognizer.EmulateRecognize("testing one two three");
                if (result != null)
                {
                    TextInFile.Text += result.Text;
                }
            }
        }
コード例 #17
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SpeechRecognizer RMAVoiceRecognizerEngine = new SpeechRecognizer();
            Choices          voiceCommands            = new Choices();

            voiceCommands.Add(new string[] { "left", "right", "up", "down", "grip", "dance" });
            GrammarBuilder commandGrammerBuilder = new GrammarBuilder();

            commandGrammerBuilder.Append(voiceCommands);
            Grammar commandGrammer = new Grammar(commandGrammerBuilder);

            RMAVoiceRecognizerEngine.LoadGrammar(commandGrammer);
            RMAVoiceRecognizerEngine.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(RMAVoiceRecognizerEngine_SpeechRecognized);
        }
コード例 #18
0
        public VoiceCommandRecognizer()
        {
            recognizer = new SpeechRecognizer();
            Choices commands = new Choices();
            commands.Add(new string[] { "test", "example" });
            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(commands);
            Grammar g = new Grammar(gb);
            recognizer.LoadGrammar(g);
            handler = new EventHandler<SpeechRecognizedEventArgs>(recognitionHandler);

            //per ora lo faccio così, ma è assolutamente da CAMBIARE
            StartRecognition();
        }
コード例 #19
0
ファイル: MainSpeech.cs プロジェクト: dariukas/Scanorama
        public static void Run()
        {
            // Initialize an instance of the shared recognizer.
            using (SpeechRecognizer recognizer = new SpeechRecognizer())
            {

                // Create and load a sample grammar.
                Grammar testGrammar =
                  new Grammar(new GrammarBuilder("testing testing"));
                testGrammar.Name = "Test Grammar";
                recognizer.LoadGrammar(testGrammar);

                // Attach event handlers for recognition events.
                recognizer.SpeechRecognized +=
                  new EventHandler<SpeechRecognizedEventArgs>(
                    SpeechRecognizedHandler);
                recognizer.EmulateRecognizeCompleted +=
                  new EventHandler<EmulateRecognizeCompletedEventArgs>(
                    EmulateRecognizeCompletedHandler);

                completed = false;

                // Start asynchronous emulated recognition.
                // This matches the grammar and generates a SpeechRecognized event.
                recognizer.EmulateRecognizeAsync("testing testing");

                // Wait for the asynchronous operation to complete.
                while (!completed)
                {
                    Thread.Sleep(333);
                }

                completed = false;

                // Start asynchronous emulated recognition.
                // This does not match the grammar or generate a SpeechRecognized event.
                recognizer.EmulateRecognizeAsync("testing one two three");

                // Wait for the asynchronous operation to complete.
                while (!completed)
                {
                    Thread.Sleep(333);
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
コード例 #20
0
        public SpeechRecognition()
        {
            InitializeComponent();

            var grammar = new GrammarBuilder();

            grammar.Append(new Choices("red", "blue", "green", "black", "white"));
            grammar.Append(new Choices("on", "off"));

            _recognizer.LoadGrammar(new Grammar(grammar));
            _recognizer.SpeechDetected            += OnSpeechDetected;
            _recognizer.SpeechRecognized          += OnSpeechRecognized;
            _recognizer.SpeechRecognitionRejected += OnSpeechRejected;
            _recognizer.SpeechHypothesized        += OnSpeechHypothesized;
        }
コード例 #21
0
        public Window1()
        {
            InitializeComponent();

            SpeechRecognizer recognizer = new SpeechRecognizer();
            GrammarBuilder builder = new GrammarBuilder();
            builder.Append(new Choices("two", "three", "four", "five", "six", "seven",
              "eight", "nine", "ten", "jack", "queen", "king", "ace"));
            builder.Append("of", 0, 1);
            builder.Append(new Choices("clubs", "diamonds", "spades", "hearts"));
            recognizer.LoadGrammar(new Grammar(builder));

            recognizer.SpeechRecognized +=
                new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
        }
コード例 #22
0
        static void Main()
        {
            Choices choiceList = new Choices();

            choiceList.Add(new string[] { "what", "is", "a", "car", "are", "you", "robot" });

            GrammarBuilder builder = new GrammarBuilder();

            builder.Append(choiceList);
            Grammar grammar = new Grammar(new GrammarBuilder(builder, 0, 4));    //Will recognize a minimum of 0 choices, and a maximum of 4 choices

            SpeechRecognizer speechReco = new SpeechRecognizer();

            speechReco.LoadGrammar(grammar);
        }
コード例 #23
0
ファイル: MainSpeech.cs プロジェクト: dariukas/Scanorama
        public static void Run()
        {
            // Initialize an instance of the shared recognizer.
            using (SpeechRecognizer recognizer = new SpeechRecognizer())
            {
                // Create and load a sample grammar.
                Grammar testGrammar =
                    new Grammar(new GrammarBuilder("testing testing"));
                testGrammar.Name = "Test Grammar";
                recognizer.LoadGrammar(testGrammar);

                // Attach event handlers for recognition events.
                recognizer.SpeechRecognized +=
                    new EventHandler <SpeechRecognizedEventArgs>(
                        SpeechRecognizedHandler);
                recognizer.EmulateRecognizeCompleted +=
                    new EventHandler <EmulateRecognizeCompletedEventArgs>(
                        EmulateRecognizeCompletedHandler);

                completed = false;

                // Start asynchronous emulated recognition.
                // This matches the grammar and generates a SpeechRecognized event.
                recognizer.EmulateRecognizeAsync("testing testing");

                // Wait for the asynchronous operation to complete.
                while (!completed)
                {
                    Thread.Sleep(333);
                }

                completed = false;

                // Start asynchronous emulated recognition.
                // This does not match the grammar or generate a SpeechRecognized event.
                recognizer.EmulateRecognizeAsync("testing one two three");

                // Wait for the asynchronous operation to complete.
                while (!completed)
                {
                    Thread.Sleep(333);
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
コード例 #24
0
 internal WinRecog( )
 {
     try
     {
         rec      = new SpeechRecognizer();
         dGrammar = new DictationGrammar();
         rec.LoadGrammar(dGrammar);
         cGrammars = new Dictionary <string, Grammar>();
     }
     catch (Exception e)
     {
         rec = null;
         Logger.Log("Speech recognition disabled, " + e.Message,
                    Helpers.LogLevel.Warning);
     }
 }
コード例 #25
0
        private void Listen()
        {
            Choices colors = new Choices();

            colors.Add(new string[] { "red", "yellow", "green", "exit" });

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            Grammar g = new Grammar(gb);

            recognizer.LoadGrammar(g);

            recognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        }
コード例 #26
0
        void MainWindow_SourceInitialized(object sender, EventArgs e)
        {
            //		GlassHelper.ExtendGlassFrame(this, new Thickness(-1));

            string MyConString = "SERVER=localhost;" +
                                 "DATABASE=mydatabase;" +
                                 "UID=root;" +
                                 "PASSWORD=apurv;";
            MySqlConnection connection = new MySqlConnection(MyConString);
            MySqlCommand    command    = connection.CreateCommand();
            MySqlDataReader Reader;

            command.CommandText = "SELECT * FROM flash1 WHERE sno = 1";
            connection.Open();
            Reader = command.ExecuteReader();
            Choices c = new Choices();

            try
            {
                Reader.Read();
                TBword1.Text = Reader.GetString(1);
                //   RTBFlash.Text = TBword1.Text;
                //    c.Add(TBword1.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            connection.Close();

            SpeechRecognizer rec = new SpeechRecognizer();

            rec.SpeechRecognized += rec_SpeechRecognized;
            c.Add(" add");
            c.Add("flip");
            c.Add("previous");
            c.Add("next");
            c.Add("speak");
            c.Add("continuous");
            c.Add("Verbal");
            //Populate the grammar builder with the choices and load it as a new grammar
            GrammarBuilder pizzadetails = new GrammarBuilder(c);
            Grammar        g            = new Grammar(pizzadetails);

            rec.LoadGrammar(g);
            rec.Enabled = true;
        }
コード例 #27
0
ファイル: WinRecog.cs プロジェクト: Booser/radegast
 internal WinRecog( )
 {
     try
     {
         rec = new SpeechRecognizer();
         dGrammar = new DictationGrammar();
         rec.LoadGrammar(dGrammar);
         cGrammars = new Dictionary<string, Grammar>();
     }
     catch (Exception e)
     {
         rec = null;
         Logger.Log("Speech recognition disabled, " + e.Message,
             Helpers.LogLevel.Warning);
         return;
     }
 }
コード例 #28
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SpeechRecognizer sr = new SpeechRecognizer();
            Choices          ch = new Choices();

            ch.Add(new string[] { "yes", "no", "in", "out" });

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(ch);

            Grammar gr = new Grammar(gb);

            sr.LoadGrammar(gr);

            sr.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(sr_SpeechRecognition);
        }
コード例 #29
0
        public Form1()
        {
            Choices colors = new Choices();

            colors.Add(new string[] { "how are you", "fine", "blue" });

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            // Create the Grammar instance.
            System.Speech.Recognition.Grammar g = new System.Speech.Recognition.Grammar(gb);
            sr.LoadGrammar(g);
            sr.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(sr_SpeechRecognized);

            InitializeComponent();
        }
コード例 #30
0
        public VoiceCommandRecognizer()
        {
            recognizer = new SpeechRecognizer();
            Choices commands = new Choices();

            commands.Add(new string[] { "test", "example" });
            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(commands);
            Grammar g = new Grammar(gb);

            recognizer.LoadGrammar(g);
            handler = new EventHandler <SpeechRecognizedEventArgs>(recognitionHandler);

            //per ora lo faccio così, ma è assolutamente da CAMBIARE
            StartRecognition();
        }
コード例 #31
0
 void Form1_Load(object sender, EventArgs e)
 {
   var c = new Choices();
   // Doens't work must use English words to add to choices and
   // populate grammar.
   //
   //for (var i = 0; i <= 100; i++)
   //  c.Add(i.ToString());
   c.Add("one");
   c.Add("two");
   c.Add("three");
   c.Add("four");
   // etc...
   var gb = new GrammarBuilder(c);
   var g = new Grammar(gb);
   rec.LoadGrammar(g);
   rec.Enabled = true;
 }
コード例 #32
0
        private void SpeechRecognition()
        {
            using (var speechEngine = new SpeechRecognizer())
            {
                var recognize = new Choices(new string[] { "Felicia", "red", "blue", "green" });

                var grammarBuilder = new GrammarBuilder(recognize);
                var grammar        = new Grammar(grammarBuilder);
                speechEngine.LoadGrammar(grammar);

                speechEngine.SpeechDetected            += new EventHandler <SpeechDetectedEventArgs>(SpeechDetectedHandler);
                speechEngine.SpeechHypothesized        += new EventHandler <SpeechHypothesizedEventArgs>(SpeechHypothesizedHandler);
                speechEngine.SpeechRecognitionRejected += new EventHandler <SpeechRecognitionRejectedEventArgs>(SpeechRecognitionRejectedHandler);
                speechEngine.SpeechRecognized          += new EventHandler <SpeechRecognizedEventArgs>(SpeechRecognizedHandler);

                Console.ReadLine();
            }
        }
コード例 #33
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Choices colors = new Choices();

            colors.Add(new string[] { "red", "green", "blue" });

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            // Create the Grammar instance.
            Grammar g = new Grammar(gb);


            speechRecognizer.LoadGrammar(g);
            speechRecognizer.Enabled           = true;
            speechRecognizer.SpeechRecognized += speechRecognizer_SpeechRecognized;
        }
コード例 #34
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Choices theChoices = new Choices();

            theChoices.Add("Bielefeld");
            theChoices.Add("Gütersloh");
            theChoices.Add("Minden");
            theChoices.Add("Neuss");
            theChoices.Add("Düsseldorf");
            theChoices.Add("Köln");
            theChoices.Add("Christian");
            theChoices.Add("Irina");
            SpeechRecognizer recognizer = new SpeechRecognizer();

            recognizer.LoadGrammar(new Grammar(new GrammarBuilder(theChoices)));
            recognizer.SpeechRecognized += speechRecognized;
            recognizer.Enabled           = true;
        }
コード例 #35
0
ファイル: Form1.cs プロジェクト: CMU-VOR/Yiting-Hao
 private void button1_Click(object sender, EventArgs e)
 {
     // Create a Speech Recognition Engine instance
     // Notice: Need to add reference "System.Speech" in your project. Right click on the Reference on your Solution Explorer and add.
     // Notice: Include namespace System.Speech.Recognition
     SpeechRecognizer recognizer = new SpeechRecognizer();
     // Create a grammar with several words. We need
     Choices colors = new Choices();
     colors.Add(new String[] { "right wing", "left wing", "vertical stabilizer", "elevator", "winglet", "horizontal stabilizer", "engine", "slats", "transmission" });
     // Create a GrammarBuilder object and append the Choices object
     GrammarBuilder gb = new GrammarBuilder();
     gb.Append(colors);
     // Create a new Grammar and load it into speech recognition engine
     Grammar g = new Grammar(gb);
     recognizer.LoadGrammar(g);
     // Register a handler for the SpeechRecognized event, which defined in ser_SpeechRecognized
     recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(ser_SpeechRecognized);
 }
コード例 #36
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public SpeechRecognitionManager()
        {
            try
            {
                recognizer = new SpeechRecognizer();
                recognizer.LoadGrammar(BuildGrammar());

                recognizer.Enabled                    = false;
                recognizer.SpeechRecognized          += recognizer_SpeechRecognized;
                recognizer.SpeechDetected            += recognizer_SpeechDetected;
                recognizer.SpeechRecognitionRejected += recognizer_SpeechRecognitionRejected;

                isRecognitionAvailable = true;
            }
            catch
            {
                isRecognitionAvailable = false;
            }
        }
コード例 #37
0
ファイル: Form1.cs プロジェクト: saadixl/vcon-1.0
        private void Form1_Load(object sender, EventArgs e)
        {
            
             
            notifyIcon1.ShowBalloonTip(50);
            notifyIcon1.ContextMenuStrip = contextMenuStrip1;

            SpeechRecognizer sr = new SpeechRecognizer();
            Choices commands = new Choices();
            commands.Add(new string[] { "up", "down", "right", "left", "ok", "back", "tab","escape", "close" });

            GrammarBuilder gbuilder = new GrammarBuilder();
            gbuilder.Append(commands);

            // Create the Grammar instance.
            Grammar g = new Grammar(gbuilder);
            sr.LoadGrammar(g);
            g.Priority = 127;
            sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognized);

        }
コード例 #38
0
ファイル: Form1.cs プロジェクト: ChaYongbin/Programming-Exp
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create a new SpeechRecognitionEngine instance.
            SpeechRecognizer recognizer = new SpeechRecognizer();

            // Create a simple grammar that recognizes "red", "green", or "blue".
            Choices colors = new Choices();
            colors.Add(new string[] { "red", "green", "blue" });

            // Create a GrammarBuilder object and append the Choices object.
            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(colors);

            // Create the Grammar instance and load it into the speech recognition engine.
            Grammar g = new Grammar(gb);
            recognizer.LoadGrammar(g);

            // Register a handler for the SpeechRecognized event.
            recognizer.SpeechRecognized +=
              new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        }
コード例 #39
0
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            SpeechRecognizer sr = new SpeechRecognizer();
            SpeechRecognizer recognizer = new SpeechRecognizer();
            Choices colors = new Choices();
            colors.Add(new string[] { "banana", "apple", "car" });

            // Create a GrammarBuilder object and append the Choices object.
            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(colors);

            // Create the Grammar instance and load it into the speech recognition engine.
            Grammar g = new Grammar(gb);
            recognizer.LoadGrammar(g);

            // Register a handler for the SpeechRecognized event.
            recognizer.SpeechRecognized +=
              new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        }
コード例 #40
0
        public MainWindow()
        {
            InitializeComponent();
            InitializeUI();

            Speech = new SpeechRecognizer();

            Choices commands = new Choices();
            commands.Add(new string[]
                {
                    "add feed", "add channel", "select article", "read article", "unread article", "next article", "previous article",
                    "view main", "view topic", "view map",
                    "save", "load", "exit"
                });
            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(commands);
            Grammar = new Grammar(gb);
            Speech.LoadGrammar(Grammar);
            Speech.SpeechRecognized += Speech_SpeechRecognized;
        }
コード例 #41
0
ファイル: Form2.cs プロジェクト: CMU-VOR/VoiceFormApp
 private void button2_Click(object sender, EventArgs e)
 {
     recognizer = new SpeechRecognizer();
     g = CreateFormGrammar();
     recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(jobType_ser_SpeechRecognized);
     recognizer.LoadGrammar(g);
 }
コード例 #42
0
ファイル: Program.cs プロジェクト: Erok21/NADIA
        public void Init()
        {
            recognizer = new SpeechRecognizer();
            recognizer.Enabled = true;
            recognizer.SpeechRecognized += (s, args) =>
            {
                foreach (RecognizedWordUnit word in args.Result.Words)
                {
                    if (word.Confidence > 0.5f)
                        message += word.Text + " ";
                }
            };
            recognizer.LoadGrammar(new DictationGrammar());

            //recognitionEngine = new SpeechRecognitionEngine();
            //recognitionEngine.SetInputToDefaultAudioDevice();
            //recognitionEngine.SpeechRecognized += (s, args) =>
            //{
            //    foreach (RecognizedWordUnit word in args.Result.Words)
            //    {
            //        if (word.Confidence > 0.5f)
            //            message += word.Text + " ";
            //    }

            //};
            //recognitionEngine.LoadGrammar(new DictationGrammar());
            if (!string.IsNullOrEmpty(message) && outputMessage != message)
            {
                outputMessage = message;
                Console.WriteLine(message);
            }
        }
コード例 #43
0
ファイル: Form1.cs プロジェクト: CMU-VOR/VoiceFormApp
 private void RecordButton2_Click(object sender, EventArgs e)
 {
     recognizer = new SpeechRecognizer();
     g = CreateLogInGrammar();
     recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(plane_ser_SpeechRecognized);
     recognizer.LoadGrammar(g);
 }