direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
speakThread.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #ifndef SPEAKTHREAD_H
22 #define SPEAKTHREAD_H
23 
24 #include <QtGlobal> // for Q_OS_* Makro!
25 
26 //-------------------------------------------------------------------
27 #ifdef Q_OS_LINUX // currently supported only under linux (no MAC OS at the moment)
28 #include "speak_lib.h"
29 #endif
30 #include <QThread>
31 //-------------------------------------------------------------------
32 
33 
41 class SpeakThread : public QThread
42 {
43  Q_OBJECT
44 
45  public:
46  SpeakThread();
47  ~SpeakThread();
48  void stop();
49  virtual void run();
50  void setLanguage(QString language);
51  void setVoice(unsigned char gender,unsigned char age);
52  void setRate(int value);
53 
54 
55  public slots:
61  void speak(QString text, int phase=0);
62 
63 
64  signals:
69  void speechCompleted(int mPhase);
70 
71 
72  private:
73  QString removeHTML(QString string);
74 
75  volatile bool stopped;
76  bool saySomething;
77  QString textToSpeak;
78  int mPhase;
79 
80  // Every thread sleeps some time, for having a bit more time fo the other threads!
81  // Time in milliseconds
82  static const unsigned long THREADSLEEPTIME = 200; // Default value: 600 ms
83 };
84 
85 #endif