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


C# Choices.ToGrammarBuilder方法代码示例

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


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

示例1: getGrammar

 public Grammar getGrammar()
 {
     // Create a set of choices
     Choices thisChoices = new Choices("Alfred", "Is there anything you would like to say", "What do you think", "That will be all Alfred");
     Grammar thisGrammar = new Grammar(thisChoices.ToGrammarBuilder());
     // Set the Grammar name
     thisGrammar.Name = _grammarName;
     return thisGrammar;
 }
开发者ID:EquinoxSoftware,项目名称:Alfred,代码行数:9,代码来源:Personality.cs

示例2: getGrammar

        public Grammar getGrammar()
        {
            // Create a set of choices
            Choices thisChoices = new Choices("How is the weather", "What is the weather like", "What time is it");

            Grammar thisGrammar = new Grammar(thisChoices.ToGrammarBuilder());
            // Set the Grammar name
            thisGrammar.Name = _grammarName;
            return thisGrammar;
        }
开发者ID:EquinoxSoftware,项目名称:Alfred,代码行数:10,代码来源:Information.cs

示例3: getGrammar

        public Grammar getGrammar()
        {
            // Create a set of choices
            Choices thisChoices = new Choices("Email", "Internet", "Notepad", "Calculator");

            Grammar thisGrammar = new Grammar(thisChoices.ToGrammarBuilder());
            // Set the Grammar name
            thisGrammar.Name = _grammarName;
            return thisGrammar;
        }
开发者ID:EquinoxSoftware,项目名称:Alfred,代码行数:10,代码来源:Launch.cs

示例4: Recognize

        public void Recognize(IEnumerable<string> phrases, bool continuous)
        {
            Choices choices = new Choices();
            foreach (string s in phrases)
            {
                choices.Add(s);
            }
            Grammar grammar = new Grammar(choices.ToGrammarBuilder());

            Recognize(grammar, continuous);
        }
开发者ID:InfoStrat,项目名称:MotionFx,代码行数:11,代码来源:SpeechHelper.cs

示例5: VoiceCommandEngine

    public VoiceCommandEngine(string callName)
    {
        this.callName = callName;

        engine = new SpeechRecognitionEngine();
        engine.SetInputToDefaultAudioDevice();

        var choice = new Choices(new[] {
            "open",
            "open file",
            "mute",
            "unmute",
            "increase volume",
            "raise volume",
            "volume up",
            "decrease volume",
            "lower volume",
            "volume down",
            "hide",
            "show",
            "help",
            "stop listening",
            "close",
            "play",
            "pause",
            "rewind",
            "stop",
            "next chapter",
            "skip chapter",
            "previous chapter",
            "next",
            "next file",
            "previous",
            "previous file",
            "fullscreen",
            "view fullscreen",
            "go fullscreen",
            "exit fullscreen",
            "leave fullscreen",
            "whats playing"
        });

        var grammarBuilder = new GrammarBuilder(callName);
        grammarBuilder.Append(choice.ToGrammarBuilder());

        // add the grammars
        engine.LoadGrammarAsync(new Grammar(grammarBuilder));

        // adds handlers for the grammar's speech recognized event.
        engine.SpeechRecognized += recognizer_SpeechRecognized;
        engine.AudioLevelUpdated += engine_AudioLevelUpdated;
    }
开发者ID:godly-devotion,项目名称:Baka-MPlayer-old,代码行数:52,代码来源:VoiceCommandEngine.cs

示例6: MakeGrammarBuilderRecursively

        private static GrammarBuilder MakeGrammarBuilderRecursively(RadTreeNode currentNode)
        {
            GrammarBuilder currentGrammar = new GrammarBuilder();
            if ((currentNode.Tag as GrammarTreeViewTag).Optional != true &&
                (currentNode.Tag as GrammarTreeViewTag).IsDictation != true)
            {
                currentGrammar = new GrammarBuilder(new SemanticResultKey(currentNode.Text, new GrammarBuilder(currentNode.Text)));
            }
            else if ((currentNode.Tag as GrammarTreeViewTag).Optional && (currentNode.Tag as GrammarTreeViewTag).IsDictation != true)
            {
                currentGrammar = new GrammarBuilder(new SemanticResultKey(currentNode.Text, new GrammarBuilder(currentNode.Text)), 0, 1);
            }
            else if ((currentNode.Tag as GrammarTreeViewTag).IsDictation)
            {
                GrammarBuilder fakeDictation = new GrammarBuilder();
                string dictation = (currentNode.Tag as GrammarTreeViewTag).DictationContext;
                if (dictation == string.Empty)
                {
                    fakeDictation.AppendDictation();
                }
                else
                {
                    fakeDictation.AppendDictation(dictation);
                }
                if ((currentNode.Tag as GrammarTreeViewTag).Optional)
                {
                    currentGrammar = new GrammarBuilder(new SemanticResultKey(currentNode.Text, fakeDictation), 0, 1);
                }
                else
                {
                    currentGrammar = new GrammarBuilder(new SemanticResultKey(currentNode.Text, fakeDictation));
                }
            }

            Choices tempGrammar = new Choices();
            for (int i = 0; i < currentNode.Nodes.Count; i++)
            {
                tempGrammar.Add(MakeGrammarBuilderRecursively(currentNode.Nodes[i]));
            }
            if (tempGrammar.ToGrammarBuilder().DebugShowPhrases != "[]")
            {
                currentGrammar.Append(tempGrammar);
            }
            return currentGrammar;
        }
