从Qt5.8推出的语音转换类,用于将文字转换为语音。通过setLocale()设置指定语言。
使用方式
增加模块:
QT += widgets texttospeech
头文件导入:
#include <QTextToSpeech>
具体代码:
QTextToSpeech *m_speech;
m_speech = new QTextToSpeech(this);
m_speech->setRate( 0.0);//设置语速-1.0-1.0
m_speech->setPitch(1.0);//设置音高-1.0-1.0
m_speech->setVolume(1.0);//设置音量0.0-1.0
QString sayWord("12345789");
m_speech->say(sayWord);