void recognizer_SaidSomething(object sender, SpeechRecogniser.SaidSomethingArgs e) { //CHeck to see if 2 seconds have passed since last note played //If so, ok to make change. THis is to try and mitigate issue //where playing notes cause recogniser to switch instrument //but is not a satisfactory solution //Looking to improve the grammar for selection if(keyLastPressed.AddMilliseconds(2000) < DateTime.Now) { switch (e.Instruments) { case SpeechRecogniser.Instruments.Piano: //kinectSynth = new PianoSynth(); break; case SpeechRecogniser.Instruments.Organ: //kinectSynth = new SanfordSynth(); break; } resetKeys(); } banner.Content = e.Matched; }
private void InitialiseSpeechRecognition() { try { recognizer = new SpeechRecogniser(); } catch { recognizer = null; } if ((recognizer == null) || !recognizer.IsValid()) { BannerText.NewBanner("No speech recognition", screenRect, false, Color.FromArgb(90, 255, 255, 255)); recognizer = null; } else { recognizer.SaidSomething += recognizer_SaidSomething; banner.Content = "Piano"; } }