Esempio n. 1
0
        private Grammar GetGrammar(VoiceListenerParameters parameters)
        {
            ListType = new List <Tuple <TermType, String> >();
            Choices ch_Dict = new Choices();

            foreach (VoiceTerm Value in parameters.Terms)
            {
                if (Value.Value.Equals("Range"))
                {
                    int[] arr = Enumerable.Range(0, 10).ToArray();
                    foreach (int y in arr)
                    {
                        String newint = y.ToString();
                        ch_Dict.Add(newint);
                        ListType.Add(Tuple.Create(TermType.Number, newint));
                    }
                }
                else
                {
                    string varadd = Value.Value;
                    ch_Dict.Add(Value.Value);
                    ListType.Add(Tuple.Create(Value.Type, varadd));
                }
            }

            GrammarBuilder gb_result = new GrammarBuilder(ch_Dict);
            Grammar        g_result  = new Grammar(gb_result);

            return(g_result);
        }
Esempio n. 2
0
 public void Initialize(VoiceListenerParameters parameters)
 {
     try
     {
         sre.SetInputToDefaultAudioDevice();
         sre.SpeechRecognized += SomethingHeard;
         Grammar g_HelloGoodbye = GetGrammar(parameters);
         sre.LoadGrammarAsync(g_HelloGoodbye);
         GetTolerance(parameters);
         logger.Info("Program started..");
     }
     catch (DivideByZeroException ex)
     {
         logger.Error("Initializing problems..", ex);
     }
 }
Esempio n. 3
0
 private void GetTolerance(VoiceListenerParameters parameters)
 {
     RealTolerance = parameters.Tolerance / 100;
 }