| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qtexttospeechengine.h" |
| 5 | |
| 6 | #include <QLoggingCategory> |
| 7 | |
| 8 | QT_BEGIN_NAMESPACE |
| 9 | |
| 10 | |
| 11 | /*! |
| 12 | \class QTextToSpeechEngine |
| 13 | \inmodule QtTextToSpeech |
| 14 | \brief The QTextToSpeechEngine class is the base for text-to-speech engine integrations. |
| 15 | \internal |
| 16 | |
| 17 | An engine implementation must derive from QTextToSpeechEngine and implement all |
| 18 | its pure virtual methods. |
| 19 | */ |
| 20 | |
| 21 | /*! |
| 22 | \fn QTextToSpeech::Capabilities QTextToSpeechEngine::capabilities() const |
| 23 | |
| 24 | Implementation of \l QTextToSpeech::engineCapabilities(). If this function is |
| 25 | not implemented, then the capabilities will be read from the plugin meta data. |
| 26 | */ |
| 27 | |
| 28 | /*! |
| 29 | \fn QList<QLocale> QTextToSpeechEngine::availableLocales() const |
| 30 | |
| 31 | Implementation of \l QTextToSpeech::availableLocales(). |
| 32 | */ |
| 33 | |
| 34 | /*! |
| 35 | \fn QList<QVoice> QTextToSpeechEngine::availableVoices() const |
| 36 | |
| 37 | Implementation of \l QTextToSpeech::availableVoices(). |
| 38 | */ |
| 39 | |
| 40 | /*! |
| 41 | \fn void QTextToSpeechEngine::say(const QString &text) |
| 42 | |
| 43 | Implementation of \l {QTextToSpeech::say()}{QTextToSpeech::say}(\a text). |
| 44 | */ |
| 45 | |
| 46 | /*! |
| 47 | \fn void QTextToSpeechEngine::stop(QTextToSpeech::BoundaryHint hint) |
| 48 | |
| 49 | Implementation of \l QTextToSpeech::stop(). |
| 50 | */ |
| 51 | |
| 52 | /*! |
| 53 | \fn void QTextToSpeechEngine::pause(QTextToSpeech::BoundaryHint hint) |
| 54 | |
| 55 | Implementation of \l QTextToSpeech::pause(). |
| 56 | */ |
| 57 | |
| 58 | /*! |
| 59 | \fn void QTextToSpeechEngine::resume() |
| 60 | |
| 61 | Implementation of \l QTextToSpeech::resume(). |
| 62 | */ |
| 63 | |
| 64 | /*! |
| 65 | \fn void QTextToSpeechEngine::rate() const |
| 66 | |
| 67 | Implementation of \l QTextToSpeech::rate(). |
| 68 | */ |
| 69 | |
| 70 | /*! |
| 71 | \fn bool QTextToSpeechEngine::setRate(double rate) |
| 72 | |
| 73 | Implementation of \l {QTextToSpeech::setRate()}{QTextToSpeech::setRate}(\a rate). |
| 74 | |
| 75 | Return \c true if the operation was successful. |
| 76 | */ |
| 77 | |
| 78 | /*! |
| 79 | \fn void QTextToSpeechEngine::pitch() const |
| 80 | |
| 81 | Implementation of \l QTextToSpeech::pitch(). |
| 82 | */ |
| 83 | |
| 84 | /*! |
| 85 | \fn bool QTextToSpeechEngine::setPitch(double pitch) |
| 86 | |
| 87 | Implementation of \l {QTextToSpeech::setPitch()}{QTextToSpeech::setPitch}(\a pitch). |
| 88 | |
| 89 | Return \c true if the operation was successful. |
| 90 | */ |
| 91 | |
| 92 | /*! |
| 93 | \fn QLocale QTextToSpeechEngine::locale() const |
| 94 | |
| 95 | Implementation of QTextToSpeech::locale(). |
| 96 | */ |
| 97 | |
| 98 | /*! |
| 99 | \fn bool QTextToSpeechEngine::setLocale(const QLocale &locale) |
| 100 | |
| 101 | Implementation \l {QTextToSpeech::setLocale()}{QTextToSpeech::setLocale}(\a locale). |
| 102 | |
| 103 | Return \c true if the operation was successful. In this case, the |
| 104 | current voice (as returned by voice()) should also be updated to a |
| 105 | new, valid value. |
| 106 | */ |
| 107 | |
| 108 | /*! |
| 109 | \fn double QTextToSpeechEngine::volume() const |
| 110 | |
| 111 | Implementation of QTextToSpeech::volume(). |
| 112 | */ |
| 113 | |
| 114 | /*! |
| 115 | \fn bool QTextToSpeechEngine::setVolume(double volume) |
| 116 | |
| 117 | Implementation of \l {QTextToSpeech::setVolume()}{QTextToSpeech::setVolume}(\a volume). |
| 118 | |
| 119 | Return \c true if the operation was successful. |
| 120 | */ |
| 121 | |
| 122 | /*! |
| 123 | \fn QVoice QTextToSpeechEngine::voice() const |
| 124 | |
| 125 | Implementation of \l QTextToSpeech::voice(). |
| 126 | */ |
| 127 | |
| 128 | /*! |
| 129 | \fn bool QTextToSpeechEngine::setVoice(const QVoice &voice) |
| 130 | |
| 131 | Implementation of \l {QTextToSpeech::setVoice()}{QTextToSpeech::setVoice}(\a voice). |
| 132 | |
| 133 | Return \c true if the operation was successful. |
| 134 | */ |
| 135 | |
| 136 | /*! |
| 137 | \fn QTextToSpeech::State QTextToSpeechEngine::state() const |
| 138 | |
| 139 | Implementation of QTextToSpeech::state(). |
| 140 | */ |
| 141 | |
| 142 | /*! |
| 143 | \fn void QTextToSpeechEngine::stateChanged(QTextToSpeech::State state) |
| 144 | |
| 145 | Emitted when the text-to-speech engine \a state has changed. |
| 146 | |
| 147 | This signal is connected to QTextToSpeech::stateChanged() signal. |
| 148 | */ |
| 149 | |
| 150 | /*! |
| 151 | Constructs the text-to-speech engine base class with \a parent. |
| 152 | */ |
| 153 | QTextToSpeechEngine::QTextToSpeechEngine(QObject *parent): |
| 154 | QObject(parent) |
| 155 | { |
| 156 | } |
| 157 | |
| 158 | QTextToSpeechEngine::~QTextToSpeechEngine() |
| 159 | { |
| 160 | } |
| 161 | |
| 162 | /*! |
| 163 | Creates a voice for a text-to-speech engine. |
| 164 | |
| 165 | Parameters \a name, \a locale, \a gender, \a age and \a data are directly |
| 166 | stored in the QVoice instance. |
| 167 | */ |
| 168 | QVoice QTextToSpeechEngine::createVoice(const QString &name, const QLocale &locale, |
| 169 | QVoice::Gender gender, QVoice::Age age, |
| 170 | const QVariant &data) |
| 171 | { |
| 172 | return QVoice(name, locale, gender, age, data); |
| 173 | } |
| 174 | |
| 175 | /*! |
| 176 | Returns the engine-specific private data for the given \a voice. |
| 177 | |
| 178 | */ |
| 179 | QVariant QTextToSpeechEngine::voiceData(const QVoice &voice) |
| 180 | { |
| 181 | return voice.data(); |
| 182 | } |
| 183 | |
| 184 | QT_END_NAMESPACE |
| 185 | |