Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static SpeechRecognitionEngine Rec = new SpeechRecognitionEngine(new CultureInfo("es-ES"));
- private static SpeechSynthesizer Synth = new SpeechSynthesizer();
- private static System.Timers.Timer CountDown = new System.Timers.Timer();
- private static System.Media.SoundPlayer Player = new System.Media.SoundPlayer(@"sound.wav");
- public static DBConnection Connection = new DBConnection();
- public static void Start()
- {
- DBConnection connection = new DBConnection();
- Choices commands = new Choices();
- commands.Add(connection.RetrieveAllWords());
- GrammarBuilder gBuilder = new GrammarBuilder();
- gBuilder.Append(commands);
- Grammar grammar = new Grammar(new GrammarBuilder(gBuilder, 0, 100));
- CountDown.Elapsed += new ElapsedEventHandler(TimesUp);
- CountDown.Interval = 10000;
- CountDown.Enabled = true;
- CountDown.AutoReset = false;
- try{Rec.LoadGrammarAsync(grammar);}
- catch(FormatException e){MessageBox.Show(e.Message, e.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);}
- Rec.SetInputToDefaultAudioDevice();
- Rec.RecognizeAsync(RecognizeMode.Multiple);
- Rec.SpeechRecognized += Rec_SpeechRecognized;
- Application.Run(new ManualActivation());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement