public override void OnError(string utteranceId) { SpeechInProgress.TrySetResult(false); Log.For(typeof(Speech)).Error($"Error in text-to-speech engine when listening to progress. [{utteranceId}]"); }
static async Task DoSpeak(string text, Settings settings) { Synthesizer.Voice = settings.SelectVoice(); Synthesizer.Options.SpeakingRate = GetNormalizedSpeed(settings.Speed); var handler = new TypedEventHandler <MediaPlayer, object>((sender, args) => SpeechInProgress?.TrySetResult(true)); Player.MediaEnded += handler; var stream = (await Synthesizer.SynthesizeTextToStreamAsync(text)); Player.SetStreamSource(stream); Player.Play(); await SpeechInProgress.Task; Player.MediaEnded -= handler; }
public override void OnDone(string utteranceId) => SpeechInProgress.TrySetResult(true);
static void OnFinishedSpeechUtterance(object sender, AVSpeechSynthesizerUteranceEventArgs args) { SpeechInProgress?.TrySetResult(false); }