开发者ID:ModernSteward,项目名称:ModernSteward,代码行数:45,代码来源:TreeViewToGrammarBuilderAlgorithm.cs

示例7: ConstructGrammarBuilder

        public static GrammarBuilder ConstructGrammarBuilder(HashSet<string> cues, int slideCount)
        {
            Choices choices = new Choices();

            foreach (string command in SPEECH_SIMPLE_COMMANDS)
            {
                choices.Add(SPEECH_COMMAND_PREFIX + " " + command);
            }

            for (int i = 1; i < slideCount + 1; i++)
            {
                choices.Add(SPEECH_COMMAND_PREFIX + " " + SPEECH_COMMAND_GOTO_SLIDE + " " + i);
            }

            foreach (string cue in cues)
            {
                choices.Add(cue);
            }

            return choices.ToGrammarBuilder();
        }
开发者ID:chancancode,项目名称:KinectPresenter,代码行数:21,代码来源:SpeechCommandDetector.cs

示例8: CreatePositionGrammar

        private Grammar CreatePositionGrammar()
        {
            Choices posChoice = new Choices(new string[] { "position", "orientation", "angle" });
            GrammarBuilder posGram = new GrammarBuilder(posChoice);

            GrammarBuilder getPhrase1 = new GrammarBuilder("What is my");
            getPhrase1.Append(posGram);
            GrammarBuilder getPhrase2 = new GrammarBuilder("Tell me my");
            getPhrase2.Append(posGram);
            Choices both = new Choices();
            both.Add(getPhrase1);
            both.Add(getPhrase2);
            GrammarBuilder bothgb = both.ToGrammarBuilder();
            bothgb.Culture = System.Globalization.CultureInfo.CurrentCulture;
            Grammar grammar = new Grammar(bothgb);
            grammar.Name = "RequestPhrase";
            return grammar;
        }
开发者ID:nickudell,项目名称:PigmentFramework,代码行数:18,代码来源:Listening.cs

