| 1234567891011121314151617181920212223242526272829303132 |
- #include "speechthread.h"
- //#include <QtDebug>
- SpeechThread::SpeechThread(QObject *parent) : QObject(parent)
- {
- SpeechList.clear();
- tts = new QTextToSpeech(this);
- tts->setVolume(1.0);
- timer = new QTimer(this);
- connect(timer,&QTimer::timeout,this,&SpeechThread::timeout);
- }
- void SpeechThread::append(QString speech)
- {
- SpeechList.append(speech);
- }
- void SpeechThread::start()
- {
- timer->start(1500);
- }
- void SpeechThread::timeout()
- {
- if(SpeechList.length()>0){
- if(tts->state()==QTextToSpeech::Ready){
- tts->say(SpeechList.first());
- // qDebug()<<SpeechList.first();
- SpeechList.removeFirst();
- }
- }
- }
|