summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Heikkinen <jani.heikkinen@qt.io>2017-02-09 14:57:52 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2017-02-09 14:57:52 +0200
commit5de7101be14e7711eae6d28d187709656bc6f51d (patch)
treeca4297f13c08f8ed704235bed5fafd26ffa8113a
parent43fed1e8fa150ce9441281ad1891e9f2029b6d51 (diff)
parentecc425e33290abdda9a193b57f160d3195930586 (diff)
Merge remote-tracking branch 'origin/5.8' into 5.9v5.9.0-alpha1
Conflicts: .qmake.conf Task-number: QTBUG-58418 Change-Id: I2f235e738fabc7948697fcac167bf442882a489d
-rw-r--r--.gitattributes3
-rw-r--r--.tag1
-rw-r--r--src/plugins/tts/ios/ios.pro24
-rw-r--r--src/plugins/tts/ios/ios_plugin.json6
-rw-r--r--src/plugins/tts/ios/qtexttospeech_ios.h93
-rw-r--r--src/plugins/tts/ios/qtexttospeech_ios.mm282
-rw-r--r--src/plugins/tts/ios/qtexttospeech_ios_plugin.cpp44
-rw-r--r--src/plugins/tts/ios/qtexttospeech_ios_plugin.h63
-rw-r--r--src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp8
-rw-r--r--src/plugins/tts/tts.pro1
-rw-r--r--src/tts/qtexttospeech.cpp55
-rw-r--r--src/tts/qvoice.cpp31
12 files changed, 584 insertions, 27 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..6b2abde
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,3 @@
+.tag export-subst
+.gitattributes export-ignore
+.gitignore export-ignore
diff --git a/.tag b/.tag
new file mode 100644
index 0000000..6828f88
--- /dev/null
+++ b/.tag
@@ -0,0 +1 @@
+$Format:%H$
diff --git a/src/plugins/tts/ios/ios.pro b/src/plugins/tts/ios/ios.pro
new file mode 100644
index 0000000..247aac4
--- /dev/null
+++ b/src/plugins/tts/ios/ios.pro
@@ -0,0 +1,24 @@
+TARGET = qtexttospeech_speechios
+PLUGIN_TYPE = texttospeech
+PLUGIN_CLASS_NAME = QTextToSpeechPluginIos
+
+load(qt_plugin)
+
+QT += core texttospeech
+LIBS += -framework AVFoundation
+
+HEADERS += \
+ qtexttospeech_ios_plugin.h \
+ qtexttospeech_ios.h \
+
+OBJECTIVE_HEADERS += \
+ qtexttospeech_ios.h \
+
+SOURCES += \
+ qtexttospeech_ios_plugin.cpp \
+
+OBJECTIVE_SOURCES += \
+ qtexttospeech_ios.mm \
+
+OTHER_FILES += \
+ ios_plugin.json
diff --git a/src/plugins/tts/ios/ios_plugin.json b/src/plugins/tts/ios/ios_plugin.json
new file mode 100644
index 0000000..694c226
--- /dev/null
+++ b/src/plugins/tts/ios/ios_plugin.json
@@ -0,0 +1,6 @@
+{
+ "Keys": ["ios"],
+ "Provider": "ios",
+ "Version": 100,
+ "Features": []
+}
diff --git a/src/plugins/tts/ios/qtexttospeech_ios.h b/src/plugins/tts/ios/qtexttospeech_ios.h
new file mode 100644
index 0000000..8791f94
--- /dev/null
+++ b/src/plugins/tts/ios/qtexttospeech_ios.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Speech module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXTTOSPEECHENGINE_IOS_H
+#define QTEXTTOSPEECHENGINE_IOS_H
+
+#include <QtCore/qvector.h>
+#include <QtTextToSpeech/qtexttospeechengine.h>
+#include <QtTextToSpeech/qvoice.h>
+
+Q_FORWARD_DECLARE_OBJC_CLASS(AVSpeechSynthesizer);
+Q_FORWARD_DECLARE_OBJC_CLASS(AVSpeechSynthesisVoice);
+
+QT_BEGIN_NAMESPACE
+
+class QTextToSpeechEngineIos : public QTextToSpeechEngine
+{
+ Q_OBJECT
+
+public:
+ QTextToSpeechEngineIos(const QVariantMap &parameters, QObject *parent);
+ ~QTextToSpeechEngineIos();
+
+ QVector<QLocale> availableLocales() const override;
+ QVector<QVoice> availableVoices() const override;
+ void say(const QString &text) override;
+ void stop() override;
+ void pause() override;
+ void resume() override;
+ double rate() const override;
+ bool setRate(double rate) override;
+ double pitch() const override;
+ bool setPitch(double pitch) override;
+ QLocale locale() const override;
+ bool setLocale(const QLocale &locale) override;
+ double volume() const override;
+ bool setVolume(double volume) override;
+ QVoice voice() const override;
+ bool setVoice(const QVoice &voice) override;
+ QTextToSpeech::State state() const override;
+
+ void setState(QTextToSpeech::State state);
+
+private:
+ AVSpeechSynthesisVoice *fromQVoice(const QVoice &voice) const;
+ QVoice toQVoice(AVSpeechSynthesisVoice *avVoice) const;
+
+ AVSpeechSynthesizer *m_speechSynthesizer;
+ QLocale m_locale;
+ QVoice m_voice;
+ QTextToSpeech::State m_state;
+
+ double m_pitch;
+ double m_rate;
+ double m_volume;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/tts/ios/qtexttospeech_ios.mm b/src/plugins/tts/ios/qtexttospeech_ios.mm
new file mode 100644
index 0000000..ca885a5
--- /dev/null
+++ b/src/plugins/tts/ios/qtexttospeech_ios.mm
@@ -0,0 +1,282 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Speech module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <AVFoundation/AVFoundation.h>
+
+#include "qtexttospeech_ios.h"
+
+@interface QIOSSpeechSynthesizerDelegate : NSObject <AVSpeechSynthesizerDelegate> {
+ QTextToSpeechEngineIos *_engine;
+}
+@end
+
+@implementation QIOSSpeechSynthesizerDelegate
+
+- (id)initWithQIOSTextToSpeechEngineIos:(QTextToSpeechEngineIos *)engine
+{
+ if (self = [super init]) {
+ _engine = engine;
+ }
+ return self;
+}
+
+- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didCancelSpeechUtterance:(AVSpeechUtterance *)utterance
+{
+ Q_UNUSED(synthesizer);
+ Q_UNUSED(utterance);
+ _engine->setState(QTextToSpeech::Ready);
+}
+
+- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didContinueSpeechUtterance:(AVSpeechUtterance *)utterance
+{
+ Q_UNUSED(synthesizer);
+ Q_UNUSED(utterance);
+ _engine->setState(QTextToSpeech::Speaking);
+}
+
+- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance *)utterance
+{
+ Q_UNUSED(synthesizer);
+ Q_UNUSED(utterance);
+ _engine->setState(QTextToSpeech::Ready);
+}
+
+- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didPauseSpeechUtterance:(AVSpeechUtterance *)utterance
+{
+ Q_UNUSED(synthesizer);
+ Q_UNUSED(utterance);
+ _engine->setState(QTextToSpeech::Paused);
+}
+
+- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didStartSpeechUtterance:(AVSpeechUtterance *)utterance
+{
+ Q_UNUSED(synthesizer);
+ Q_UNUSED(utterance);
+ _engine->setState(QTextToSpeech::Speaking);
+}
+
+@end
+
+// -------------------------------------------------------------------------
+
+QT_BEGIN_NAMESPACE
+
+QTextToSpeechEngineIos::QTextToSpeechEngineIos(const QVariantMap &/*parameters*/, QObject *parent)
+ : QTextToSpeechEngine(parent)
+ , m_speechSynthesizer([AVSpeechSynthesizer new])
+ , m_locale(QLocale())
+ , m_voice(QVoice())
+ , m_state(QTextToSpeech::Ready)
+ , m_pitch(0)
+ , m_rate(0)
+ , m_volume(1)
+{
+ m_speechSynthesizer.delegate = [[QIOSSpeechSynthesizerDelegate alloc] initWithQIOSTextToSpeechEngineIos:this];
+}
+
+QTextToSpeechEngineIos::~QTextToSpeechEngineIos()
+{
+ [m_speechSynthesizer.delegate autorelease];
+ [m_speechSynthesizer release];
+}
+
+void QTextToSpeechEngineIos::say(const QString &text)
+{
+ stop();
+
+ AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text.toNSString()];
+ utterance.volume = m_volume;
+ utterance.voice = fromQVoice(m_voice);
+ // Pitch: Qt range: [-1.0, 1.0], iOS range: [0.5, 2.0]
+ utterance.pitchMultiplier = 0.5 + ((m_pitch + 1.0) / 2.0 * 1.5);
+
+ if (m_rate >= 0) {
+ // The QtTextToSpeech documentation states that a rate of 0.0 represents normal speech flow.
+ // To map that to AVSpeechUtteranceDefaultSpeechRate while at the same time preserve the Qt
+ // range [-1.0, 1.0], we choose to operate with two differente rate convertions; one for
+ // values in the range [-1, 0), and for [0, 1].
+ float range = AVSpeechUtteranceMaximumSpeechRate - AVSpeechUtteranceDefaultSpeechRate;
+ utterance.rate = AVSpeechUtteranceDefaultSpeechRate + (m_rate * range);
+ } else {
+ float range = AVSpeechUtteranceDefaultSpeechRate - AVSpeechUtteranceMinimumSpeechRate;
+ utterance.rate = AVSpeechUtteranceMinimumSpeechRate + (m_rate * range);
+ }
+
+ [m_speechSynthesizer speakUtterance:utterance];
+}
+
+void QTextToSpeechEngineIos::stop()
+{
+ [m_speechSynthesizer stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];
+}
+
+void QTextToSpeechEngineIos::pause()
+{
+ [m_speechSynthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryWord];
+}
+
+void QTextToSpeechEngineIos::resume()
+{
+ [m_speechSynthesizer continueSpeaking];
+}
+
+bool QTextToSpeechEngineIos::setRate(double rate)
+{
+ m_rate = rate;
+ return true;
+}
+
+double QTextToSpeechEngineIos::rate() const
+{
+ return m_rate;
+}
+
+bool QTextToSpeechEngineIos::setPitch(double pitch)
+{
+ m_pitch = pitch;
+ return true;
+}
+
+double QTextToSpeechEngineIos::pitch() const
+{
+ return m_pitch;
+}
+
+bool QTextToSpeechEngineIos::setVolume(double volume)
+{
+ m_volume = volume;
+ return true;
+}
+
+double QTextToSpeechEngineIos::volume() const
+{
+ return m_volume;
+}
+
+QVector<QLocale> QTextToSpeechEngineIos::availableLocales() const
+{
+ QVector<QLocale> localeVector;
+ QString prevVoiceLanguage;
+ for (AVSpeechSynthesisVoice *voice in [AVSpeechSynthesisVoice speechVoices]) {
+ QString language = QString::fromNSString(voice.language);
+ // Filter out languages already added. A language will occur several times
+ // in sequence if more than one voice name exists for them.
+ if (language == prevVoiceLanguage)
+ continue;
+ localeVector << QLocale(language);
+ prevVoiceLanguage = language;
+ }
+
+ return localeVector;
+}
+
+bool QTextToSpeechEngineIos::setLocale(const QLocale &locale)
+{
+ NSString *bcp47 = locale.bcp47Name().toNSString();
+ AVSpeechSynthesisVoice *defaultAvVoice = [AVSpeechSynthesisVoice voiceWithLanguage:bcp47];
+ if (!defaultAvVoice)
+ return false;
+
+ m_locale = locale;
+ m_voice = toQVoice(defaultAvVoice);
+ return true;
+}
+
+QLocale QTextToSpeechEngineIos::locale() const
+{
+ return m_locale;
+}
+
+QVector<QVoice> QTextToSpeechEngineIos::availableVoices() const
+{
+ QVector<QVoice> voiceVector;
+ QString countryCode = m_locale.name().mid(3);
+
+ for (AVSpeechSynthesisVoice *avVoice in [AVSpeechSynthesisVoice speechVoices]) {
+ if (QString::fromNSString(avVoice.language).endsWith(countryCode))
+ voiceVector << toQVoice(avVoice);
+ }
+
+ return voiceVector;
+}
+
+bool QTextToSpeechEngineIos::setVoice(const QVoice &voice)
+{
+ AVSpeechSynthesisVoice *avVoice = fromQVoice(voice);
+ if (!avVoice)
+ return false;
+
+ m_voice = voice;
+ return true;
+}
+
+QVoice QTextToSpeechEngineIos::voice() const
+{
+ return m_voice;
+}
+
+AVSpeechSynthesisVoice *QTextToSpeechEngineIos::fromQVoice(const QVoice &voice) const
+{
+ for (AVSpeechSynthesisVoice *avVoice in [AVSpeechSynthesisVoice speechVoices]) {
+ if (voice.name() == QString::fromNSString(avVoice.name))
+ return avVoice;
+ }
+
+ return Q_NULLPTR;
+}
+
+QVoice QTextToSpeechEngineIos::toQVoice(AVSpeechSynthesisVoice *avVoice) const
+{
+ return createVoice(QString::fromNSString(avVoice.name), QVoice::Unknown, QVoice::Other, QVariant());
+}
+
+void QTextToSpeechEngineIos::setState(QTextToSpeech::State state)
+{
+ if (m_state == state)
+ return;
+
+ m_state = state;
+ emit stateChanged(m_state);
+}
+
+QTextToSpeech::State QTextToSpeechEngineIos::state() const
+{
+ return m_state;
+}
+
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/tts/ios/qtexttospeech_ios_plugin.cpp b/src/plugins/tts/ios/qtexttospeech_ios_plugin.cpp
new file mode 100644
index 0000000..db03b13
--- /dev/null
+++ b/src/plugins/tts/ios/qtexttospeech_ios_plugin.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Speech module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtexttospeech_ios_plugin.h"
+#include "qtexttospeech_ios.h"
+
+QTextToSpeechEngine *QTextToSpeechPluginIos::createTextToSpeechEngine(const QVariantMap &parameters, QObject *parent, QString *errorString) const
+{
+ Q_UNUSED(errorString)
+ return new QTextToSpeechEngineIos(parameters, parent);
+}
diff --git a/src/plugins/tts/ios/qtexttospeech_ios_plugin.h b/src/plugins/tts/ios/qtexttospeech_ios_plugin.h
new file mode 100644
index 0000000..f6d4e0d
--- /dev/null
+++ b/src/plugins/tts/ios/qtexttospeech_ios_plugin.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Speech module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXTTOSPEECHPLUGIN_IOS_H
+#define QTEXTTOSPEECHPLUGIN_IOS_H
+
+#include <QtCore/QObject>
+#include <QtCore/QLoggingCategory>
+#include <QtTextToSpeech/qtexttospeechplugin.h>
+#include <QtTextToSpeech/qtexttospeechengine.h>
+
+QT_BEGIN_NAMESPACE
+
+class QTextToSpeechPluginIos : public QObject, public QTextToSpeechPlugin
+{
+ Q_OBJECT
+ Q_INTERFACES(QTextToSpeechPlugin)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.speech.tts.plugin/5.0"
+ FILE "ios_plugin.json")
+
+public:
+ QTextToSpeechEngine *createTextToSpeechEngine(
+ const QVariantMap &parameters,
+ QObject *parent,
+ QString *errorString) const;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
index 9ee406c..118a71c 100644
--- a/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+++ b/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
@@ -72,9 +72,11 @@ QTextToSpeechEngineSpeechd::QTextToSpeechEngineSpeechd(const QVariantMap &, QObj
QTextToSpeechEngineSpeechd::~QTextToSpeechEngineSpeechd()
{
- if ((m_state != QTextToSpeech::BackendError) && (m_state != QTextToSpeech::Ready) && speechDispatcher)
- spd_cancel_all(speechDispatcher);
- spd_close(speechDispatcher);
+ if (speechDispatcher) {
+ if ((m_state != QTextToSpeech::BackendError) && (m_state != QTextToSpeech::Ready))
+ spd_cancel_all(speechDispatcher);
+ spd_close(speechDispatcher);
+ }
backends->removeAll(this);
}
diff --git a/src/plugins/tts/tts.pro b/src/plugins/tts/tts.pro
index 0d56920..8fc9a63 100644
--- a/src/plugins/tts/tts.pro
+++ b/src/plugins/tts/tts.pro
@@ -13,6 +13,7 @@ windows:!winrt:!mingw: SUBDIRS += sapi
winrt: SUBDIRS += winrt
osx: SUBDIRS += osx
+uikit: SUBDIRS += ios
android: SUBDIRS += android
diff --git a/src/tts/qtexttospeech.cpp b/src/tts/qtexttospeech.cpp
index d7346ff..f419fdd 100644
--- a/src/tts/qtexttospeech.cpp
+++ b/src/tts/qtexttospeech.cpp
@@ -167,7 +167,7 @@ void QTextToSpeechPrivate::loadPluginMetadata(QHash<QString, QJsonObject> &list)
It is possible to specify the language with \l setLocale().
To select between the available voices use \l setVoice().
The languages and voices depend on the available synthesizers on each platform.
- On Linux by default speech-dispatcher is used.
+ On Linux, \c speech-dispatcher is used by default.
*/
/*!
@@ -175,7 +175,7 @@ void QTextToSpeechPrivate::loadPluginMetadata(QHash<QString, QJsonObject> &list)
\value Ready The synthesizer is ready to start a new text. This is
also the state after a text was finished.
\value Speaking The current text is being spoken.
- \value Paused The sythetization was paused and can be resumed with \l resume().
+ \value Paused The synthesis was paused and can be resumed with \l resume().
\value BackendError The backend was unable to synthesize the current string.
*/
@@ -193,7 +193,7 @@ void QTextToSpeechPrivate::loadPluginMetadata(QHash<QString, QJsonObject> &list)
The default engine may be platform-specific.
- If loading the plug-in fails, QTextToSpeech::state() will return
+ If the plugin fails to load, QTextToSpeech::state() returns
QTextToSpeech::BackendError.
\sa availableEngines()
@@ -214,7 +214,7 @@ QTextToSpeech::QTextToSpeech(QObject *parent)
If \a engine is empty, the default engine plug-in is used. The default
engine may be platform-specific.
- If loading the plug-in fails, QTextToSpeech::state() will return QTextToSpeech::BackendError.
+ If the plugin fails to load, QTextToSpeech::state() returns QTextToSpeech::BackendError.
\sa availableEngines()
*/
@@ -245,10 +245,10 @@ QTextToSpeech::State QTextToSpeech::state() const
/*!
Start synthesizing the \a text.
- This function will start the asynchronous speaking of the text.
+ This function will start the asynchronous reading of the text.
The current state is available using the \l state property. Once the
- synthetization is done, a \l stateChanged() signal with the \l Ready state
- will be emitted.
+ synthesis is done, a \l stateChanged() signal with the \l Ready state
+ is emitted.
*/
void QTextToSpeech::say(const QString &text)
{
@@ -258,7 +258,7 @@ void QTextToSpeech::say(const QString &text)
}
/*!
- Stop the currently speaking text.
+ Stop the text that is being read.
*/
void QTextToSpeech::stop()
{
@@ -268,13 +268,20 @@ void QTextToSpeech::stop()
}
/*!
- Pause the current speech.
- \note this function depends on the platform and backend and may not work at all,
- take several seconds until it takes effect or may pause instantly.
- Some synthesizers will look for a break that they can later resume from, such as
- a sentence end.
- \note Due to Android platform limitations, pause() stops the current utterance,
- while resume() starts the previously queued utterance from the beginning.
+ Pauses the current speech.
+
+ Note:
+ \list
+ \li This function depends on the platform and the backend. It may not
+ work at all, it may take several seconds before it takes effect,
+ or it may pause instantly.
+ Some synthesizers will look for a break that they can later resume
+ from, such as a sentence end.
+ \li Due to Android platform limitations, pause() stops what is presently
+ being said, while resume() starts the previously queued sentence from
+ the beginning.
+ \endlist
+
\sa resume()
*/
void QTextToSpeech::pause()
@@ -315,8 +322,8 @@ void QTextToSpeech::resume()
/*!
\property QTextToSpeech::pitch
- This property holds the voice pitch in the range -1.0 to 1.0.
- The default of 0.0 is normal speech pitch.
+ This property holds the voice pitch, ranging from -1.0 to 1.0.
+ The default of 0.0 is the normal speech pitch.
*/
void QTextToSpeech::setPitch(double pitch)
@@ -336,7 +343,7 @@ double QTextToSpeech::pitch() const
/*!
\property QTextToSpeech::rate
- This property holds the current voice rate in the range -1.0 to 1.0.
+ This property holds the current voice rate, ranging from -1.0 to 1.0.
The default value of 0.0 is normal speech flow.
*/
void QTextToSpeech::setRate(double rate)
@@ -356,7 +363,7 @@ double QTextToSpeech::rate() const
/*!
\property QTextToSpeech::volume
- This property holds the current volume in the range 0.0 to 1.0.
+ This property holds the current volume, ranging from 0.0 to 1.0.
The default value is the platform's default volume.
*/
void QTextToSpeech::setVolume(double volume)
@@ -402,8 +409,9 @@ QLocale QTextToSpeech::locale() const
}
/*!
- Gets a vector of locales that are currently supported. Note on some platforms
- these can change when the backend changes synthesizers for example.
+ Gets a vector of locales that are currently supported.
+ \note On some platforms these can change, for example,
+ when the backend changes synthesizers.
*/
QVector<QLocale> QTextToSpeech::availableLocales() const
{
@@ -416,9 +424,8 @@ QVector<QLocale> QTextToSpeech::availableLocales() const
/*!
Sets the \a voice to use.
- \note On some platforms setting the voice changes other voice attributes
- such as locale, pitch, etc. in which case signals are emitted for these
- changes.
+ \note On some platforms, setting the voice changes other voice attributes
+ such as locale, pitch, and so on. These changes trigger the emission of signals.
*/
void QTextToSpeech::setVoice(const QVoice &voice)
{
diff --git a/src/tts/qvoice.cpp b/src/tts/qvoice.cpp
index 8a578fd..4f9563c 100644
--- a/src/tts/qvoice.cpp
+++ b/src/tts/qvoice.cpp
@@ -42,6 +42,13 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QVoice
+ \brief The QVoice class allows to set and retrieve values of a particular voice
+ \inmodule QtSpeech
+*/
+
+
QVoice::QVoice()
{
d = new QVoicePrivate();
@@ -84,16 +91,25 @@ bool QVoice::operator!=(const QVoice &other)
return !operator==(other);
}
+/*!
+ Assign a \a name to a voice
+*/
void QVoice::setName(const QString &name)
{
d->name = name;
}
+/*!
+ Assign a \a gender to a voice
+*/
void QVoice::setGender(Gender gender)
{
d->gender = gender;
}
+/*!
+ Set the \a age property
+*/
void QVoice::setAge(Age age)
{
d->age = age;
@@ -104,16 +120,25 @@ void QVoice::setData(const QVariant &data)
d->data = data;
}
+/*!
+ Returns the \a name to a voice
+*/
QString QVoice::name() const
{
return d->name;
}
+/*!
+ Returns the age of a voice
+*/
QVoice::Age QVoice::age() const
{
return d->age;
}
+/*!
+ Returns the gender of a voice
+*/
QVoice::Gender QVoice::gender() const
{
return d->gender;
@@ -124,6 +149,9 @@ QVariant QVoice::data() const
return d->data;
}
+/*!̈́
+ Returns the gender name of a voice
+*/
QString QVoice::genderName(QVoice::Gender gender)
{
QString retval;
@@ -142,6 +170,9 @@ QString QVoice::genderName(QVoice::Gender gender)
return retval;
}
+/*!
+ Returns the age class of a voice
+*/
QString QVoice::ageName(QVoice::Age age)
{
QString retval;