当前位置: 首页>>代码示例>>C#>>正文


C# SpeechRecognizer.LoadGrammar方法代码示例

本文整理汇总了C#中SpeechRecognizer.LoadGrammar方法的典型用法代码示例。如果您正苦于以下问题:C# SpeechRecognizer.LoadGrammar方法的具体用法?C# SpeechRecognizer.LoadGrammar怎么用?C# SpeechRecognizer.LoadGrammar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpeechRecognizer的用法示例。


在下文中一共展示了SpeechRecognizer.LoadGrammar方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: button1_Click

 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);
 }
开发者ID:Tarang1993,项目名称:Laugh-Meter,代码行数:11,代码来源:Form1.cs

示例2: SpeechInput

 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);
 }
开发者ID:RadoChervenkov,项目名称:Minesweeper,代码行数:12,代码来源:SpeechInput.cs

示例3: VoiceCommandRecognizer

        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();
        }
开发者ID:andresrobinson,项目名称:ivaps,代码行数:14,代码来源:VoiceCommandRecognizer.cs

示例4: Run

        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();
        }
开发者ID:dariukas,项目名称:Scanorama,代码行数:49,代码来源:MainSpeech.cs

示例5: WinRecog

 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;
     }
 }
开发者ID:Booser,项目名称:radegast,代码行数:17,代码来源:WinRecog.cs

示例6: button1_Click

 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);
 }
开发者ID:CMU-VOR,项目名称:Yiting-Hao,代码行数:18,代码来源:Form1.cs

示例7: Form1_Load

        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);
        }
开发者ID:ChaYongbin,项目名称:Programming-Exp,代码行数:21,代码来源:Form1.cs

示例8: Form1_Load

        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);

        }
开发者ID:saadixl,项目名称:vcon-1.0,代码行数:21,代码来源:Form1.cs

示例9: MainWindow

        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;
        }
开发者ID:thomdabeast,项目名称:CptS323RSSMAP,代码行数:20,代码来源:MainWindow.xaml.cs

示例10: RecordButton2_Click

 private void RecordButton2_Click(object sender, EventArgs e)
 {
     recognizer = new SpeechRecognizer();
     g = CreateLogInGrammar();
     recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(plane_ser_SpeechRecognized);
     recognizer.LoadGrammar(g);
 }
开发者ID:CMU-VOR,项目名称:VoiceFormApp,代码行数:7,代码来源:Form1.cs

示例11: Grid_Loaded

        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);
        }
开发者ID:BarrosNathiel,项目名称:Verium,代码行数:19,代码来源:MainWindow.xaml.cs

示例12: Init

        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);
            }
        }
开发者ID:Erok21,项目名称:NADIA,代码行数:32,代码来源:Program.cs

示例13: button2_Click

 private void button2_Click(object sender, EventArgs e)
 {
     recognizer = new SpeechRecognizer();
     g = CreateFormGrammar();
     recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(jobType_ser_SpeechRecognized);
     recognizer.LoadGrammar(g);
 }
开发者ID:CMU-VOR,项目名称:VoiceFormApp,代码行数:7,代码来源:Form2.cs


注:本文中的SpeechRecognizer.LoadGrammar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。