Text To Speech(TTS) in C++

0

I want to add TTS to my program in c++. The code i wrote shows the following exception:

Exception thrown at 0x00007FF8C2199E08 in GettingData.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x0000000BFA1FC830. HRESULT:0x80070002 The system cannot find the file specified.

WinRT information: The system cannot find the file specified.

Stack trace:
[External Code]
GettingData.exe!GettingData::MainPage::btnTextToSpeech_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) Line 198
[External Code]

If there is a handler for this exception, the program may be safely continued..

I attach my short code and i dont know why doesnt it work, i will be glad for some help.

void MainPage::btnTextToSpeech_Click(Platform::Object^ sender,
Windows::UI::Xaml::RoutedEventArgs^ e)
{

String^ textToSpeech="Hello World";
//Exception occurs after I paste the following code on the next line only.
auto synth = ref new SpeechSynthesizer();
task<SpeechSynthesisStream^>speakTask = create_task(synth->SynthesizeTextToStreamAsync(textToSpeech));
speakTask.then([this, textToSpeech](SpeechSynthesisStream^ speechStream)
{
    auto media = ref new MediaElement();
    media->SetSource(speechStream, speechStream->ContentType);
    media->AutoPlay = true;
    media->Play();  
});

The Exception occurs when I pass the line under comment above.

.net
c++-cli
text-to-speech
asked on Stack Overflow Oct 5, 2017 by Yakov Borohov • edited Oct 5, 2017 by Volkan Güven

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0