示例9: buildCourseGrammarNested

        private GrammarBuilder buildCourseGrammarNested()
        {
            //Class: a class, this class, that class, that other class
             Choices deptChoices = new Choices();
             SemanticResultValue deptsRV;
             for (int i = 0; i < this.depts.Count; i++)
             {
            Department dept = depts[i];
            Choices classNumbers = new Choices();
            foreach (var numbersRV in classList.Where(c => c.DeptAbv == dept.Abv).Select(c => c.Number).Distinct().Select(n => new SemanticResultValue(n.ToString(), n)))
            {
               classNumbers.Add(numbersRV);
            }

            deptsRV = new SemanticResultValue(dept.Abv, dept.Abv);
            GrammarBuilder deptsGmr = deptsRV.ToGrammarBuilder();
            deptsGmr.Append(classNumbers);
            deptChoices.Add(deptsGmr);

            deptsRV = new SemanticResultValue(dept.Name, dept.Abv);
            deptsGmr = deptsRV.ToGrammarBuilder();
            deptsGmr.Append(classNumbers);
            deptChoices.Add(deptsGmr);
             }

             SemanticResultKey deptSemKey = new SemanticResultKey(Slots.Department.ToString(), deptChoices);
             GrammarBuilder course = new GrammarBuilder();
             course.Append(deptChoices.ToGrammarBuilder());

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

示例10: Recog_Choices

        public RecognitionResult Recog_Choices(List<string> choices, int timeout)
        {
            Console.Write("Recognition Choices Grammar loaded : ");

            foreach (string s in choices)
                Console.Write(s);
            Console.WriteLine();
            Choices c = new Choices(choices.ToArray());
            GrammarBuilder cBuild = c.ToGrammarBuilder();
            cBuild.Culture = m_reco.RecognizerInfo.Culture;
            m_reco.UnloadAllGrammars();
            m_grammar_simple = new Grammar(cBuild);

            m_reco.LoadGrammar(m_grammar_simple);
            RecognitionResult result = m_reco.Recognize(TimeSpan.FromMilliseconds(timeout));
            if (result != null)
                Console.WriteLine("Recognized : " + result.Text);
            else
                Console.WriteLine("Recognize Failure.");
            return result;
        }
开发者ID:xufango,项目名称:contrib_bk,代码行数:21,代码来源:SpeechRecognizerServer.cs

示例11: LoadSpeechInformation

        private GrammarBuilder LoadSpeechInformation(ScriptData p_scriptData)
        {
            /*** Fake the old api from lorei
             * Run through the keywords and build the grammers for each of the functions
             * I also keep track of amout of entries added to each list.  There doesn't
             * seem to be a way to keep to see if entires exist in the speech data structures
             * without building a parser(way to much work)
             ***/
            // Data
            Choices keywords; int countKeywords = 0;
            Choices functions; int countFunctions = 0;
            Choices programs; int countPrograms = 0;
            Choices programActions; int countProgramActions = 0;
            Choices finalChoices = new Choices(); int countFinalChoices = 0;

            // Grammar Stuff
            GrammarBuilder m_FunctionExecution = new GrammarBuilder();
            GrammarBuilder m_ProgramControl = new GrammarBuilder();
            GrammarBuilder m_GrammarToReturn = new GrammarBuilder();

            // Collect and setup all key words
            // Setup Keywords
            keywords = new Choices(p_scriptData.m_Keywords.ToArray());
            countKeywords += p_scriptData.m_Keywords.Count;
            keywords.Add(m_LoreiApi.GetLoreiNames().ToArray());
            countKeywords += m_LoreiApi.GetLoreiNames().Count;

            // Setup Function List
            functions = new Choices(p_scriptData.m_Functions.ToArray());
            countFunctions += p_scriptData.m_Functions.Count;
            functions.Add(m_dataFromSetupLua.m_Functions.ToArray());
            countFunctions += m_dataFromSetupLua.m_Functions.Count;
            foreach (var x in m_ScriptInfo.Values)
            {
                functions.Add(x.m_Functions.ToArray());
                countFunctions++;
            }

            // Setup List of Programs;
            programs = new Choices(p_scriptData.m_Programs.ToArray());
            countPrograms += p_scriptData.m_Programs.Count;

            // Program Functions
            programActions = new Choices(p_scriptData.m_ProgramActions.ToArray());
            countProgramActions += p_scriptData.m_ProgramActions.Count;

            // Setup Grammar for lorei functions
            if ( countKeywords > 0 && countFunctions > 0 && countPrograms > 0 )
            {
                m_FunctionExecution.Append(keywords);
                m_FunctionExecution.Append(functions);
                m_FunctionExecution.Append(programs);

                // Setup function grammars
                finalChoices.Add(m_FunctionExecution);

                // Keep track of number of final choices
                countFinalChoices++;
            }

            // Setup Grammar for program controls
            if (countKeywords > 0 && countPrograms > 0 && countProgramActions > 0)
            {
                m_ProgramControl.Append(keywords);
                m_ProgramControl.Append(programs);
                m_ProgramControl.Append(programActions);

                // Setup function grammars
                finalChoices.Add(m_ProgramControl);

                // Keep track of number of final choices
                countFinalChoices++;
            }

            if ( countFinalChoices > 0)
            {
                return finalChoices.ToGrammarBuilder();

            }
            else
            {
                return null;
            }
            // Setup Engine
            //m_FunctionGrammar = new Grammar(m_FunctionExecution);
            //m_ProgramGrammar = new Grammar(m_ProgramControl);
            //m_FunctionGrammar.Name = "m_FunctionGrammar";
            //m_ProgramGrammar.Name = "m_ProgramGrammar";

            //m_LoreiApi.RegisterLoreiGrammar(m_FunctionGrammar);
            //m_LoreiApi.RegisterLoreiGrammar(m_ProgramGrammar);
        }
开发者ID:GregoryLand,项目名称:Lorei,代码行数:92,代码来源:LuaScriptProcessor.cs

示例12: CreateAndLoadGrammars

        private void CreateAndLoadGrammars()
        {
            List<GrammarBuilder> grammarBuffer = new List<GrammarBuilder>();
            Choices combinedGrammars = new Choices();

            // Run all data loaded
            foreach (ScriptData scriptItem in m_ScriptInfo.Values)
            {
                GrammarBuilder speechInfo = LoadSpeechInformation(scriptItem);
                if (speechInfo.ToString() != null)
                {
                    grammarBuffer.Add(speechInfo);
                }
            }

            // Setup the final choices
            combinedGrammars.Add(grammarBuffer.ToArray());

            // Setup the grammar
            if (grammarBuffer.Count > 0)
            {
                Grammar finalGrammarToReturn = new Grammar(combinedGrammars.ToGrammarBuilder());
                finalGrammarToReturn.Name = m_luaGrammarName;
                m_LoreiApi.RegisterLoreiGrammar(finalGrammarToReturn);
            }
        }
开发者ID:GregoryLand,项目名称:Lorei,代码行数:26,代码来源:LuaScriptProcessor.cs


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