I'm working on a TTS (Text to Speech) application and I need to present the duration of each speech. The problem is that it always returns zero. Any help is most welcome. Thanks.
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
MediaPlayerElement mediaPlayerElement = new MediaPlayerElement();
SpeechSynthesisStream stream = await synthesizer.SynthesizeTextToStreamAsync("Some text...");
mediaPlayerElement.Source = MediaSource.CreateFromStream(stream, stream.ContentType);
mediaPlayerElement.MediaPlayer.Play();
string strDuration = mediaPlayerElement.MediaPlayer.PlaybackSession.NaturalDuration.Milliseconds.ToString();
MessageDialog msgDlg = new MessageDialog(strDuration);
await msgDlg.ShowAsync();