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


C# Choices.Add方法代码示例

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


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

示例1: Main

        public Main()
        {
            InitializeComponent();

            fontList.SelectedIndex = 0;
            squareCenter = squareButton.Checked;

            speechEngine.SpeechRecognized +=new EventHandler<SpeechRecognizedEventArgs>(speechEngine_SpeechRecognized);

            speechEngine.SetInputToDefaultAudioDevice();

            Choices choices = new Choices("primes", "squares", "dots", "numbers");

            foreach(string item in fontList.Items)
                choices.Add("set font " + item);

            for (int i = 0; i <= 999; ++i)
                choices.Add("set size " + i);

            GrammarBuilder grammarBuilder = new GrammarBuilder(choices);
            speechEngine.LoadGrammar(new Grammar(grammarBuilder));
            speechEngine.RecognizeAsync(RecognizeMode.Multiple);

            init();
        }
开发者ID:bradenwatling,项目名称:UlamSpiral,代码行数:25,代码来源:Main.cs

示例2: initRS

        public void initRS()
        {
            try
            {
                SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US"));

                var words = new Choices();
                words.Add("Hello");
                words.Add("Jump");
                words.Add("Left");
                words.Add("Right");

                var gb = new GrammarBuilder();
                gb.Culture = new System.Globalization.CultureInfo("en-US");
                gb.Append(words);
                Grammar g = new Grammar(gb);

                sre.LoadGrammar(g);
                
                sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
                sre.SetInputToDefaultAudioDevice();
                sre.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch (Exception e)
            {
                label1.Text = "init RS Error : " + e.ToString();
            }
        }
开发者ID:gustavocalheiros,项目名称:ItOverviewEpita,代码行数:28,代码来源:Form1.cs

示例3: addCommand

        private GrammarBuilder addCommand()
        {
            //<pleasantries> <command> <CLASS> <prep> <Time><year>
             //Pleasantries: I'd like to, please, I want to, would you
             //Command: Add, Remove
             //Class: a class, this class, that class, that other class
             //When: to Spring 2012

             Choices commands = new Choices();
             SemanticResultValue commandSRV;
             commandSRV = new SemanticResultValue("add", (int)CommandTypes.Add);
             commands.Add(commandSRV);
             commandSRV = new SemanticResultValue("take", (int)CommandTypes.Add);
             commands.Add(commandSRV);
             commandSRV = new SemanticResultValue("put", (int)CommandTypes.Add);
             commands.Add(commandSRV);
             SemanticResultKey commandSemKey = new SemanticResultKey(Slots.Command.ToString(), commands);

             // put the whole command together
             GrammarBuilder finalCommand = new GrammarBuilder();
             finalCommand.Append(this.pleasantries, 0, 1);
             finalCommand.Append(commandSemKey);
             finalCommand.Append(this.course, 0, 1);
             finalCommand.Append(this.semester, 0, 1);

             return finalCommand;
        }
开发者ID:ewhitmire,项目名称:mypack-speech,代码行数:27,代码来源:CommandGrammar.cs

示例4: GetGrammar

 /*
  * Función: GetGrammar
  * Descripción: Función que llena y devuelve la gramática usando los vectores de comandos y el árbol de comandos
  * Autor: Christian Vargas
  * Fecha de creación: 16/08/15
  * Fecha de modificación: --/--/--
  * Entradas: Nodo inicial del árbol de comandos
  * Salidas: (Choices, gramática para entrenar a Kinect)
  */
 public static Choices GetGrammar(CommandNode commandTree)
 {
     grammar = new Choices();
     grammar.Add(UNLOCK_COMMAND);
     foreach (string command in GEOMETRIC_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string command in MENU_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string command in DICTATION_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string characterSound in CHARACTERS_SOUNDS)
     {
         grammar.Add(characterSound);
     }
     foreach (string characterSound in ALT_CHARACTERS_SOUNDS)
     {
         grammar.Add(characterSound);
     }
     AddNodeToGrammar(commandTree);
     AddNumbers();
     return grammar;
 }
开发者ID:Christian010,项目名称:RealMOL,代码行数:37,代码来源:GrammarGenerator.cs

示例5: IntroGrammar

        public IntroGrammar()
        {
            Choices majors = new Choices();
             majors.Add(new SemanticResultValue("Computer Science", "CSC"));

             SemanticResultKey majorKey = new SemanticResultKey(Slots.Major.ToString(), majors);

             Choices years = new Choices();
             for (int i = 2001; i < 2020; i++)
             {
            years.Add(new SemanticResultValue(i.ToString(), i));
             }
             SemanticResultKey year = new SemanticResultKey(Slots.GradYear.ToString(), years);

             Choices yesOrNo = new Choices();
             yesOrNo.Add(new SemanticResultValue("yes", "yes"));
             yesOrNo.Add(new SemanticResultValue("yeah", "yes"));
             yesOrNo.Add(new SemanticResultValue("yep", "yes"));
             yesOrNo.Add(new SemanticResultValue("no", "no"));
             yesOrNo.Add(new SemanticResultValue("nope", "no"));
             SemanticResultKey yesNo = new SemanticResultKey(Slots.YesNo.ToString(), yesOrNo);

             Choices options = new Choices();
             options.Add(majorKey);
             options.Add(year);
             options.Add(yesNo);

             GrammarBuilder builder = new GrammarBuilder();
             builder.Append(options);
             grammar = new Grammar(builder);
        }
开发者ID:ewhitmire,项目名称:mypack-speech,代码行数:31,代码来源:IntroGrammar.cs

示例6: BuildGrammar

        public Grammar BuildGrammar()
        {
            Choices choiceBuilder = new Choices();

            // Next
            GrammarBuilder nextBuilder = new GrammarBuilder();
            nextBuilder.Append(new Choices("next song", "play the next song", "skip this song", "play next song"));
            choiceBuilder.Add(nextBuilder);

            // Previous
            GrammarBuilder prevBuilder = new GrammarBuilder();
            prevBuilder.Append(new Choices("last song", "previous song", "play the last song", "play the previous song"));
            choiceBuilder.Add(prevBuilder);

            // Pause
            GrammarBuilder pauseBuilder = new GrammarBuilder();
            pauseBuilder.Append(new Choices("pause song", "pause this song", "pause song playback"));
            choiceBuilder.Add(pauseBuilder);

            // Stop
            GrammarBuilder stopBuilder = new GrammarBuilder();
            stopBuilder.Append(new Choices("stop song", "stop song playback", "stop the music"));
            choiceBuilder.Add(stopBuilder);

            // Resume
            GrammarBuilder resumeBuilder = new GrammarBuilder();
            resumeBuilder.Append(new Choices("resume playback", "resume song", "resume playing"));
            choiceBuilder.Add(resumeBuilder);

            return new Grammar(new GrammarBuilder(choiceBuilder));
        }
开发者ID:BenWoodford,项目名称:Jarvis,代码行数:31,代码来源:Controls.cs

示例7: Main

        static void Main(string[] args)
        {
            try
            {
                ss.SetOutputToDefaultAudioDevice();
                Console.WriteLine("\n(Speaking: I am awake)");
                ss.Speak("I am awake");

                CultureInfo ci = new CultureInfo("en-us");
                sre = new SpeechRecognitionEngine(ci);
                sre.SetInputToDefaultAudioDevice();
                sre.SpeechRecognized += sre_SpeechRecognized;

                Choices ch_StartStopCommands = new Choices();
                ch_StartStopCommands.Add("Alexa record");
                ch_StartStopCommands.Add("speech off");
                ch_StartStopCommands.Add("klatu barada nikto");
                GrammarBuilder gb_StartStop = new GrammarBuilder();
                gb_StartStop.Append(ch_StartStopCommands);
                Grammar g_StartStop = new Grammar(gb_StartStop);

                sre.LoadGrammarAsync(g_StartStop);
                sre.RecognizeAsync(RecognizeMode.Multiple); // multiple grammars

                while (done == false) { ; }

                Console.WriteLine("\nHit <enter> to close shell\n");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
开发者ID:toriqyan,项目名称:prototype0,代码行数:35,代码来源:Program.cs

示例8: VoiceInput

        public VoiceInput()
        {
            recognizer = new SpeechRecognitionEngine(new CultureInfo("en-US"));

            recognizer.SetInputToDefaultAudioDevice();
            Choices choices = new Choices();
            foreach (String command in commands)
            {
                choices.Add(command);
            }
            choices.Add(startListening);
            choices.Add(stopListening);
            choices.Add(stop);
            /*choices.Add("Close");
            choices.Add("Left");
            choices.Add("Right");
            choices.Add("Tilt Left");
            choices.Add("Tilt Right");
            choices.Add("Move");
            choices.Add("Back");
            choices.Add("Move Up");
            choices.Add("Down");
            choices.Add("Exit");
            choices.Add("Stop");
            choices.Add("Start Listening");
            choices.Add("Stop Listening");*/
            Grammar grammar = new Grammar(new GrammarBuilder(choices));
            recognizer.LoadGrammar(grammar);

            recognizer.SpeechRecognized +=
                new EventHandler<SpeechRecognizedEventArgs>(SpeechRecognized);
            recognizer.RecognizeAsync(RecognizeMode.Multiple);
        }
开发者ID:davidajulio,项目名称:hx,代码行数:33,代码来源:VoiceInput.cs

示例9: BuildGrammar

        public Grammar BuildGrammar()
        {
            Choices choiceBuilder = new Choices();

            // Songs
            if (SongHelper.SongCount() > 0) // it freaks out if there's nothing in the one-of bit.
            {
                GrammarBuilder songBuilder = new GrammarBuilder();
                songBuilder.Append("play song");
                songBuilder.Append(SongHelper.GenerateSongChoices());
                choiceBuilder.Add(songBuilder);
            }

            GrammarBuilder shuffleBuilder = new GrammarBuilder();
            shuffleBuilder.Append("shuffle all songs");
            choiceBuilder.Add(shuffleBuilder);

            // Playlists
            if (SongHelper.PlaylistCount() > 0)
            {
                GrammarBuilder playListBuilder = new GrammarBuilder();
                playListBuilder.Append("play playlist");
                playListBuilder.Append(SongHelper.GeneratePlaylistChoices());
                choiceBuilder.Add(playListBuilder);

                GrammarBuilder shufflePlayListBuilder = new GrammarBuilder();
                shufflePlayListBuilder.Append("shuffle playlist");
                shufflePlayListBuilder.Append(SongHelper.GeneratePlaylistChoices());
                choiceBuilder.Add(shufflePlayListBuilder);
            }

            Grammar gram = new Grammar(new GrammarBuilder(choiceBuilder));

            return gram;
        }
开发者ID:BenWoodford,项目名称:Jarvis,代码行数:35,代码来源:Play.cs

示例10: BuildSpeechEngine

void BuildSpeechEngine(RecognizerInfo rec)
{
    _speechEngine = new SpeechRecognitionEngine(rec.Id);

    var choices = new Choices();
    choices.Add("venus");
    choices.Add("mars");
    choices.Add("earth");
    choices.Add("jupiter");
    choices.Add("sun");

    var gb = new GrammarBuilder { Culture = rec.Culture };
    gb.Append(choices);

    var g = new Grammar(gb);

    _speechEngine.LoadGrammar(g);
    //recognized a word or words that may be a component of multiple complete phrases in a grammar.
    _speechEngine.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(SpeechEngineSpeechHypothesized);
    //receives input that matches any of its loaded and enabled Grammar objects.
    _speechEngine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(_speechEngineSpeechRecognized);
    //receives input that does not match any of its loaded and enabled Grammar objects.
    _speechEngine.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(_speechEngineSpeechRecognitionRejected);


    //C# threads are MTA by default and calling RecognizeAsync in the same thread will cause an COM exception.
    var t = new Thread(StartAudioStream);
    t.Start();
}
开发者ID:RITInsightLab,项目名称:space-adventure,代码行数:29,代码来源:MainWindow.xaml.cs

示例11: CreateGrammar

        public void CreateGrammar()
        {
            // 1[what]  2[is today's, is tomorrow's, is the] 3[is today, is tomorrow]  4[time, day, date]  5[is it]

            var one = new Choices();
            one.Add(new SemanticResultValue("what", "what"));
            var sOne = new SemanticResultKey("one", one);

            var two = new Choices();
            two.Add(new SemanticResultValue("is today's", "is today"));
            two.Add(new SemanticResultValue("is tomorrow's", "is tomorrow"));
            two.Add(new SemanticResultValue("is the", "is the"));
            var sTwo = new SemanticResultKey("two", two);

            var three = new Choices();
            three.Add(new SemanticResultValue("is today", "is today"));
            three.Add(new SemanticResultValue("is tomorrow", "is tomorrow"));
            three.Add(new SemanticResultValue("was yesterday", "was yesterday"));
            var sThree = new SemanticResultKey("three", three);

            var four = new Choices();
            four.Add(new SemanticResultValue("time", "time"));
            four.Add(new SemanticResultValue("day", "day"));
            four.Add(new SemanticResultValue("date", "day"));
            var sFour = new SemanticResultKey("three", four);

            var five = new Choices();
            five.Add(new SemanticResultValue("is it", "is it"));
            var sFive = new SemanticResultKey("four", five);

            // what (time, day, date) is it
            var gOne = new GrammarBuilder();
            gOne.Append(sOne);
            gOne.Append(sFour);
            gOne.Append(sFive);

            // what (is today's, is the) (time, day, date)
            var gTwo = new GrammarBuilder();
            gTwo.Append(sOne);
            gTwo.Append(sTwo);
            gTwo.Append(sFour);

            // what (is today, is tomorrow)
            var gThree = new GrammarBuilder();
            gThree.Append(sOne);
            gThree.Append(sThree);

            var perm = new Choices();
            perm.Add(gOne);
            perm.Add(gTwo);
            perm.Add(gThree);

            var b = new GrammarBuilder();
            b.Append(perm, 0, 1);

            Grammar = new Grammar(b);
        }
开发者ID:EricFreeman,项目名称:HAL,代码行数:57,代码来源:DateAndTimeModule.cs

示例12: Main

        static void Main(string[] args)
        {                    
            using (var source = new KinectAudioSource())
            {
                source.FeatureMode = true;
                source.AutomaticGainControl = false; //Important to turn this off for speech recognition
				source.SystemMode = SystemMode.OptibeamArrayOnly; //No AEC for this sample

                RecognizerInfo ri = GetKinectRecognizer();

                if (ri == null)
                {
                    Console.WriteLine("Could not find Kinect speech recognizer. Please refer to the sample requirements.");
                    return;
                }

                Console.WriteLine("Using: {0}", ri.Name);

                using (var sre = new SpeechRecognitionEngine(ri.Id))
                {                
                    var colors = new Choices();
                    colors.Add("red");
                    colors.Add("green");
                    colors.Add("blue");

                    var gb = new GrammarBuilder();
                    //Specify the culture to match the recognizer in case we are running in a different culture.                                 
                    gb.Culture = ri.Culture;
                    gb.Append(colors);
                    

                    // Create the actual Grammar instance, and then load it into the speech recognizer.
                    var g = new Grammar(gb);                    

                    sre.LoadGrammar(g);
                    sre.SpeechRecognized += SreSpeechRecognized;
                    sre.SpeechHypothesized += SreSpeechHypothesized;
                    sre.SpeechRecognitionRejected += SreSpeechRecognitionRejected;

                    using (Stream s = source.Start())
                    {
                        sre.SetInputToAudioStream(s,
                                                  new SpeechAudioFormatInfo(
                                                      EncodingFormat.Pcm, 16000, 16, 1,
                                                      32000, 2, null));

						Console.WriteLine("Recognizing. Say: 'red', 'green' or 'blue'. Press ENTER to stop");

                        sre.RecognizeAsync(RecognizeMode.Multiple);
                        Console.ReadLine();
                        Console.WriteLine("Stopping recognizer ...");
                        sre.RecognizeAsyncStop();                       
                    }
                }
            }
        }
开发者ID:thoschmidt,项目名称:shoopdoup,代码行数:56,代码来源:Program.cs

示例13: loadCommandGrammar

 public void loadCommandGrammar()
 {
     var keywords = _settingsList.Commands.Select(coms => coms.VoiceKeyword);
     Choices sList = new Choices();
     sList.Add(keywords.ToArray());
     sList.Add("start dictation");
     sList.Add("start scroll");
     sList.Add("stop scroll");
     GrammarBuilder gb = new GrammarBuilder(sList);
     commandGrammar = new Grammar(gb);
 }
开发者ID:AlexanderMcNeill,项目名称:voxvisio,代码行数:11,代码来源:MainEngine.cs.LOCAL.11920.cs

示例14: BrightnessGrammar

        private Grammar BrightnessGrammar()
        {
            // Change/Set Brightness to Choices
            var choices = new Choices();
            for (var i = -255; i <= 255; i++)
            {
                SemanticResultValue choiceResultValue = new SemanticResultValue(i.ToString(), i);
                GrammarBuilder resultValueBuilder = new GrammarBuilder(choiceResultValue);
                choices.Add(resultValueBuilder);
            }

            GrammarBuilder changeGrammar = "Change";
            GrammarBuilder setGrammar = "Set";
            GrammarBuilder brightnessGrammar = "Brightness";
            GrammarBuilder toGrammar = "To";

            SemanticResultKey resultKey = new SemanticResultKey("brightness", choices);
            GrammarBuilder resultContrast = new GrammarBuilder(resultKey);

            Choices alternatives = new Choices(changeGrammar, setGrammar);

            GrammarBuilder result = new GrammarBuilder(alternatives);
            result.Append(brightnessGrammar);
            result.Append(toGrammar);
            result.Append(resultContrast);

            Grammar grammar = new Grammar(result);
            grammar.Name = "Set Brightness";
            return grammar;
        }
开发者ID:fvioz,项目名称:VoiceRecognition,代码行数:30,代码来源:MainView.cs

示例15: SpeechRecogniser

        public SpeechRecogniser()
        {
            RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers().Where(r => r.Id == RecognizerId).FirstOrDefault();
            if (ri == null)
                return;

            sre = new SpeechRecognitionEngine(ri.Id);

            // Build a simple grammar of shapes, colors, and some simple program control
            var instruments = new Choices();
            foreach (var phrase in InstrumentPhrases)
                instruments.Add(phrase.Key);

            var objectChoices = new Choices();
            objectChoices.Add(instruments);

            var actionGrammar = new GrammarBuilder();
            //actionGrammar.AppendWildcard();
            actionGrammar.Append(objectChoices);

            var gb = new GrammarBuilder();
            gb.Append(actionGrammar);

            var g = new Grammar(gb);
            sre.LoadGrammar(g);
            sre.SpeechRecognized += sre_SpeechRecognized;
            sre.SpeechHypothesized += sre_SpeechHypothesized;
            sre.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(sre_SpeechRecognitionRejected);

            var t = new Thread(StartDMO);
            t.Start();

            valid = true;
        }
开发者ID:grazulis,项目名称:KinectRainbowSynth,代码行数:34,代码来源:SpeechRecogniser.cs


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