I would like to implement the text to speech feature in my app. I see there are docs on how to do this here: https://docs.microsoft.com/en-us/uwp/api/windows.media.speechsynthesis.speechsynthesizer .
However the example does not compile on a modern winrt app.
// The object for controlling the speech synthesis engine (voice).
synth = ref new SpeechSynthesizer();
// The media object for controlling and playing audio.
media = ref new MediaElement();
// The string to speak.
String^ text = "Hello World";
// Generate the audio stream from plain text.
task speakTask = create_task(synth- >SynthesizeTextToStreamAsync(text));
speakTask.then([this, text](SpeechSynthesisStream ^speechStream)
{
// Send the stream to the media object.
// media === MediaElement XAML object.
media->SetSource(speechStream, speechStream->ContentType);
media->AutoPlay = true;
media->Play();
});
How can this example be adapted to work in a modern c++ winrt uwp app?