private async Task ToggleRecordStop() { if (recordStopButton.Content.Equals("Record")) { graph.Start(); recordStopButton.Content = "Stop"; audioPipe1.Fill = new SolidColorBrush(Colors.Blue); audioPipe2.Fill = new SolidColorBrush(Colors.Blue); } else if (recordStopButton.Content.Equals("Stop")) { // Good idea to stop the graph to avoid data loss graph.Stop(); audioPipe1.Fill = new SolidColorBrush(Color.FromArgb(255, 49, 49, 49)); audioPipe2.Fill = new SolidColorBrush(Color.FromArgb(255, 49, 49, 49)); TranscodeFailureReason finalizeResult = await fileOutputNode.FinalizeAsync(); if (finalizeResult != TranscodeFailureReason.None) { // Finalization of file failed. Check result code to see why rootPage.NotifyUser(String.Format("Finalization of file failed because {0}", finalizeResult.ToString()), NotifyType.ErrorMessage); fileButton.Background = new SolidColorBrush(Colors.Red); return; } recordStopButton.Content = "Record"; rootPage.NotifyUser("Recording to file completed successfully!", NotifyType.StatusMessage); fileButton.Background = new SolidColorBrush(Colors.Green); recordStopButton.IsEnabled = false; createGraphButton.IsEnabled = false; } }
async void TranscodeFailure(TranscodeFailureReason reason) { try { if (_OutputFile != null) { await _OutputFile.DeleteAsync(); } } catch (Exception exception) { TranscodeError(exception.Message); } switch (reason) { case TranscodeFailureReason.CodecNotFound: TranscodeError("Codec not found."); break; case TranscodeFailureReason.InvalidProfile: TranscodeError("Invalid profile."); break; default: TranscodeError("Unknown failure."); break; } }
private async void RecordStart(object sender, TappedRoutedEventArgs e) { if (!recordButtonPushed) { recordButtonPushed = true; __start_record_button.Source = new BitmapImage(new Uri(this.BaseUri, "Assets/mic-512_pushed.png")); await CreateAudioGraph(); graph.Start(); } else { recordButtonPushed = false; __start_record_button.Source = new BitmapImage(new Uri(this.BaseUri, "Assets/mic-512.png")); graph.Stop(); TranscodeFailureReason finalizeResult = await fileOutputNode.FinalizeAsync(); if (finalizeResult != TranscodeFailureReason.None) { // Finalization of file failed. Check result code to see why return; } Guid requestId = Guid.NewGuid(); var Uri = @"https://speech.platform.bing.com/recognize?version=3.0&requestid=" + requestId.ToString() + @"&appID=D4D52672-91D7-4C74-8AD8-42B1D981415A&format=json&locale=en-US&device.os=Windows%20OS&scenarios=ulm&instanceid=f1efbd27-25fd-4212-9332-77cd63176112"; var resp = SendRequestAsync(Uri, accessToken, "audio/wav; samplerate=16000", path); string json = resp; ParsedJson jsonResp = JsonConvert.DeserializeObject <ParsedJson>(json); json = jsonResp.header.lexical.Replace("<profanity>", ""); json = json.Replace("</profanity>", ""); if (allDone) { precise = 0; count = 0; Result.Text = ""; allDone = false; } var temp = StringDifference(parts[count], json, jsonResp.results[0].confidence); precise += temp; Result.Text += json + " - " + temp.ToString("F1") + " %\n"; if (count + 1 < parts.Length) { count++; } else { Result.Text += "Общая точность: " + (precise / parts.Length).ToString("F1") + "%\n"; allDone = true; } } }
async void TranscodeFailure(TranscodeFailureReason reason) { try { if (_OutputFile != null) { await _OutputFile.DeleteAsync(); } } catch (Exception exception) { } }
public async void RecordOrStop(int value) { if (value == 1) { secondstimer.Start(); graph.Start(); secondscount = 0; await Recordings.ShowAsync(); } else { secondstimer.Stop(); graph.Stop(); TranscodeFailureReason finalizeResult = await fileOutputNode.FinalizeAsync(); if (finalizeResult != TranscodeFailureReason.None) { MessageDialog md = new MessageDialog("Error in saving the audio", "OOPS!!"); await md.ShowAsync(); return; } else { MessageDialog md = new MessageDialog("Sucessfully saved", "Hurray!!"); await md.ShowAsync(); UpdateInCommentSection(storageFile.Name); com1.Add(new comments { empname = pd.emp.name, message = storageFile.Name, dt = DateTime.Now, empid = pd.emp.id, IsFile = true, storagefile = storageFile }); commentsSection.ItemsSource = null; commentsSection.ItemsSource = com1; Recordings.Hide(); } } }