1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Speech module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37
38
39
40#ifndef QTEXTTOSPEECH_H
41#define QTEXTTOSPEECH_H
42
43#include <QtTextToSpeech/qtexttospeech_global.h>
44#include <QtCore/qobject.h>
45#include <QtCore/qshareddata.h>
46#include <QtCore/QSharedDataPointer>
47#include <QtCore/qlocale.h>
48
49#include <QtTextToSpeech/qvoice.h>
50
51QT_BEGIN_NAMESPACE
52
53class QTextToSpeechPrivate;
54class Q_TEXTTOSPEECH_EXPORT QTextToSpeech : public QObject
55{
56 Q_OBJECT
57 Q_ENUMS(QTextToSpeech::State)
58 Q_PROPERTY(State state READ state NOTIFY stateChanged)
59 Q_PROPERTY(double volume READ volume WRITE setVolume NOTIFY volumeChanged)
60 Q_PROPERTY(double rate READ rate WRITE setRate NOTIFY rateChanged)
61 Q_PROPERTY(double pitch READ pitch WRITE setPitch NOTIFY pitchChanged)
62 Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged)
63 Q_PROPERTY(QVoice voice READ voice WRITE setVoice NOTIFY voiceChanged)
64 Q_DECLARE_PRIVATE(QTextToSpeech)
65public:
66 enum State {
67 Ready,
68 Speaking,
69 Paused,
70 BackendError
71 };
72
73 explicit QTextToSpeech(QObject *parent = nullptr);
74 explicit QTextToSpeech(const QString &engine, QObject *parent = nullptr);
75 State state() const;
76
77 QVector<QLocale> availableLocales() const;
78 QLocale locale() const;
79
80 QVoice voice() const;
81 QVector<QVoice> availableVoices() const;
82
83 double rate() const;
84 double pitch() const;
85 double volume() const;
86
87 static QStringList availableEngines();
88
89public Q_SLOTS:
90 void say(const QString &text);
91 void stop();
92 void pause();
93 void resume();
94
95 void setLocale(const QLocale &locale);
96
97 void setRate(double rate);
98 void setPitch(double pitch);
99 void setVolume(double volume);
100 void setVoice(const QVoice &voice);
101
102Q_SIGNALS:
103 void stateChanged(QTextToSpeech::State state);
104 void localeChanged(const QLocale &locale);
105 void rateChanged(double rate);
106 void pitchChanged(double pitch);
107 void volumeChanged(int volume); // ### Qt 6: remove this bad overload
108 void volumeChanged(double volume);
109 void voiceChanged(const QVoice &voice);
110
111private:
112 Q_DISABLE_COPY(QTextToSpeech)
113};
114
115Q_DECLARE_TYPEINFO(QTextToSpeech::State, Q_PRIMITIVE_TYPE);
116
117QT_END_NAMESPACE
118
119Q_DECLARE_METATYPE(QTextToSpeech::State)
120
121#endif
122

source code of qtspeech/src/tts/qtexttospeech.h