async void btnListenTask_Clicked(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(txtTask.Text)) { try { Loading(true); var servicioAudioRecorder = DependencyService.Get <IServicioAudioRecorder>(); var datos = await ServicioSpeech.ConvertirTexto_Voz(txtTask.Text); var archivo = servicioAudioRecorder.WriteAudioDataToFile(datos); await CrossMediaManager.Current.Play(archivo); } catch (Exception ex) { } finally { Loading(false); } } else { await DisplayAlert("Error", "The task can't be an empty string", "OK"); } }
async void btnDictarTarea_Clicked(object sender, EventArgs e) { try { var servicioAudioRecorder = DependencyService.Get <IServicioAudioRecorder>(); if (!estaGrabando) { servicioAudioRecorder.IniciarGrabacion(); btnDictarTarea.Text = "Finalizar"; Loading(true); } else { servicioAudioRecorder.DetenerGrabacion(); } estaGrabando = !estaGrabando; if (!estaGrabando) { var texto = await ServicioSpeech.ReconocerVozTexto(); txtTarea.Text = texto; } } catch (Exception ex) { txtTarea.Text = "Error durante la grabación"; } finally { if (!estaGrabando) { btnDictarTarea.Text = "Dictar Tarea"; Loading(false); } } }