I have a C++ program using Qt 6.5.2. I'm trying to use its QTextToSpeech class on Windows 11.
It works fine when I set the engine to "sapi", but when I set it to the higher quality "winrt" engine, it stops playing the speech after less than a second.
Here's the code:
#include <QtWidgets/QApplication>
#include <QTextToSpeech>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextToSpeech * speech = new QTextToSpeech();
speech->setLocale(QLocale(QLocale::English, QLocale::LatinScript, QLocale::UnitedStates));
speech->setEngine("winrt");
speech->say("Mary had a little lamb, its fleece was white as snow. How did that sound?");
return app.exec();
}
It says the word "Mary", then just stops. The QTextToSpeech state remains set to 1 (playing), and it reports no error. It just stops playing.
I tried using the lower quality "sapi" engine, and the full text was spoken.
How can I solve this?