Exemplo n.º 1
0
 public async Task Speak(string text)
 {
     await Threading.MarshallToUiThread(async() =>
     {
         if (audioOut.CurrentState == Windows.UI.Xaml.Media.MediaElementState.Playing)
         {
             audioOut.Stop();
         }
         var voiceStream = await speechSynth.SynthesizeTextToStreamAsync(text);
         if (voiceStream == null)
         {
             System.Diagnostics.Debug.WriteLine($"Could not synthesize voice stream from text: {text}.");
         }
         audioOut.SetSource(voiceStream, voiceStream.ContentType);
         audioOut.Play();
     });
 }