/// <summary> /// Occurs when the 'Capture' command was received. /// </summary> /// <param name="e">Audio event args</param> private void CaptureCallback(AudioEventArgs e) { OnSnapshotClick(null, null); }
/// <summary> /// Called when a word or phrase was recognized. /// </summary> /// <param name="sender">Sender of event</param> /// <param name="e">Event args</param> private void SpeechRecognized(object sender, IavaSpeechRecognizedEventArgs e) { Console.WriteLine("\rSpeech Recognized: \t{0}\tConfidence:\t{1}", e.Text, e.Confidence); // If we just synced, set the flag and return if (e.Text.Contains(syncCommand)) { m_syncContext.Post(new SendOrPostCallback(delegate(object state) { OnSynced(this, e); }), null); return; } if (m_isSynced) { foreach (string command in AudioCallbacks.Keys) { if (e.Text.Contains(command.TrimEnd(new[] { '*' })) && e.Confidence > AudioConfidenceThreshold) { try { // We found a command, reset the timer ResetTimer(); AudioEventArgs args = new AudioEventArgs { Command = command }; if (command.EndsWith("*")) { // Extract the wildcard words spoken and split them into string recognizedPhrase = e.Text.Substring(command.Length - 1).ToLower(); args.CommandWildcards = new List<string>(recognizedPhrase.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); } // Invoke the callback m_syncContext.Post(new SendOrPostCallback(delegate(object state) { AudioCallbacks[command].Invoke(args); }), null); } catch (Exception exception) { StatusLogger.LogMessage(new Message("Error occured in speech recogition method or speech recognition callback.", GetType().Name, MessageType.Error, exception)); } break; } } } }
/// <summary> /// Occurs when a move south command was received. /// </summary> /// <param name="e">Audio event args</param> private void MoveSouthCallback(AudioEventArgs e) { MoveSouth(); DisplayStatus(String.Format("Audio: {0} Detected", e.Command)); ResetAudioSyncTime(); }
/// <summary> /// Occurs when a zoom out command was received. /// </summary> /// <param name="e">Audio event args</param> private void ZoomOutCallback(AudioEventArgs e) { ZoomOut(); DisplayStatus(String.Format("Audio: {0} Detected", e.Command)); ResetAudioSyncTime(); }
/// <summary> /// Occurs when a get recognizer statuses command was received. /// </summary> /// <param name="e">Audio event args</param> private void GetRecognizerStatusesCallback(AudioEventArgs e) { DisplayStatus(String.Format("Audio Recognizer Status: {0} Gesture Recognizer Status: {1}", m_pAudioRecognizer.Status, m_pGestureRecognizer.Status)); ResetAudioSyncTime(); }
/// <summary> /// Occurs when a locate wildcard command was received. /// </summary> /// <param name="e">Audio event args</param> private void LocateCityCallback(AudioEventArgs e) { if (e.CommandWildcards != null && e.CommandWildcards.Count > 0) { string wildCardString = string.Empty; foreach (string wildcard in e.CommandWildcards) { wildCardString += wildcard + " "; } wildCardString = wildCardString.Trim(); MapPoint point = CityLocations.GetCityLocation(wildCardString); if (point != null) { map.PanTo(point); DisplayStatus(String.Format("Audio: {0} {1}", e.Command.TrimEnd('*'), wildCardString)); ResetAudioSyncTime(); } } }
/// <summary> /// Occurs when a blow up command was received. /// </summary> /// <param name="e">Audio event args</param> private void BlowUp(AudioEventArgs e) { this.Window.Close(); }
/// <summary> /// Occurs when change audio sync command was recieved. /// </summary> /// <param name="e">Audio event args</param> private void ChangeAudioSyncCommandCallback(AudioEventArgs e) { if (e.CommandWildcards != null && e.CommandWildcards.Count > 0) { string commandWildcards = string.Empty; foreach (string wildcard in e.CommandWildcards) { commandWildcards += wildcard + " "; } commandWildcards = commandWildcards.Trim(); m_pAudioRecognizer.SyncCommand = commandWildcards.Trim(); DisplayStatus(String.Format("Sync Command Changed To: {0}", m_pAudioRecognizer.SyncCommand)); ResetAudioSyncTime(); } }
/// <summary> /// Occurs when the 'Load Gestures' command was received. /// </summary> /// <param name="e">Audio event args</param> private void LoadGesturesCallback(AudioEventArgs e) { OnLoadGesturesClick(null, null); }
/// <summary> /// Occurs when the 'Stop Test' command was received. /// </summary> /// <param name="e">Audio event args</param> private void StopTestCallback(AudioEventArgs e) { if (m_bStarted) { OnStartTestClick(null, null); } }
private void TestAudioCallback(AudioEventArgs e) { btnTest.IsChecked = true; }
private void ExitAudioCallback(AudioEventArgs e) { this.Close(); }
private void CreateAudioCallback(AudioEventArgs e) { btnCreate.IsChecked = true; }