/// <summary> /// Starts the speech recognition for the main page, using the passed <paramref name="callbackFunction"/> and the passed <paramref name="textBox"/> /// </summary> /// <param name="callbackFunction"></param> /// <param name="textBox"></param> public static void StartListeningForMainPage(Action <string> callbackFunction, TextBox textBox) { // the main page takes priority over everything when it comes to listening, so force stop SpeechRecognitionUtils.Stop(); CurrentListener = typeof(MainPage); IsCurrentListenerDone = false; MainPageFunction = callbackFunction; MainPageTextBox = textBox; SpeechRecognitionUtils.StartLooping(MainPageFunction, MainPageTextBox); }
/// <summary> /// should only be called after <see cref="StartListeningForMainPage(Action{string}, TextBox)"/> has been called since the main page was navigated to /// </summary> private static void StartListeningForMainPage() { if (Utils.IsListeningSettingEnabled()) { if (MainPageFunction != null && MainPageTextBox != null) { // the main page takes priority over everything when it comes to listening, so force stop SpeechRecognitionUtils.Stop(); CurrentListener = typeof(MainPage); IsCurrentListenerDone = false; SpeechRecognitionUtils.StartLooping(MainPageFunction, MainPageTextBox); } } else { TextToSpeechEngine.SpeakText(new MediaElement(), "Sorry, but something went wrong with setting up your microphone. You cannot use me through speech, but you can still use the command bar at the bottom of the screen."); } }