From fd6648b0b77dc628e89655f5dc271dbc42ca829c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 2 Feb 2018 15:12:57 +0100 Subject: Bump version Change-Id: Icd683cab1f4d58eb244d614239644d835c16c972 --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 85c58cc..ef9f985 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ load(qt_build_config) CONFIG += qt_example_installs CONFIG += warning_clean -MODULE_VERSION = 5.9.4 +MODULE_VERSION = 5.9.5 -- cgit v1.2.3 From c7b57997dcc96c2820714b2ef6e3bcfe93193614 Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Sat, 27 Jan 2018 15:14:04 +0100 Subject: Add Android support for supported locales and voices This patch adds support for availableLocales() and availableVoices() to the Android QtSpeech module. [ChangeLog][Android] Added support for availableLocales, availableVoices and setting voices on Android. Task-number: QTBUG-65930 Change-Id: I7457cecb69a07f1e2926c861658a0894cc154a85 Reviewed-by: Frederik Gladhorn --- .../qt5/android/speech/QtTextToSpeech.java | 55 ++++++++++++++++++++++ .../tts/android/src/qtexttospeech_android.cpp | 49 +++++++++++++++++-- .../tts/android/src/qtexttospeech_android.h | 1 + 3 files changed, 101 insertions(+), 4 deletions(-) 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 getAvailableVoices() + { + if (mInitialized && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { + //Log.d("QtTextToSpeech", "Voices: " + mTts.getVoices()); + return new ArrayList(mTts.getVoices()); + } + return new ArrayList(); + } + + public List getAvailableLocales() + { + if (mInitialized && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { + //Log.d("QtTextToSpeech", "Locales: " + mTts.getAvailableLanguages()); + return new ArrayList(mTts.getAvailableLanguages()); + } + return new ArrayList(); + } + + 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 QTextToSpeechEngineAndroid::availableLocales() const { - return QVector(); + auto locales = m_speech.callObjectMethod("getAvailableLocales", "()Ljava/util/List;"); + int count = locales.callMethod("size"); + QVector 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("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("toString").toString(); + return QLocale(localeName); + } return QLocale(); } +QVoice QTextToSpeechEngineAndroid::javaVoiceObjectToQVoice(QJNIObjectPrivate &obj) const +{ + auto voiceName = obj.callObjectMethod("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 QTextToSpeechEngineAndroid::availableVoices() const { - return QVector(); + auto voices = m_speech.callObjectMethod("getAvailableVoices", "()Ljava/util/List;"); + int count = voices.callMethod("size"); + QVector 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("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; -- cgit v1.2.3 From b36a675e77a92cd408864bfbcfdf755647749927 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Apr 2018 12:36:07 +0200 Subject: qtexttospeech_sapi.h: Add missing override Silence warning by clang-cl. Task-number: QTBUG-63512 Change-Id: Idd6d9dabad2ac450b358274cb531c4e98377f699 Reviewed-by: Jeremy Whiting Reviewed-by: Maurice Kalinowski --- src/plugins/tts/sapi/qtexttospeech_sapi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); -- cgit v1.2.3 From da77ce9802200cc6dd47268172f60a60bd1310d1 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 25 Apr 2018 11:20:35 +0200 Subject: Remove legal section about Flite Flite is not part of Qt source code, nor part of the Qt binaries, so documenting the Flite license inside the Qt documentation is misleading. We do optionally link against it, but we do so with heaps of other libraries ... Task-number: QTBUG-66542 Change-Id: I2e84faa11de03e15b01d1cbfdbc32d4acc4dc8f2 Reviewed-by: Lars Knoll --- src/plugins/tts/flite/flite_legal.qdoc | 253 --------------------------------- 1 file changed, 253 deletions(-) delete mode 100644 src/plugins/tts/flite/flite_legal.qdoc 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 -*/ -- cgit v1.2.3 From b113bca742e01d3771f4f8ee0c5dc5ea5a97816e Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 25 Apr 2018 12:38:56 +0200 Subject: Doc: Resolve documentation warnings - Add missing enumeration docs to QVoice. - Fix the name of the QTextToSpeechEngine class and fix missing parameter documentation. - Add custom module header and include paths for Clang-QDoc. - Fix minor formatting issues. Task-number: QTBUG-67790 Change-Id: I18e9af9e9f47afe0b76ca973e0b304af5fe599df Reviewed-by: Paul Wicking Reviewed-by: Martin Smith --- src/doc/QtSpeechDoc | 1 + src/doc/qtspeech.qdocconf | 6 +++ src/tts/qtexttospeechengine.cpp | 89 +++++++++++++++++++++-------------------- src/tts/qvoice.cpp | 47 +++++++++++++++++----- 4 files changed, 90 insertions(+), 53 deletions(-) create mode 100644 src/doc/QtSpeechDoc 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 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/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 QTextToSpeechPluginEngine::availableLocales() const +/*! \fn QVector QTextToSpeechEngine::availableLocales() const - Implementation of \l QTextToSpeech::availableLocales() + Implementation of \l QTextToSpeech::availableLocales(). */ -/*! \fn QVector QTextToSpeechPluginEngine::availableVoices() const +/*! \fn QVector 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) { -- cgit v1.2.3 From d0494c3b3842ef77be355e764c1ba17f369d3278 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 14 Mar 2018 11:11:31 +0100 Subject: Fix type for volume in property: double instead of int MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tests works on macOS, Windows and RHEL 7 at the moment, other platforms do not have the backend or do not test. [ChangeLog] Fixed type of volume property, it has to be double, not int, to be the same as in the related functions. Task-number: QTBUG-66209 Change-Id: I547c00a726fb9b5a846fd5759fc8230dee774782 Reviewed-by: Maurice Kalinowski Reviewed-by: Jan Arve Sæther --- src/tts/qtexttospeech.cpp | 4 +++- src/tts/qtexttospeech.h | 5 +++-- tests/auto/texttospeech/BLACKLIST | 6 ++++++ tests/auto/texttospeech/tst_qtexttospeech.cpp | 17 +++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) 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(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/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(&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" -- cgit v1.2.3