恩施土家族苗族自治州网站建设_网站建设公司_Python_seo优化
2026/1/16 12:34:32 网站建设 项目流程

Qt5 朗读语音

在.pro文件中添加

QT+=texttospeech LIBS+=-lole32


main.cpp

#include "mainwindow.h"#include <QApplication>#include <windows.h>#include <sapi.h>#include <sphelper.h>#include <QDebug>#include <QTextToSpeech>void speakQt(const QString&text){QTextToSpeech *speech=new QTextToSpeech();if(speech->availableVoices().isEmpty()){qDebug()<<"No TTS voices available";return;}speech->say(text);}int main(int argc, char *argv[]){QApplication a(argc, argv);MainWindow w;w.show();QStringtext="出现告警,请关注";speakQt(text);returna.exec();}

可以听到朗读的声音

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询