QT5实现TTS文本语音朗读功能

  #include "mainwindow.h"

  #include "ui_mainwindow.h"

  #pragma execution_character_set("utf-8")

  MainWindow::MainWindow(QWidget *parent) :

  QMainWindow(parent),

  ui(new Ui::MainWindow)

  {

  ui->setupUi(this);

  QIcon disconnect = QIcon(":/save.png");

  ui->pushButton_Speed->setText(QStringLiteral("Speech"));

  ui->pushButton_Speed->setIconSize(QSize(32, 32));

  ui->pushButton_Speed->setLayoutDirection(Qt::RightToLeft);

  ui->pushButton_Speed->setIcon(disconnect);

  }

  MainWindow::~MainWindow()

  {

  delete ui;

  }

  void MainWindow::on_pushButton_Speed_clicked()

  {

  m_Speech.say(ui->textEdit->toPlainText());

  }