Exemple #1
0
 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}]");
 }
Exemple #2
0
        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;
        }
Exemple #3
0
 public override void OnDone(string utteranceId) => SpeechInProgress.TrySetResult(true);
Exemple #4
0
 static void OnFinishedSpeechUtterance(object sender, AVSpeechSynthesizerUteranceEventArgs args)
 {
     SpeechInProgress?.TrySetResult(false);
 }