1 | // Copyright (C) 2015 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only |
3 | |
4 | #ifndef QTEXTTOSPEECHENGINE_H |
5 | #define QTEXTTOSPEECHENGINE_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is part of the Qt TextToSpeech plugin API, with limited compatibility |
12 | // guarantees. |
13 | // Usage of this API may make your code source and binary incompatible with |
14 | // future versions of Qt. |
15 | // |
16 | |
17 | #include <QtTextToSpeech/qtexttospeech.h> |
18 | |
19 | #include <QtCore/QObject> |
20 | #include <QtCore/QLocale> |
21 | #include <QtCore/QDir> |
22 | #include <QtMultimedia/QAudioFormat> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QAudioFormat; |
27 | |
28 | class Q_TEXTTOSPEECH_EXPORT QTextToSpeechEngine : public QObject |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | explicit QTextToSpeechEngine(QObject *parent = nullptr); |
34 | ~QTextToSpeechEngine(); |
35 | |
36 | virtual QTextToSpeech::Capabilities capabilities() const |
37 | { |
38 | return QTextToSpeech::Capability::None; |
39 | } |
40 | virtual QList<QLocale> availableLocales() const = 0; |
41 | virtual QList<QVoice> availableVoices() const = 0; |
42 | |
43 | virtual void say(const QString &text) = 0; |
44 | virtual void synthesize(const QString &text) = 0; |
45 | virtual void stop(QTextToSpeech::BoundaryHint boundaryHint) = 0; |
46 | virtual void pause(QTextToSpeech::BoundaryHint boundaryHint) = 0; |
47 | virtual void resume() = 0; |
48 | |
49 | virtual double rate() const = 0; |
50 | virtual bool setRate(double rate) = 0; |
51 | virtual double pitch() const = 0; |
52 | virtual bool setPitch(double pitch) = 0; |
53 | virtual QLocale locale() const = 0; |
54 | virtual bool setLocale(const QLocale &locale) = 0; |
55 | virtual double volume() const = 0; |
56 | virtual bool setVolume(double volume) = 0; |
57 | virtual QVoice voice() const = 0; |
58 | virtual bool setVoice(const QVoice &voice) = 0; |
59 | virtual QTextToSpeech::State state() const = 0; |
60 | virtual QTextToSpeech::ErrorReason errorReason() const = 0; |
61 | virtual QString errorString() const = 0; |
62 | |
63 | protected: |
64 | static QVoice createVoice(const QString &name, const QLocale &locale, QVoice::Gender gender, |
65 | QVoice::Age age, const QVariant &data); |
66 | static QVariant voiceData(const QVoice &voice); |
67 | |
68 | Q_SIGNALS: |
69 | void stateChanged(QTextToSpeech::State state); |
70 | void errorOccurred(QTextToSpeech::ErrorReason error, const QString &errorString); |
71 | |
72 | void sayingWord(const QString &word, qsizetype start, qsizetype length); |
73 | void synthesized(const QAudioFormat &format, const QByteArray &data); |
74 | }; |
75 | |
76 | QT_END_NAMESPACE |
77 | |
78 | #endif |
79 | |