private async void addToDoButton_Click(object sender, EventArgs e) { var selectedLanguage = checkSelectedLanguage(); SpeechService speechService = new SpeechService(); var result = await speechService.RecognizeSpeechAsync(selectedLanguage); result = trimResult(result); var newTodo = todos.FirstOrDefault(s => s.Title == result); if (newTodo == null) { var todo = new Todo(result); todos.Add(todo); ListViewItem item = new ListViewItem(todo.Title); var toDoStatus = checkToDoStatus(todo); item.SubItems.Add(toDoStatus); listViewAll.Items.Add(item); updateListViewActive(); updateListViewAll(); updateListViewCompleted(); } else { MessageBox.Show($"Todo { result } already exists"); } }
private async void markAsDoneButton_Click(object sender, EventArgs e) { var selectedLanguage = checkSelectedLanguage(); SpeechService speechService = new SpeechService(); var result = await speechService.RecognizeSpeechAsync(selectedLanguage); result = trimResult(result); var completedTodo = todos.FirstOrDefault(s => s.Title == result); if (completedTodo == null) { MessageBox.Show("Todo with this title does not exist"); } else { completedTodo.Completed = true; updateListViewActive(); updateListViewAll(); updateListViewCompleted(); } }
void RecognizeSpeech() { //if (this.availableGrammars == null || // this.availableGrammars.Count == 0) //{ // return; //} this.RecognizingProgress.Visibility = Visibility.Visible; if (this.AudioStream != null && this.AudioStream.Length != 0) { SpeechService.RecognizeSpeechAsync( HawaiiClient.HawaiiApplicationId, SpeechService.DefaultGrammar, this.AudioStream.ToArray(), (result) => Dispatcher.BeginInvoke(() => this.OnSpeechRecognitionCompleted(result))); } else { MessageBox.Show("Invalid speech buffer found. Record speech and try again.", "Error", MessageBoxButton.OK); } }