/// <summary> /// Распознать рукописный текст и озвучить /// </summary> /// <param name="photo"></param> /// <returns></returns> private async Task RecognizeAndVoiceHandwrittenText(MediaFile photo) { BusyIndicator.IsVisible = true; BusyIndicator.IsBusy = true; this.BackgroundImageSource = ImageSource.FromStream(() => { return(photo.GetStreamWithImageRotatedForExternalStorage()); }); try { detectedText = await TextDetector.ReadHandwrittenText(photo.Path); BusyIndicator.IsVisible = false; BusyIndicator.IsBusy = false; await SpeechSyntezer.VoiceResultInEnglish(detectedText); } catch (TextDetectorException ex) { await SpeechSyntezer.VoiceResultInEnglish(ex.Message); } finally { BusyIndicator.IsVisible = false; BusyIndicator.IsBusy = false; } }
/// <summary> /// Распознать печатный текст и озвучить /// </summary> /// <param name="photo"></param> /// <returns></returns> private async Task RecognizeAndVoicePrintedText(MediaFile photo) { try { BusyIndicator.IsVisible = true; BusyIndicator.IsBusy = true; this.BackgroundImageSource = ImageSource.FromStream(() => { return(photo.GetStreamWithImageRotatedForExternalStorage()); }); detectedText = await TextDetector.ReadPrintedText(photo.Path); BusyIndicator.IsVisible = false; BusyIndicator.IsBusy = false; await SpeechSyntezer.VoiceResult(detectedText); } catch (TextDetectorException) { await SpeechSyntezer.VoiceResult("Ничего не распознано. Попробуйте другое фото"); } finally { BusyIndicator.IsVisible = false; BusyIndicator.IsBusy = false; } }