diff options
-rw-r--r-- | .qmake.conf | 5 | ||||
-rw-r--r-- | config.tests/flite/flite.cpp | 56 | ||||
-rw-r--r-- | config.tests/flite/flite.pri | 5 | ||||
-rw-r--r-- | config.tests/flite/flite.pro | 1 | ||||
-rw-r--r-- | config.tests/flite_alsa/flite_alsa.pro | 2 | ||||
-rw-r--r-- | config.tests/speechd/speechd.cpp | 45 | ||||
-rw-r--r-- | config.tests/speechd/speechd.pro | 3 | ||||
-rw-r--r-- | config_help.txt | 5 | ||||
-rw-r--r-- | configure.json | 5 | ||||
-rw-r--r-- | examples/speech/hello_speak/mainwindow.cpp | 9 | ||||
-rw-r--r-- | qtspeech.pro | 6 | ||||
-rw-r--r-- | src/plugins/tts/flite/flite.pro | 6 | ||||
-rw-r--r-- | src/plugins/tts/flite/qtexttospeech_flite.cpp | 7 | ||||
-rw-r--r-- | src/plugins/tts/flite/qtexttospeech_flite_processor.cpp | 5 | ||||
-rw-r--r-- | src/plugins/tts/sapi/qtexttospeech_sapi.cpp | 2 | ||||
-rw-r--r-- | src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp | 2 | ||||
-rw-r--r-- | src/plugins/tts/speechdispatcher/speechdispatcher.pro | 7 | ||||
-rw-r--r-- | src/plugins/tts/tts.pro | 6 | ||||
-rw-r--r-- | src/tts/configure.json | 85 | ||||
-rw-r--r-- | tests/auto/texttospeech/texttospeech.pro | 11 | ||||
-rw-r--r-- | tests/auto/texttospeech/tst_qtexttospeech.cpp | 3 |
21 files changed, 125 insertions, 151 deletions
diff --git a/.qmake.conf b/.qmake.conf index 3b808a7..f30686b 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,7 @@ load(qt_build_config) CONFIG += qt_example_installs CONFIG += warning_clean -MODULE_VERSION = 5.13.0 +DEFINES += QT_NO_FOREACH +DEFINES += QT_NO_JAVA_STYLE_ITERATORS + +MODULE_VERSION = 5.14.0 diff --git a/config.tests/flite/flite.cpp b/config.tests/flite/flite.cpp deleted file mode 100644 index 10b135f..0000000 --- a/config.tests/flite/flite.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** 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 <flite/flite.h> - -static int fliteAudioCb(const cst_wave *w, int start, int size, - int last, cst_audio_streaming_info *asi) -{ - (void)w; - (void)start; - (void)size; - (void)last; - (void)asi; - return CST_AUDIO_STREAM_STOP; -} - -int main() -{ - cst_audio_streaming_info *asi = new_audio_streaming_info(); - asi->asc = fliteAudioCb; // This fails for old Flite - new_audio_streaming_info(); - return 0; -} diff --git a/config.tests/flite/flite.pri b/config.tests/flite/flite.pri deleted file mode 100644 index 9d24740..0000000 --- a/config.tests/flite/flite.pri +++ /dev/null @@ -1,5 +0,0 @@ - -SOURCES = $$PWD/flite.cpp -CONFIG -= qt - -LIBS += -lflite_cmu_us_kal16 -lflite_usenglish -lflite_cmulex -lflite diff --git a/config.tests/flite/flite.pro b/config.tests/flite/flite.pro deleted file mode 100644 index 3f4b1ce..0000000 --- a/config.tests/flite/flite.pro +++ /dev/null @@ -1 +0,0 @@ -include(flite.pri) diff --git a/config.tests/flite_alsa/flite_alsa.pro b/config.tests/flite_alsa/flite_alsa.pro deleted file mode 100644 index be24c6e..0000000 --- a/config.tests/flite_alsa/flite_alsa.pro +++ /dev/null @@ -1,2 +0,0 @@ -LIBS += -lasound -include(../flite/flite.pri) diff --git a/config.tests/speechd/speechd.cpp b/config.tests/speechd/speechd.cpp deleted file mode 100644 index 9910b31..0000000 --- a/config.tests/speechd/speechd.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 <libspeechd.h> - -int main() -{ - SPDConnection *speechDispatcher = spd_open("QtConfigTest", "main", 0, SPD_MODE_THREADED); - if (speechDispatcher) - spd_close(speechDispatcher); - return 0; -} diff --git a/config.tests/speechd/speechd.pro b/config.tests/speechd/speechd.pro deleted file mode 100644 index 48e2ffa..0000000 --- a/config.tests/speechd/speechd.pro +++ /dev/null @@ -1,3 +0,0 @@ -SOURCES = speechd.cpp - -LIBS += -lspeechd diff --git a/config_help.txt b/config_help.txt new file mode 100644 index 0000000..22d4f09 --- /dev/null +++ b/config_help.txt @@ -0,0 +1,5 @@ +TextToSpeech options: + + -flite ............... Enable Flite support [auto] (Unix only) + -flite-alsa .......... Enable Flite with ALSA support [auto] (Unix only) + -speechd ............. Enable speech dispatcher support [auto] (Unix only) diff --git a/configure.json b/configure.json new file mode 100644 index 0000000..010d569 --- /dev/null +++ b/configure.json @@ -0,0 +1,5 @@ +{ + "subconfigs": [ + "src/tts" + ] +} diff --git a/examples/speech/hello_speak/mainwindow.cpp b/examples/speech/hello_speak/mainwindow.cpp index 17619d2..351249e 100644 --- a/examples/speech/hello_speak/mainwindow.cpp +++ b/examples/speech/hello_speak/mainwindow.cpp @@ -62,7 +62,8 @@ MainWindow::MainWindow(QWidget *parent) // Populate engine selection list ui.engine->addItem("Default", QString("default")); - foreach (QString engine, QTextToSpeech::availableEngines()) + const auto engines = QTextToSpeech::availableEngines(); + for (const QString &engine : engines) ui.engine->addItem(engine, engine); ui.engine->setCurrentIndex(0); engineSelected(0); @@ -125,9 +126,9 @@ void MainWindow::engineSelected(int index) disconnect(ui.language, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MainWindow::languageSelected); ui.language->clear(); // Populate the languages combobox before connecting its signal. - QVector<QLocale> locales = m_speech->availableLocales(); + const QVector<QLocale> locales = m_speech->availableLocales(); QLocale current = m_speech->locale(); - foreach (const QLocale &locale, locales) { + for (const QLocale &locale : locales) { QString name(QString("%1 (%2)") .arg(QLocale::languageToString(locale.language())) .arg(QLocale::countryToString(locale.country()))); @@ -171,7 +172,7 @@ void MainWindow::localeChanged(const QLocale &locale) m_voices = m_speech->availableVoices(); QVoice currentVoice = m_speech->voice(); - foreach (const QVoice &voice, m_voices) { + for (const QVoice &voice : qAsConst(m_voices)) { ui.voice->addItem(QString("%1 - %2 - %3").arg(voice.name()) .arg(QVoice::genderName(voice.gender())) .arg(QVoice::ageName(voice.age()))); diff --git a/qtspeech.pro b/qtspeech.pro index 0ae27e2..58c33f2 100644 --- a/qtspeech.pro +++ b/qtspeech.pro @@ -1,7 +1 @@ -load(configure) -qtCompileTest(flite) -qtCompileTest(flite_alsa) -!packagesExist(speech-dispatcher) { - qtCompileTest(speechd) -} load(qt_parts) diff --git a/src/plugins/tts/flite/flite.pro b/src/plugins/tts/flite/flite.pro index 3a5af39..acf60cc 100644 --- a/src/plugins/tts/flite/flite.pro +++ b/src/plugins/tts/flite/flite.pro @@ -1,5 +1,6 @@ TARGET = qttexttospeech_flite QT = core multimedia texttospeech +QT_FOR_CONFIG += texttospeech-private PLUGIN_TYPE = texttospeech PLUGIN_CLASS_NAME = QTextToSpeechEngineFlite @@ -20,6 +21,5 @@ SOURCES += \ OTHER_FILES += \ flite_plugin.json -LIBS += -lflite_cmu_us_kal16 -lflite_usenglish -lflite_cmulex -lflite - -config_flite_alsa: LIBS += -lasound +QMAKE_USE_PRIVATE += flite +qtConfig(flite_alsa): QMAKE_USE_PRIVATE += flite_alsa diff --git a/src/plugins/tts/flite/qtexttospeech_flite.cpp b/src/plugins/tts/flite/qtexttospeech_flite.cpp index 2b32715..fc69397 100644 --- a/src/plugins/tts/flite/qtexttospeech_flite.cpp +++ b/src/plugins/tts/flite/qtexttospeech_flite.cpp @@ -122,7 +122,7 @@ QLocale QTextToSpeechEngineFlite::locale() const bool QTextToSpeechEngineFlite::setLocale(const QLocale &locale) { bool localeFound = false; - foreach (const QLocale &l, m_locales) { + for (const QLocale &l : qAsConst(m_locales)) { if (l.name() == locale.name()) { localeFound = true; break; @@ -154,7 +154,8 @@ QVoice QTextToSpeechEngineFlite::voice() const bool QTextToSpeechEngineFlite::setVoice(const QVoice &voice) { - foreach (const QVoice &availableVoice, availableVoices()) { + const auto voices = availableVoices(); + for (const QVoice &availableVoice : voices) { if (QTextToSpeechEngine::voiceData(availableVoice) == QTextToSpeechEngine::voiceData(voice)) { m_currentVoice = voice; return true; @@ -172,7 +173,7 @@ bool QTextToSpeechEngineFlite::init(QString *errorString) { int i = 0; const QVector<QTextToSpeechProcessor::VoiceInfo> &voices = m_processor->voices(); - foreach (const QTextToSpeechProcessor::VoiceInfo &voiceInfo, voices) { + for (const QTextToSpeechProcessor::VoiceInfo &voiceInfo : voices) { QString name = voiceInfo.name; QLocale locale(voiceInfo.locale); QVoice voice = QTextToSpeechEngine::createVoice(name, voiceInfo.gender, voiceInfo.age, diff --git a/src/plugins/tts/flite/qtexttospeech_flite_processor.cpp b/src/plugins/tts/flite/qtexttospeech_flite_processor.cpp index 5cb051d..198c09b 100644 --- a/src/plugins/tts/flite/qtexttospeech_flite_processor.cpp +++ b/src/plugins/tts/flite/qtexttospeech_flite_processor.cpp @@ -179,7 +179,7 @@ bool QTextToSpeechProcessorFlite::init() m_fliteVoices.append(voice_enus); int totalVoiceCount = 0; - foreach (const FliteVoice &voice, m_fliteVoices) { + for (const FliteVoice &voice : qAsConst(m_fliteVoices)) { QTextToSpeechProcessor::VoiceInfo voiceInfo; voiceInfo.name = voice.name; voiceInfo.locale = voice.locale; @@ -194,9 +194,8 @@ bool QTextToSpeechProcessorFlite::init() void QTextToSpeechProcessorFlite::deinit() { - foreach (const FliteVoice &voice, m_fliteVoices) + for (const FliteVoice &voice : qExchange(m_fliteVoices, {})) voice.unregister_func(voice.vox); - m_fliteVoices.clear(); m_voices.clear(); } diff --git a/src/plugins/tts/sapi/qtexttospeech_sapi.cpp b/src/plugins/tts/sapi/qtexttospeech_sapi.cpp index b97b56f..e371247 100644 --- a/src/plugins/tts/sapi/qtexttospeech_sapi.cpp +++ b/src/plugins/tts/sapi/qtexttospeech_sapi.cpp @@ -386,7 +386,7 @@ QVoice QTextToSpeechEngineSapi::voice() const m_voice->GetVoice(&cpVoiceToken); QString vId = voiceId(cpVoiceToken); cpVoiceToken->Release(); - foreach (const QVoice &voice, m_voices.values()) { + for (const QVoice &voice : m_voices) { if (voiceData(voice).toString() == vId) { return voice; } diff --git a/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp index 5fd3bc2..6eb74b8 100644 --- a/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp +++ b/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp @@ -364,7 +364,7 @@ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const // (history functions are just stubs) void speech_finished_callback(size_t /*msg_id*/, size_t /*client_id*/, SPDNotificationType state) { - Q_FOREACH (QTextToSpeechEngineSpeechd *backend, *backends) + for (QTextToSpeechEngineSpeechd *backend : qAsConst(*backends)) backend->spdStateChanged(state); } diff --git a/src/plugins/tts/speechdispatcher/speechdispatcher.pro b/src/plugins/tts/speechdispatcher/speechdispatcher.pro index a6795e5..d600700 100644 --- a/src/plugins/tts/speechdispatcher/speechdispatcher.pro +++ b/src/plugins/tts/speechdispatcher/speechdispatcher.pro @@ -5,10 +5,7 @@ PLUGIN_CLASS_NAME = QTextToSpeechPluginSpeechd load(qt_plugin) QT = core texttospeech - -CONFIG += link_pkgconfig -packagesExist(speech-dispatcher): PKGCONFIG = speech-dispatcher -config_speechd: LIBS += -lspeechd +QT_FOR_CONFIG += texttospeech-private HEADERS += \ qtexttospeech_speechd.h \ @@ -20,3 +17,5 @@ SOURCES += \ OTHER_FILES += \ speechd_plugin.json + +qtConfig(speechd): QMAKE_USE_PRIVATE += speechd diff --git a/src/plugins/tts/tts.pro b/src/plugins/tts/tts.pro index 7307e40..693bda1 100644 --- a/src/plugins/tts/tts.pro +++ b/src/plugins/tts/tts.pro @@ -1,8 +1,8 @@ TEMPLATE = subdirs +QT_FOR_CONFIG += texttospeech-private unix { - CONFIG += link_pkgconfig - config_speechd | packagesExist(speech-dispatcher) { + qtConfig(speechd) { SUBDIRS += speechdispatcher } } @@ -15,6 +15,6 @@ uikit: SUBDIRS += ios android: SUBDIRS += android -config_flite | config_flite_alsa { +qtConfig(flite) { qtHaveModule(multimedia): SUBDIRS += flite } diff --git a/src/tts/configure.json b/src/tts/configure.json new file mode 100644 index 0000000..2fb68e2 --- /dev/null +++ b/src/tts/configure.json @@ -0,0 +1,85 @@ +{ + "module": "texttospeech", + "depends": [ + "gui" + ], + + "commandline": { + "options": { + "flite": "boolean", + "flite-alsa": { "type": "boolean", "name": "flite_alsa" }, + "speechd": "boolean" + } + }, + + "libraries": { + "flite": { + "label": "Flite", + "test": { + "include": "flite/flite.h", + "tail": [ + "static int fliteAudioCb(const cst_wave *, int, int, int, cst_audio_streaming_info *)", + "{ return CST_AUDIO_STREAM_STOP; }" + ], + "main": [ + "cst_audio_streaming_info *asi = new_audio_streaming_info();", + "asi->asc = fliteAudioCb; // This fails for old Flite", + "new_audio_streaming_info();" + ] + }, + "sources": [ + "-lflite_cmu_us_kal16 -lflite_usenglish -lflite_cmulex -lflite" + ] + }, + "flite_alsa": { + "label": "Flite with ALSA", + "sources": [ + { "type": "pkgConfig", "args": "alsa" }, + "-lasound" + ] + }, + "speechd": { + "label": "Speech Dispatcher", + "test": { + "include": "libspeechd.h", + "main": [ + "spd_close(spd_open(\"QtConfigTest\", \"main\", 0, SPD_MODE_THREADED));" + ] + }, + "sources": [ + { "type": "pkgConfig", "args": "speech-dispatcher" }, + "-lspeechd" + ] + } + }, + + "features": { + "flite": { + "label": "Flite", + "condition": "libs.flite", + "output": [ "privateFeature" ] + }, + "flite_alsa": { + "label": "Flite with ALSA", + "condition": "libs.flite && libs.flite_alsa", + "output": [ "privateFeature" ] + }, + "speechd": { + "label": "Speech Dispatcher", + "autoDetect": "config.unix", + "condition": "libs.speechd", + "output": [ "publicFeature" ] + } + }, + + "summary": [ + { + "section": "Qt TextToSpeech", + "entries": [ + "flite", + "flite_alsa", + "speechd" + ] + } + ] +} diff --git a/tests/auto/texttospeech/texttospeech.pro b/tests/auto/texttospeech/texttospeech.pro index 4ca4419..8d89574 100644 --- a/tests/auto/texttospeech/texttospeech.pro +++ b/tests/auto/texttospeech/texttospeech.pro @@ -1,13 +1,6 @@ CONFIG += testcase TARGET = tst_qtexttospeech -QT = testlib core texttospeech +QT = testlib core texttospeech-private SOURCES += tst_qtexttospeech.cpp -unix { - CONFIG += link_pkgconfig - packagesExist(speech-dispatcher): PKGCONFIG = speech-dispatcher - config_speechd | packagesExist(speech-dispatcher) { - DEFINES += HAVE_SPEECHD - } - config_speechd: LIBS += -lspeechd -} +qtConfig(speechd): QMAKE_USE += speechd diff --git a/tests/auto/texttospeech/tst_qtexttospeech.cpp b/tests/auto/texttospeech/tst_qtexttospeech.cpp index a5a1f0d..9996659 100644 --- a/tests/auto/texttospeech/tst_qtexttospeech.cpp +++ b/tests/auto/texttospeech/tst_qtexttospeech.cpp @@ -38,8 +38,9 @@ #include <QTest> #include <QTextToSpeech> #include <QSignalSpy> +#include <qttexttospeech-config.h> -#if defined(HAVE_SPEECHD) +#if QT_CONFIG(speechd) #include <libspeechd.h> #if LIBSPEECHD_MAJOR_VERSION == 0 && LIBSPEECHD_MINOR_VERSION < 9 #define HAVE_SPEECHD_BEFORE_090 |