summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-05-19 03:01:46 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-05-19 03:01:46 +0200
commite89ef52922ef23b0d1d1880022929d79d8ecc785 (patch)
tree8663729ff0dc1895b33bca91a3788e363af1297b
parent0d02c3e54507f0568c630fc5fb41e9e2e4b34ea6 (diff)
parent1d8cdb9107dcefb97b4ff344ca58cb49bda1484d (diff)
Merge remote-tracking branch 'origin/5.11' into dev
-rw-r--r--src/doc/QtSpeechDoc1
-rw-r--r--src/doc/qtspeech.qdocconf6
-rw-r--r--src/plugins/tts/android/jar/src/org/qtproject/qt5/android/speech/QtTextToSpeech.java55
-rw-r--r--src/plugins/tts/android/src/qtexttospeech_android.cpp49
-rw-r--r--src/plugins/tts/android/src/qtexttospeech_android.h1
-rw-r--r--src/plugins/tts/flite/flite_legal.qdoc253
-rw-r--r--src/plugins/tts/sapi/qtexttospeech_sapi.h2
-rw-r--r--src/tts/qtexttospeech.cpp4
-rw-r--r--src/tts/qtexttospeech.h5
-rw-r--r--src/tts/qtexttospeechengine.cpp89
-rw-r--r--src/tts/qvoice.cpp47
-rw-r--r--tests/auto/texttospeech/BLACKLIST6
-rw-r--r--tests/auto/texttospeech/tst_qtexttospeech.cpp17
13 files changed, 221 insertions, 314 deletions
diff --git a/src/doc/QtSpeechDoc b/src/doc/QtSpeechDoc
new file mode 100644
index 0000000..73ff578
--- /dev/null
+++ b/src/doc/QtSpeechDoc
@@ -0,0 +1 @@
+#include <QtTextToSpeech/QtTextToSpeech>
diff --git a/src/doc/qtspeech.qdocconf b/src/doc/qtspeech.qdocconf
index 8fd2d73..4259272 100644
--- a/src/doc/qtspeech.qdocconf
+++ b/src/doc/qtspeech.qdocconf
@@ -12,6 +12,12 @@ imagedirs += images
exampledirs += \
../../examples/speech
+moduleheader = QtSpeechDoc
+
+includepaths = -I . \
+ -I $QT_INSTALL_HEADERS \
+ -I $QT_INSTALL_HEADERS/QtCore
+
examplesinstallpath = speech
depends += qtcore qtdoc
diff --git a/src/plugins/tts/android/jar/src/org/qtproject/qt5/android/speech/QtTextToSpeech.java b/src/plugins/tts/android/jar/src/org/qtproject/qt5/android/speech/QtTextToSpeech.java
index a6e6091..83332fc 100644
--- a/src/plugins/tts/android/jar/src/org/qtproject/qt5/android/speech/QtTextToSpeech.java
+++ b/src/plugins/tts/android/jar/src/org/qtproject/qt5/android/speech/QtTextToSpeech.java
@@ -50,6 +50,8 @@ import android.util.Log;
import java.lang.Float;
import java.util.HashMap;
import java.util.Locale;
+import java.util.List;
+import java.util.ArrayList;
public class QtTextToSpeech
{
@@ -60,6 +62,7 @@ public class QtTextToSpeech
private TextToSpeech mTts;
private final long mId;
+ private boolean mInitialized = false;
private float mPitch = 1.0f;
private float mRate = 1.0f;
private float mVolume = 1.0f;
@@ -70,8 +73,10 @@ public class QtTextToSpeech
public void onInit(int status) {
Log.w("QtTextToSpeech", "tts initialized");
if (status == TextToSpeech.SUCCESS) {
+ mInitialized = true;
notifyReady(mId);
} else {
+ mInitialized = false;
notifyError(mId);
}
}
@@ -206,4 +211,54 @@ public class QtTextToSpeech
return (result != TextToSpeech.LANG_NOT_SUPPORTED) && (result != TextToSpeech.LANG_MISSING_DATA);
}
+ public List<Object> getAvailableVoices()
+ {
+ if (mInitialized && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ //Log.d("QtTextToSpeech", "Voices: " + mTts.getVoices());
+ return new ArrayList<Object>(mTts.getVoices());
+ }
+ return new ArrayList<Object>();
+ }
+
+ public List<Locale> getAvailableLocales()
+ {
+ if (mInitialized && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ //Log.d("QtTextToSpeech", "Locales: " + mTts.getAvailableLanguages());
+ return new ArrayList<Locale>(mTts.getAvailableLanguages());
+ }
+ return new ArrayList<Locale>();
+ }
+
+ public Locale getLocale()
+ {
+ //Log.d("QtTextToSpeech", "getLocale: " + mLocale);
+ return mTts.getLanguage();
+ }
+
+ public Object getVoice()
+ {
+ if (mInitialized && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ return mTts.getVoice();
+ }
+ return null;
+ }
+
+ public boolean setVoice(String voiceName)
+ {
+ if (!mInitialized)
+ return false;
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ for (android.speech.tts.Voice voice : mTts.getVoices()) {
+ if (voice.getName().equals(voiceName)) {
+ int result = mTts.setVoice(voice);
+ if (result == TextToSpeech.SUCCESS) {
+ //Log.d("QtTextToSpeech", "setVoice: " + voice);
+ return true;
+ }
+ break;
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/src/plugins/tts/android/src/qtexttospeech_android.cpp b/src/plugins/tts/android/src/qtexttospeech_android.cpp
index a3cac58..b4bb006 100644
--- a/src/plugins/tts/android/src/qtexttospeech_android.cpp
+++ b/src/plugins/tts/android/src/qtexttospeech_android.cpp
@@ -250,7 +250,16 @@ bool QTextToSpeechEngineAndroid::setVolume(double volume)
QVector<QLocale> QTextToSpeechEngineAndroid::availableLocales() const
{
- return QVector<QLocale>();
+ auto locales = m_speech.callObjectMethod("getAvailableLocales", "()Ljava/util/List;");
+ int count = locales.callMethod<jint>("size");
+ QVector<QLocale> result;
+ result.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ auto locale = locales.callObjectMethod("get", "(I)Ljava/lang/Object;", i);
+ auto localeName = locale.callObjectMethod<jstring>("toString").toString();
+ result << QLocale(localeName);
+ }
+ return result;
}
bool QTextToSpeechEngineAndroid::setLocale(const QLocale &locale)
@@ -272,21 +281,53 @@ bool QTextToSpeechEngineAndroid::setLocale(const QLocale &locale)
QLocale QTextToSpeechEngineAndroid::locale() const
{
+ auto locale = m_speech.callObjectMethod("getLocale", "()Ljava/util/Locale;");
+ if (locale.isValid()) {
+ auto localeName = locale.callObjectMethod<jstring>("toString").toString();
+ return QLocale(localeName);
+ }
return QLocale();
}
+QVoice QTextToSpeechEngineAndroid::javaVoiceObjectToQVoice(QJNIObjectPrivate &obj) const
+{
+ auto voiceName = obj.callObjectMethod<jstring>("getName").toString();
+ QVoice::Gender gender;
+ if (voiceName.contains(QStringLiteral("#male"))) {
+ gender = QVoice::Male;
+ } else if (voiceName.contains(QStringLiteral("#female"))) {
+ gender = QVoice::Female;
+ } else {
+ gender = QVoice::Unknown;
+ }
+ return createVoice(voiceName, gender, QVoice::Other, voiceName);
+}
+
QVector<QVoice> QTextToSpeechEngineAndroid::availableVoices() const
{
- return QVector<QVoice>();
+ auto voices = m_speech.callObjectMethod("getAvailableVoices", "()Ljava/util/List;");
+ int count = voices.callMethod<jint>("size");
+ QVector<QVoice> result;
+ result.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ auto voice = voices.callObjectMethod("get", "(I)Ljava/lang/Object;", i);
+ result << javaVoiceObjectToQVoice(voice);
+ }
+ return result;
}
-bool QTextToSpeechEngineAndroid::setVoice(const QVoice & /* voice */)
+bool QTextToSpeechEngineAndroid::setVoice(const QVoice &voice)
{
- return false;
+ return m_speech.callMethod<jboolean>("setVoice", "(Ljava/lang/String;)Z",
+ QJNIObjectPrivate::fromString(voiceData(voice).toString()).object());
}
QVoice QTextToSpeechEngineAndroid::voice() const
{
+ auto voice = m_speech.callObjectMethod("getVoice", "()Ljava/lang/Object;");
+ if (voice.isValid()) {
+ return javaVoiceObjectToQVoice(voice);
+ }
return QVoice();
}
diff --git a/src/plugins/tts/android/src/qtexttospeech_android.h b/src/plugins/tts/android/src/qtexttospeech_android.h
index 60cb32d..94c59f5 100644
--- a/src/plugins/tts/android/src/qtexttospeech_android.h
+++ b/src/plugins/tts/android/src/qtexttospeech_android.h
@@ -81,6 +81,7 @@ public Q_SLOTS:
private:
void setState(QTextToSpeech::State state);
+ QVoice javaVoiceObjectToQVoice(QJNIObjectPrivate &obj) const;
QJNIObjectPrivate m_speech;
QTextToSpeech::State m_state;
diff --git a/src/plugins/tts/flite/flite_legal.qdoc b/src/plugins/tts/flite/flite_legal.qdoc
deleted file mode 100644
index 107d99f..0000000
--- a/src/plugins/tts/flite/flite_legal.qdoc
+++ /dev/null
@@ -1,253 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-/*!
-\page legal-flite.html
-\title Flite Library
-\ingroup licensing
-
-\legalese
-\code
-
-Flite is free software.
-
-We have kept the core code to BSD-like copyright, thus the system is
-free to use in commercial products, with commercial extensions. GPL
-code is only included as part of the build process and does not
-taint any of the run-time code.
-
-As a collection it is distributed under the following license. Note
-a few files in this distribution have a different but equally free
-non-conflicting license, see below.
-
- Language Technologies Institute
- Carnegie Mellon University
- Copyright (c) 1999-2014
- All Rights Reserved.
-
- Permission is hereby granted, free of charge, to use and distribute
- this software and its documentation without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of this work, and to
- permit persons to whom this work is furnished to do so, subject to
- the following conditions:
- 1. The code must retain the above copyright notice, this list of
- conditions and the following disclaimer.
- 2. Any modifications must be clearly marked as such.
- 3. Original authors' names are not deleted.
- 4. The authors' names are not used to endorse or promote products
- derived from this software without specific prior written
- permission.
-
- CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK
- DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
- SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE
- FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
- THIS SOFTWARE.
-
-All files within this distribution have the above license except
-the following
-
-src/cg/cst_mlpg.h
-src/cg/cst_mlpg.c
-src/cg/cst_mlsa.h
-src/cg/cst_mlsa.c
-src/cg/cst_vc.h
-src/cg/cst_vc.c
-*********************************************************************
-* *
-* Nagoya Institute of Technology, Aichi, Japan, *
-* Nara Institute of Science and Technology, Nara, Japan *
-* and *
-* Carnegie Mellon University, Pittsburgh, PA *
-* Copyright (c) 2003-2004 *
-* All Rights Reserved. *
-* *
-* Permission is hereby granted, free of charge, to use and *
-* distribute this software and its documentation without *
-* restriction, including without limitation the rights to use, *
-* copy, modify, merge, publish, distribute, sublicense, and/or *
-* sell copies of this work, and to permit persons to whom this *
-* work is furnished to do so, subject to the following conditions: *
-* *
-* 1. The code must retain the above copyright notice, this list *
-* of conditions and the following disclaimer. *
-* 2. Any modifications must be clearly marked as such. *
-* 3. Original authors' names are not deleted. *
-* *
-* NAGOYA INSTITUTE OF TECHNOLOGY, NARA INSTITUTE OF SCIENCE AND *
-* TECHNOLOGY, CARNEGIE MELLON UNIVERSITY, AND THE CONTRIBUTORS TO *
-* THIS WORK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *
-* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, *
-* IN NO EVENT SHALL NAGOYA INSTITUTE OF TECHNOLOGY, NARA *
-* INSTITUTE OF SCIENCE AND TECHNOLOGY, CARNEGIE MELLON UNIVERSITY, *
-* NOR THE CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR *
-* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM *
-* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *
-* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN *
-* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
-* *
-*********************************************************************
-
-These functions are derived from the versions in festvox/src/vc/ as
-modified by Tomoki Toda which in turn contain code derived from
-NITECH's HTS system. Their copyright has the same freedoms as
-as Flite's but under NAIST, NITECH and/or CMU.
-
-src/audio/au_wince.c
-src/utils/cst_file_stdio.c
-src/utils/cst_mmap_posix.c
-src/utils/cst_mmap_win32.c
-src/utils/cst_mmap_none.c
-src/utils/cst_file_wince.c
-sapi/
- are copyright Cepstral, LLC rather than CMU but fall under the same
- free license as the above, except for the owner. (Note the SAPI stuff
- probably doesn't work any more)
-
-doc/alice
- Is the first two chapters of Alice in Wonderland as distributed by the
- Gutenburg project and is now in the public domain
-
-src/regex/regexp.c
-src/regex/regsub.c
-
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
-
-src/speech/rateconv.c
-
- * Copyright (c) 1992, 1995 by Markus Mummert
- *
- * Redistribution and use of this software, modifcation and inclusion
- * into other forms of software are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of this software must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. If this software is redistributed in a modified condition
- * it must reveal clearly that it has been modified.
-
-lang/usenglish/us_durz_cart.c
-lang/usenglish/us_durz_cart.h
-lang/usenglish/us_int_accent_cart.c
-lang/usenglish/us_int_accent_cart.h
-lang/usenglish/us_int_tone_cart.c
-lang/usenglish/us_int_tone_cart.h
-lang/usenglish/us_phoneset.c
-lang/usenglish/us_f0lr.c
- These are directly (or indirectly) compiled/derived from files that are
- part of the Festival Speech Synthesis System (1.4.1). Hence they have
- a joint copyright CMU/Edinburgh but with the same free license
-
-configure
- # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
- #
- # This configure script is free software; the Free Software Foundation
- # gives unlimited permission to copy, distribute and modify it.
-
-configure.sub
-config.guess
-missing
-install-sh
-mkinstalldirs
- Copyright FSF, and under the GPL, these files are only used for
- convenient configuration and are not part of the generated binary,
- and therefore do not impose any GPL restrctions on the rest of the
- system. But as they are standard methods for configuration they
- are included.
-
-src/speech/g72x.h
-src/speech/g721.c
-src/speech/g72x.c
-src/speech/g723_24.c
-src/speech/g723_40.c
-
- *
- * This source code is a product of Sun Microsystems, Inc. and is provided
- * for unrestricted use. Users may copy or modify this source code without
- * charge.
- *
- * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
- * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun source code is provided with no support and without any obligation on
- * the part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
-
-lang/cmu_grapheme_lex/grapheme_unitran_tables.c
- * Copyright 2008-2012, University of Illinois at Urbana-Champaign *
- * distributed under the Apache License, Version (2.0) *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * Original table developed by Richard Sproat and Kyoung-young Kim *
- * Ported for Festvox by Gopala Anumachipalli gopalakr@cs.cmu.edu Sep 2012 *
- * Then converted to C for CMU Flite (cmuflite.org) *
-
-\endcode
-\endlegalese
-*/
diff --git a/src/plugins/tts/sapi/qtexttospeech_sapi.h b/src/plugins/tts/sapi/qtexttospeech_sapi.h
index ea14389..5e52dad 100644
--- a/src/plugins/tts/sapi/qtexttospeech_sapi.h
+++ b/src/plugins/tts/sapi/qtexttospeech_sapi.h
@@ -76,7 +76,7 @@ public:
bool setVoice(const QVoice &voice) override;
QTextToSpeech::State state() const override;
- HRESULT STDMETHODCALLTYPE NotifyCallback(WPARAM /*wParam*/, LPARAM /*lParam*/);
+ HRESULT STDMETHODCALLTYPE NotifyCallback(WPARAM /*wParam*/, LPARAM /*lParam*/) override;
private:
void init();
diff --git a/src/tts/qtexttospeech.cpp b/src/tts/qtexttospeech.cpp
index eb6b083..18ab56d 100644
--- a/src/tts/qtexttospeech.cpp
+++ b/src/tts/qtexttospeech.cpp
@@ -368,8 +368,10 @@ void QTextToSpeech::setVolume(double volume)
{
Q_D(QTextToSpeech);
volume = qMin(qMax(volume, 0.0), 1.0);
- if (d->m_engine && d->m_engine->setVolume(volume))
+ if (d->m_engine && d->m_engine->setVolume(volume)) {
emit volumeChanged(volume);
+ emit volumeChanged(static_cast<int>(volume));
+ }
}
double QTextToSpeech::volume() const
diff --git a/src/tts/qtexttospeech.h b/src/tts/qtexttospeech.h
index 0f43fa0..57974f3 100644
--- a/src/tts/qtexttospeech.h
+++ b/src/tts/qtexttospeech.h
@@ -56,7 +56,7 @@ class QTEXTTOSPEECH_EXPORT QTextToSpeech : public QObject
Q_OBJECT
Q_ENUMS(QTextToSpeech::State)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
- Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
+ Q_PROPERTY(double volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(double rate READ rate WRITE setRate NOTIFY rateChanged)
Q_PROPERTY(double pitch READ pitch WRITE setPitch NOTIFY pitchChanged)
Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged)
@@ -104,7 +104,8 @@ Q_SIGNALS:
void localeChanged(const QLocale &locale);
void rateChanged(double rate);
void pitchChanged(double pitch);
- void volumeChanged(int volume);
+ void volumeChanged(int volume); // ### Qt 6: remove this bad overload
+ void volumeChanged(double volume);
void voiceChanged(const QVoice &voice);
private:
diff --git a/src/tts/qtexttospeechengine.cpp b/src/tts/qtexttospeechengine.cpp
index 5d87224..a107fc2 100644
--- a/src/tts/qtexttospeechengine.cpp
+++ b/src/tts/qtexttospeechengine.cpp
@@ -42,119 +42,120 @@ QT_BEGIN_NAMESPACE
/*!
- \class QTextToSpeechPluginEngine
+ \class QTextToSpeechEngine
\inmodule QtSpeech
- \brief The QTextToSpeechPluginEngine class is the base for text-to-speech engine integrations.
+ \brief The QTextToSpeechEngine class is the base for text-to-speech engine integrations.
- An engine implementation should derive from QTextToSpeechPluginEngine and implement all
- the pure virtual methods.
+ An engine implementation must derive from QTextToSpeechEngine and implement all
+ its pure virtual methods.
*/
-/*! \fn QVector<QLocale> QTextToSpeechPluginEngine::availableLocales() const
+/*! \fn QVector<QLocale> QTextToSpeechEngine::availableLocales() const
- Implementation of \l QTextToSpeech::availableLocales()
+ Implementation of \l QTextToSpeech::availableLocales().
*/
-/*! \fn QVector<QVoice> QTextToSpeechPluginEngine::availableVoices() const
+/*! \fn QVector<QVoice> QTextToSpeechEngine::availableVoices() const
- Implementation of \l QTextToSpeech::availableVoices()
+ Implementation of \l QTextToSpeech::availableVoices().
*/
-/*! \fn void QTextToSpeechPluginEngine::say(const QString &text)
+/*! \fn void QTextToSpeechEngine::say(const QString &text)
- Implementation of \l QTextToSpeech::say()
+ Implementation of \l {QTextToSpeech::say()}{QTextToSpeech::say}(\a text).
*/
-/*! \fn void QTextToSpeechPluginEngine::stop()
+/*! \fn void QTextToSpeechEngine::stop()
- Implementation of \l QTextToSpeech::stop()
+ Implementation of \l QTextToSpeech::stop().
*/
-/*! \fn void QTextToSpeechPluginEngine::pause()
+/*! \fn void QTextToSpeechEngine::pause()
- Implementation of \l QTextToSpeech::pause()
+ Implementation of \l QTextToSpeech::pause().
*/
-/*! \fn void QTextToSpeechPluginEngine::resume()
+/*! \fn void QTextToSpeechEngine::resume()
- Implementation of \l QTextToSpeech::resume()
+ Implementation of \l QTextToSpeech::resume().
*/
-/*! \fn void QTextToSpeechPluginEngine::rate() const
+/*! \fn void QTextToSpeechEngine::rate() const
- Implementation of \l QTextToSpeech::rate()
+ Implementation of \l QTextToSpeech::rate().
*/
-/*! \fn bool QTextToSpeechPluginEngine::setRate(double rate)
+/*! \fn bool QTextToSpeechEngine::setRate(double rate)
- Implementation of \l QTextToSpeech::setRate().
+ Implementation of \l {QTextToSpeech::setRate()}{QTextToSpeech::setRate}(\a rate).
Return \c true if the operation was successful.
*/
-/*! \fn void QTextToSpeechPluginEngine::pitch() const
+/*! \fn void QTextToSpeechEngine::pitch() const
- Implementation of \l QTextToSpeech::pitch()
+ Implementation of \l QTextToSpeech::pitch().
*/
-/*! \fn bool QTextToSpeechPluginEngine::setPitch(double pitch)
+/*! \fn bool QTextToSpeechEngine::setPitch(double pitch)
- Implementation of \l QTextToSpeech::setPitch()
+ Implementation of \l {QTextToSpeech::setPitch()}{QTextToSpeech::setPitch}(\a pitch).
Return \c true if the operation was successful.
*/
-/*! \fn QLocale QTextToSpeechPluginEngine::locale() const
+/*! \fn QLocale QTextToSpeechEngine::locale() const
- Implementation of \l QTextToSpeech::locale()
+ Implementation of QTextToSpeech::locale().
*/
-/*! \fn bool QTextToSpeechPluginEngine::setLocale(const QLocale &locale)
+/*! \fn bool QTextToSpeechEngine::setLocale(const QLocale &locale)
- Implementation of \l QTextToSpeech::setLocale()
+ Implementation \l {QTextToSpeech::setLocale()}{QTextToSpeech::setLocale}(\a locale).
Return \c true if the operation was successful. In this case, the
- current voice (returned by \l voice()) should also have been updated
- to a valid new value.
+ current voice (as returned by voice()) should also be updated to a
+ new, valid value.
*/
-/*! \fn void QTextToSpeechPluginEngine::volume() const
+/*! \fn double QTextToSpeechEngine::volume() const
- Implementation of \l QTextToSpeech::volume()
+ Implementation of QTextToSpeech::volume().
*/
-/*! \fn bool QTextToSpeechPluginEngine::setVolume(int volume)
+/*! \fn bool QTextToSpeechEngine::setVolume(double volume)
- Implementation of \l QTextToSpeech::setVolume()
+ Implementation of \l {QTextToSpeech::setVolume()}{QTextToSpeech::setVolume}(\a volume).
Return \c true if the operation was successful.
*/
-/*! \fn QVoice QTextToSpeechPluginEngine::voice() const
+/*! \fn QVoice QTextToSpeechEngine::voice() const
- Implementation of \l QTextToSpeech::voice()
+ Implementation of \l QTextToSpeech::voice().
*/
-/*! \fn bool QTextToSpeechPluginEngine::setVoice(const QVoice &voice)
+/*! \fn bool QTextToSpeechEngine::setVoice(const QVoice &voice)
- Implementation of \l QTextToSpeech::setVoice()
+ Implementation of \l {QTextToSpeech::setVoice()}{QTextToSpeech::setVoice}(\a voice).
Return \c true if the operation was successful.
*/
-/*! \fn QTextToSpeech::State QTextToSpeechPluginEngine::state() const
+/*! \fn QTextToSpeech::State QTextToSpeechEngine::state() const
- Implementation of \l QTextToSpeech::state()
+ Implementation of QTextToSpeech::state().
*/
-/*! \fn void QTextToSpeechPluginEngine::stateChanged(QTextToSpeech::State state)
+/*! \fn void QTextToSpeechEngine::stateChanged(QTextToSpeech::State state)
- Emitted when the text-to-speech engine state has changed.
- This signal is connected to signal QTextToSpeech::stateChanged().
+ Emitted when the text-to-speech engine \a state has changed.
+
+ This signal is connected to QTextToSpeech::stateChanged() signal.
*/
/*!
- Constructs the text-to-speech engine base class.
+ Constructs the text-to-speech engine base class with \a parent.
*/
QTextToSpeechEngine::QTextToSpeechEngine(QObject *parent):
QObject(parent)
diff --git a/src/tts/qvoice.cpp b/src/tts/qvoice.cpp
index 030d621..2c19aff 100644
--- a/src/tts/qvoice.cpp
+++ b/src/tts/qvoice.cpp
@@ -44,10 +44,31 @@ QT_BEGIN_NAMESPACE
/*!
\class QVoice
- \brief The QVoice class allows to set and retrieve values of a particular voice
+ \brief The QVoice class allows to set and retrieve values of a particular voice.
\inmodule QtSpeech
*/
+/*!
+ \enum QVoice::Age
+
+ The age of a voice.
+
+ \value Child Voice of a child
+ \value Teenager Voice of a teenager
+ \value Adult Voice of an adult
+ \value Senior Voice of a senior
+ \value Other Voice of unknown age
+*/
+
+/*!
+ \enum QVoice::Gender
+
+ The gender of a voice.
+
+ \value Male Voice of a male
+ \value Female Voice of a female
+ \value Unknown Voice of unknown gender
+*/
QVoice::QVoice()
{
@@ -76,6 +97,10 @@ void QVoice::operator=(const QVoice &other)
d->data = other.d->data;
}
+/*!
+ Compares the \l name, \l gender, and \l age of this voice with \l other.
+ Returns \c true if all of them match.
+*/
bool QVoice::operator==(const QVoice &other)
{
if (d->name != other.d->name ||
@@ -86,13 +111,17 @@ bool QVoice::operator==(const QVoice &other)
return true;
}
+/*!
+ Compares the \l name, \l gender, and \l age of this voice with \l other.
+ Returns \c true if they are not identical.
+*/
bool QVoice::operator!=(const QVoice &other)
{
return !operator==(other);
}
/*!
- Assign a \a name to a voice
+ Assign a \a name to a voice.
*/
void QVoice::setName(const QString &name)
{
@@ -100,7 +129,7 @@ void QVoice::setName(const QString &name)
}
/*!
- Assign a \a gender to a voice
+ Assign a \a gender to a voice.
*/
void QVoice::setGender(Gender gender)
{
@@ -108,7 +137,7 @@ void QVoice::setGender(Gender gender)
}
/*!
- Set the \a age property
+ Set the \a age property.
*/
void QVoice::setAge(Age age)
{
@@ -121,7 +150,7 @@ void QVoice::setData(const QVariant &data)
}
/*!
- Returns the name of a voice
+ Returns the name of a voice.
*/
QString QVoice::name() const
{
@@ -129,7 +158,7 @@ QString QVoice::name() const
}
/*!
- Returns the age of a voice
+ Returns the age of a voice.
*/
QVoice::Age QVoice::age() const
{
@@ -137,7 +166,7 @@ QVoice::Age QVoice::age() const
}
/*!
- Returns the gender of a voice
+ Returns the gender of a voice.
*/
QVoice::Gender QVoice::gender() const
{
@@ -150,7 +179,7 @@ QVariant QVoice::data() const
}
/*!̈́
- Returns the \a gender name of a voice
+ Returns the \a gender name of a voice.
*/
QString QVoice::genderName(QVoice::Gender gender)
{
@@ -171,7 +200,7 @@ QString QVoice::genderName(QVoice::Gender gender)
}
/*!
- Returns the \a age class of a voice
+ Returns a string representing the \a age class of a voice.
*/
QString QVoice::ageName(QVoice::Age age)
{
diff --git a/tests/auto/texttospeech/BLACKLIST b/tests/auto/texttospeech/BLACKLIST
index e5c302e..9515c1b 100644
--- a/tests/auto/texttospeech/BLACKLIST
+++ b/tests/auto/texttospeech/BLACKLIST
@@ -6,3 +6,9 @@
*
[set_voice]
*
+[volume]
+b2qt
+redhatenterpriselinuxworkstation-6.6
+ubuntu-16.04
+opensuse-42.3
+
diff --git a/tests/auto/texttospeech/tst_qtexttospeech.cpp b/tests/auto/texttospeech/tst_qtexttospeech.cpp
index 9e828e0..a5a1f0d 100644
--- a/tests/auto/texttospeech/tst_qtexttospeech.cpp
+++ b/tests/auto/texttospeech/tst_qtexttospeech.cpp
@@ -55,6 +55,7 @@ private slots:
void speech_rate();
void pitch();
void set_voice();
+ void volume();
};
@@ -138,5 +139,21 @@ void tst_QTextToSpeech::set_voice()
QVERIFY(timer.elapsed() > 100);
}
+void tst_QTextToSpeech::volume()
+{
+ QTextToSpeech tts;
+ double volumeSignalEmitted = -99.0;
+ connect(&tts, static_cast<void (QTextToSpeech::*)(double)>(&QTextToSpeech::volumeChanged),
+ [&volumeSignalEmitted](double volume){ volumeSignalEmitted = volume; } );
+ tts.setVolume(0.7);
+ QTRY_VERIFY(volumeSignalEmitted > 0.6);
+
+#ifndef HAVE_SPEECHD_BEFORE_090 // older speechd doesn't signal any volume changes
+ // engines use different systems (integers etc), even fuzzy compare is off
+ QVERIFY2(tts.volume() > 0.65, QByteArray::number(tts.volume()));
+ QVERIFY2(tts.volume() < 0.75, QByteArray::number(tts.volume()));
+#endif
+}
+
QTEST_MAIN(tst_QTextToSpeech)
#include "tst_qtexttospeech.moc"