/// <summary> /// Checks is current environment, like Internet or Recording devices, are good to work. /// If not: state labels become highlighted by colors. /// </summary> private bool _IsEnvironmentGood() { bool result = true; if (_IsMicrophoneOn()) { MicrophoneStatusBox.IsChecked = true; } else { MicrophoneStatusBox.IsChecked = false; MessageBox.Show("Не найдено ни одно звукозаписывающее устройство!"); result = false; } if (VoiceWebService.IsConnectionOn()) { InternetStatusBox.IsChecked = true; } else { InternetStatusBox.IsChecked = false; MessageBox.Show("Не удалось установить соединение с сервисом распознавания голоса!"); result = false; } return result; }
/// <summary> /// /// </summary> private void SendData() { var webRecognizer = new VoiceWebService(); var data = webRecognizer.RecognizeSoundFile(_tempFlacFilePath, _shortLanguageName); string text = string.Empty; if (data != null && data.Hypotheses != null && data.Hypotheses.Length > 0) { text = data.Hypotheses[0].Utterance; } else { text = (string)App.Current.FindResource("CanNotParse"); } // Raise event to show data. if (VoiceRecognized != null && !string.IsNullOrEmpty(text)) { VoiceRecognized(this, new VoiceRecognizedEventArgs(text)); } }