public async Task Speak(string text) { var tts = TinBotHelpers.WrapWithSSML(text); var ssStream = await Synth.SynthesizeSsmlToStreamAsync(tts); await ExecuteOnMainThread(() => { MediaElement.MarkerReached -= MediaElementOnMarkerReached; MediaElement.MarkerReached += MediaElementOnMarkerReached; MediaElement.Markers.Clear(); ssStream.Markers.ToList() .ForEach(x => MediaElement.Markers.Add(new TimelineMarker { Text = x.Text, Time = x.Time })); MediaElement.SetSource(ssStream, ssStream.ContentType); MediaElement.Play(); }); await Task.Delay(500); var playing = true; while (playing) { await ExecuteOnMainThread(() => { playing = MediaElement.CurrentState == MediaElementState.Playing || MediaElement.CurrentState == MediaElementState.Buffering || MediaElement.CurrentState == MediaElementState.Opening; }); await Task.Delay(500); } }