From fc4c0583ea6ae5c2854a7c33091d1e594b1741a7 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 21 Mar 2022 17:11:23 +0100 Subject: Build system porting and cleanup - remove .pro and .prev_CMakeLists.txt files - remove comments generated by pro2cmake - depend on Qt Multimedia only in the Flite plugin - move the qtexttospeechprocessor code into the Flite plugin, it's not used anywhere else - rename anything using osx to macOS - rename plugin classes and types to end with Plugin to silence configure warnings, e.g. QTextToSpeechPluginIos -> QTextToSpeechIosPlugin - bump dependencies to current upstream dev Change-Id: I18c45443bcad5376c2fee01954d62ab997d271f9 Reviewed-by: Jarkko Koivikko Reviewed-by: Qt CI Bot --- CMakeLists.txt | 2 +- dependencies.yaml | 6 +- qtspeech.pro | 1 - src/CMakeLists.txt | 2 - src/plugins/plugins.pro | 2 - src/plugins/tts/.prev_CMakeLists.txt | 23 -- src/plugins/tts/CMakeLists.txt | 4 +- src/plugins/tts/android/CMakeLists.txt | 2 - src/plugins/tts/android/android.pro | 2 - src/plugins/tts/android/jar/CMakeLists.txt | 3 - src/plugins/tts/android/jar/jar.pro | 18 -- src/plugins/tts/android/src/CMakeLists.txt | 9 - src/plugins/tts/android/src/src.pro | 17 -- src/plugins/tts/common/common.pri | 3 - src/plugins/tts/common/qtexttospeechprocessor.cpp | 310 --------------------- src/plugins/tts/common/qtexttospeechprocessor_p.h | 132 --------- src/plugins/tts/flite/CMakeLists.txt | 19 +- src/plugins/tts/flite/flite.pro | 25 -- .../tts/flite/qtexttospeech_flite_plugin.cpp | 4 +- src/plugins/tts/flite/qtexttospeech_flite_plugin.h | 4 +- src/plugins/tts/flite/qtexttospeechprocessor.cpp | 310 +++++++++++++++++++++ src/plugins/tts/flite/qtexttospeechprocessor_p.h | 132 +++++++++ src/plugins/tts/ios/CMakeLists.txt | 11 +- src/plugins/tts/ios/ios.pro | 23 -- src/plugins/tts/ios/qtexttospeech_ios_plugin.cpp | 2 +- src/plugins/tts/ios/qtexttospeech_ios_plugin.h | 2 +- src/plugins/tts/macos/CMakeLists.txt | 12 + src/plugins/tts/macos/macos_plugin.json | 6 + src/plugins/tts/macos/qtexttospeech_macos.h | 99 +++++++ src/plugins/tts/macos/qtexttospeech_macos.mm | 277 ++++++++++++++++++ .../tts/macos/qtexttospeech_macos_plugin.cpp | 44 +++ src/plugins/tts/macos/qtexttospeech_macos_plugin.h | 63 +++++ src/plugins/tts/osx/CMakeLists.txt | 21 -- src/plugins/tts/osx/osx.pro | 22 -- src/plugins/tts/osx/osx_plugin.json | 6 - src/plugins/tts/osx/qtexttospeech_osx.h | 99 ------- src/plugins/tts/osx/qtexttospeech_osx.mm | 277 ------------------ src/plugins/tts/osx/qtexttospeech_osx_plugin.cpp | 44 --- src/plugins/tts/osx/qtexttospeech_osx_plugin.h | 63 ----- src/plugins/tts/sapi/.prev_CMakeLists.txt | 37 --- src/plugins/tts/sapi/CMakeLists.txt | 23 +- src/plugins/tts/sapi/qtexttospeech_sapi_plugin.cpp | 4 +- src/plugins/tts/sapi/qtexttospeech_sapi_plugin.h | 4 +- src/plugins/tts/sapi/sapi.pro | 28 -- src/plugins/tts/speechdispatcher/CMakeLists.txt | 17 +- .../qtexttospeech_speechd_plugin.cpp | 4 +- .../qtexttospeech_speechd_plugin.h | 4 +- .../tts/speechdispatcher/speechdispatcher.pro | 21 -- src/plugins/tts/tts.pro | 20 -- src/plugins/tts/winrt/CMakeLists.txt | 2 +- .../tts/winrt/qtexttospeech_winrt_plugin.cpp | 4 +- src/plugins/tts/winrt/qtexttospeech_winrt_plugin.h | 4 +- src/plugins/tts/winrt/winrt.pro | 18 -- src/src.pro | 5 - src/tts/CMakeLists.txt | 9 - src/tts/tts.pro | 27 -- sync.profile | 13 - tests/.prev_CMakeLists.txt | 7 - tests/CMakeLists.txt | 2 - tests/auto/.prev_CMakeLists.txt | 4 - tests/auto/CMakeLists.txt | 3 - tests/auto/auto.pro | 5 - tests/auto/cmake/CMakeLists.txt | 11 - tests/auto/cmake/cmake.pro | 4 - tests/auto/texttospeech/.prev_CMakeLists.txt | 20 -- tests/auto/texttospeech/CMakeLists.txt | 11 +- tests/auto/texttospeech/texttospeech.pro | 6 - tests/auto/texttospeech/tst_qtexttospeech.cpp | 2 +- tests/tests.pro | 3 - 69 files changed, 979 insertions(+), 1444 deletions(-) delete mode 100644 qtspeech.pro delete mode 100644 src/plugins/plugins.pro delete mode 100644 src/plugins/tts/.prev_CMakeLists.txt delete mode 100644 src/plugins/tts/android/android.pro delete mode 100644 src/plugins/tts/android/jar/jar.pro delete mode 100644 src/plugins/tts/android/src/src.pro delete mode 100644 src/plugins/tts/common/common.pri delete mode 100644 src/plugins/tts/common/qtexttospeechprocessor.cpp delete mode 100644 src/plugins/tts/common/qtexttospeechprocessor_p.h delete mode 100644 src/plugins/tts/flite/flite.pro create mode 100644 src/plugins/tts/flite/qtexttospeechprocessor.cpp create mode 100644 src/plugins/tts/flite/qtexttospeechprocessor_p.h delete mode 100644 src/plugins/tts/ios/ios.pro create mode 100644 src/plugins/tts/macos/CMakeLists.txt create mode 100644 src/plugins/tts/macos/macos_plugin.json create mode 100644 src/plugins/tts/macos/qtexttospeech_macos.h create mode 100644 src/plugins/tts/macos/qtexttospeech_macos.mm create mode 100644 src/plugins/tts/macos/qtexttospeech_macos_plugin.cpp create mode 100644 src/plugins/tts/macos/qtexttospeech_macos_plugin.h delete mode 100644 src/plugins/tts/osx/CMakeLists.txt delete mode 100644 src/plugins/tts/osx/osx.pro delete mode 100644 src/plugins/tts/osx/osx_plugin.json delete mode 100644 src/plugins/tts/osx/qtexttospeech_osx.h delete mode 100644 src/plugins/tts/osx/qtexttospeech_osx.mm delete mode 100644 src/plugins/tts/osx/qtexttospeech_osx_plugin.cpp delete mode 100644 src/plugins/tts/osx/qtexttospeech_osx_plugin.h delete mode 100644 src/plugins/tts/sapi/.prev_CMakeLists.txt delete mode 100644 src/plugins/tts/sapi/sapi.pro delete mode 100644 src/plugins/tts/speechdispatcher/speechdispatcher.pro delete mode 100644 src/plugins/tts/tts.pro delete mode 100644 src/plugins/tts/winrt/winrt.pro delete mode 100644 src/src.pro delete mode 100644 src/tts/tts.pro delete mode 100644 tests/.prev_CMakeLists.txt delete mode 100644 tests/auto/.prev_CMakeLists.txt delete mode 100644 tests/auto/auto.pro delete mode 100644 tests/auto/cmake/CMakeLists.txt delete mode 100644 tests/auto/cmake/cmake.pro delete mode 100644 tests/auto/texttospeech/.prev_CMakeLists.txt delete mode 100644 tests/auto/texttospeech/texttospeech.pro delete mode 100644 tests/tests.pro diff --git a/CMakeLists.txt b/CMakeLists.txt index 88c2b48..abd22fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,6 @@ project(QtSpeech ) find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) -find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS Gui Multimedia Test) +find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS Gui Test) qt_build_repo() diff --git a/dependencies.yaml b/dependencies.yaml index fa1cf90..93e2762 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -1,10 +1,10 @@ dependencies: ../qtbase: - ref: de6ced66920600e659dbaa2509526a3bcb0b3360 + ref: f46db29d8c5185e952f4665d6d141586373d3a0f required: true ../qtdeclarative: - ref: bc6c16c346aa94f6c4eb9548d256b5c81cdc2a0e + ref: 445962d9701e206e358d0596b4f05cce81617b7b required: false ../qtmultimedia: - ref: d86f13725d1050d3ef35c5d67bb1f69d35b27874 + ref: 86d7c582dd0aa60005661ce4891d663a4b57f419 required: false diff --git a/qtspeech.pro b/qtspeech.pro deleted file mode 100644 index 58c33f2..0000000 --- a/qtspeech.pro +++ /dev/null @@ -1 +0,0 @@ -load(qt_parts) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a831a4..2dc298a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from src.pro. - add_subdirectory(tts) add_subdirectory(plugins) add_subdirectory(doc) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro deleted file mode 100644 index ea1896d..0000000 --- a/src/plugins/plugins.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -qtHaveModule(texttospeech): SUBDIRS += tts diff --git a/src/plugins/tts/.prev_CMakeLists.txt b/src/plugins/tts/.prev_CMakeLists.txt deleted file mode 100644 index 86f08c2..0000000 --- a/src/plugins/tts/.prev_CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Generated from tts.pro. - -if(QT_FEATURE_speechd AND UNIX) - add_subdirectory(speechdispatcher) -endif() -if(windows AND NOT WINRT) - add_subdirectory(sapi) -endif() -if(WINRT) - add_subdirectory(winrt) -endif() -if(MACOS) - add_subdirectory(osx) -endif() -if(UIKIT) - add_subdirectory(ios) -endif() -if(ANDROID) - add_subdirectory(android) -endif() -if(QT_FEATURE_flite AND TARGET Qt::Multimedia) - add_subdirectory(flite) -endif() diff --git a/src/plugins/tts/CMakeLists.txt b/src/plugins/tts/CMakeLists.txt index 1945434..867cb45 100644 --- a/src/plugins/tts/CMakeLists.txt +++ b/src/plugins/tts/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from tts.pro. - if(QT_FEATURE_speechd AND UNIX) add_subdirectory(speechdispatcher) endif() @@ -10,7 +8,7 @@ if(WINRT) add_subdirectory(winrt) endif() if(MACOS AND TARGET Qt::Gui) - add_subdirectory(osx) + add_subdirectory(macos) endif() if(UIKIT) add_subdirectory(ios) diff --git a/src/plugins/tts/android/CMakeLists.txt b/src/plugins/tts/android/CMakeLists.txt index 22fe2b6..5724bd0 100644 --- a/src/plugins/tts/android/CMakeLists.txt +++ b/src/plugins/tts/android/CMakeLists.txt @@ -1,4 +1,2 @@ -# Generated from android.pro. - add_subdirectory(jar) add_subdirectory(src) diff --git a/src/plugins/tts/android/android.pro b/src/plugins/tts/android/android.pro deleted file mode 100644 index 0a85400..0000000 --- a/src/plugins/tts/android/android.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = jar src diff --git a/src/plugins/tts/android/jar/CMakeLists.txt b/src/plugins/tts/android/jar/CMakeLists.txt index 89e70e1..8a665a1 100644 --- a/src/plugins/tts/android/jar/CMakeLists.txt +++ b/src/plugins/tts/android/jar/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from jar.pro. - qt_get_android_sdk_jar_for_api("android-21" android_sdk) set(java_sources @@ -16,4 +14,3 @@ install_jar(QtAndroidTextToSpeech DESTINATION jar COMPONENT Devel ) - diff --git a/src/plugins/tts/android/jar/jar.pro b/src/plugins/tts/android/jar/jar.pro deleted file mode 100644 index c480ef1..0000000 --- a/src/plugins/tts/android/jar/jar.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = Qt$${QT_MAJOR_VERSION}AndroidTextToSpeech - -load(qt_build_paths) -CONFIG += java -API_VERSION = android-21 - -DESTDIR = $$MODULE_BASE_OUTDIR/jar - -PATHPREFIX = $$PWD/src/org/qtproject/qt/android/speech - -JAVACLASSPATH += $$PWD/src -JAVASOURCES += $$PATHPREFIX/QtTextToSpeech.java - -# install -target.path = $$[QT_INSTALL_PREFIX]/jar -INSTALLS += target - -OTHER_FILES += $$JAVASOURCES diff --git a/src/plugins/tts/android/src/CMakeLists.txt b/src/plugins/tts/android/src/CMakeLists.txt index f7c6a4f..3945a55 100644 --- a/src/plugins/tts/android/src/CMakeLists.txt +++ b/src/plugins/tts/android/src/CMakeLists.txt @@ -1,9 +1,3 @@ -# Generated from src.pro. - -##################################################################### -## QTextToSpeechEngineAndroid Plugin: -##################################################################### - qt_internal_add_plugin(QTextToSpeechEngineAndroid OUTPUT_NAME qttexttospeech_android PLUGIN_TYPE texttospeech @@ -15,6 +9,3 @@ qt_internal_add_plugin(QTextToSpeechEngineAndroid Qt::CorePrivate Qt::TextToSpeech ) - -#### Keys ignored in scope 1:.:.:src.pro:: -# OTHER_FILES = "android_plugin.json" diff --git a/src/plugins/tts/android/src/src.pro b/src/plugins/tts/android/src/src.pro deleted file mode 100644 index 70f6a40..0000000 --- a/src/plugins/tts/android/src/src.pro +++ /dev/null @@ -1,17 +0,0 @@ -TARGET = qttexttospeech_android -QT = core core-private texttospeech - -PLUGIN_TYPE = texttospeech -PLUGIN_CLASS_NAME = QTextToSpeechEngineAndroid -load(qt_plugin) - -HEADERS += \ - qtexttospeech_android.h \ - qtexttospeech_android_plugin.h - -SOURCES += \ - qtexttospeech_android.cpp \ - qtexttospeech_android_plugin.cpp - -OTHER_FILES += \ - android_plugin.json diff --git a/src/plugins/tts/common/common.pri b/src/plugins/tts/common/common.pri deleted file mode 100644 index 44e506b..0000000 --- a/src/plugins/tts/common/common.pri +++ /dev/null @@ -1,3 +0,0 @@ -HEADERS += $$PWD/qtexttospeechprocessor_p.h -SOURCES += $$PWD/qtexttospeechprocessor.cpp - diff --git a/src/plugins/tts/common/qtexttospeechprocessor.cpp b/src/plugins/tts/common/qtexttospeechprocessor.cpp deleted file mode 100644 index 5ce4756..0000000 --- a/src/plugins/tts/common/qtexttospeechprocessor.cpp +++ /dev/null @@ -1,310 +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 "qtexttospeechprocessor_p.h" - -#include - -QT_BEGIN_NAMESPACE - -QTextToSpeechProcessor::QTextToSpeechProcessor(): - m_stop(true), - m_idle(true), - m_paused(false), - m_rate(0), - m_pitch(0), - m_volume(1.0), - m_audio(nullptr), - m_audioBuffer(nullptr) -{ -} - -QTextToSpeechProcessor::~QTextToSpeechProcessor() -{ -} - -void QTextToSpeechProcessor::say(const QString &text, int voiceId) -{ - if (isInterruptionRequested()) - return; - QMutexLocker lock(&m_lock); - bool wasPaused = m_paused; - m_stop = true; // Cancel any previous utterance - m_idle = false; - m_paused = false; - m_nextText = text; - m_nextVoice = voiceId; - // If the speech was paused, one signal is needed to release the pause - // and another to start processing the new text. - m_speakSem.release(wasPaused ? 2 : 1); -} - -void QTextToSpeechProcessor::stop() -{ - QMutexLocker lock(&m_lock); - m_stop = true; - m_paused = false; - m_nextText.clear(); - m_speakSem.release(); -} - -void QTextToSpeechProcessor::pause() -{ - QMutexLocker lock(&m_lock); - m_paused = true; - m_speakSem.release(); -} - -void QTextToSpeechProcessor::resume() -{ - QMutexLocker lock(&m_lock); - m_paused = false; - m_speakSem.release(); -} - -bool QTextToSpeechProcessor::setRate(double rate) -{ - QMutexLocker lock(&m_lock); - if (rate >= -1.0 && rate <= 1.0) { - if (updateRate(rate)) { - m_rate = rate; - return true; - } - } - return false; -} - -bool QTextToSpeechProcessor::setPitch(double pitch) -{ - QMutexLocker lock(&m_lock); - if (pitch >= -1.0 && pitch <= 1.0) { - if (updatePitch(pitch)) { - m_pitch = pitch; - return true; - } - } - return false; -} - -bool QTextToSpeechProcessor::setVolume(double volume) -{ - QMutexLocker lock(&m_lock); - if (volume >= 0.0 && volume <= 1.0) { - if (updateVolume(volume)) { - m_volume = volume; - return true; - } - } - return false; -} - -bool QTextToSpeechProcessor::isIdle() const -{ - QMutexLocker lock(&m_lock); - return m_idle; -} - -double QTextToSpeechProcessor::rate() const -{ - QMutexLocker lock(&m_lock); - return m_rate; -} - -double QTextToSpeechProcessor::pitch() const -{ - QMutexLocker lock(&m_lock); - return m_pitch; -} - -double QTextToSpeechProcessor::volume() const -{ - QMutexLocker lock(&m_lock); - return m_volume; -} - -void QTextToSpeechProcessor::start(QThread::Priority priority) -{ - QThread::start(priority); -} - -void QTextToSpeechProcessor::exit(int retcode) -{ - QThread::exit(retcode); - QThread::requestInterruption(); - stop(); - if (!QThread::wait(5000)) { - QThread::terminate(); - QThread::wait(); - } -} - -void QTextToSpeechProcessor::run() -{ - int statusCode = 0; - forever { - m_lock.lock(); - if (!m_speakSem.tryAcquire()) { - m_idle = true; - m_lock.unlock(); - emit notSpeaking(statusCode); // Going idle - m_speakSem.acquire(); - m_lock.lock(); - } - if (isInterruptionRequested()) { - if (m_audio) { - delete m_audio; - m_audio = nullptr; - m_audioBuffer = nullptr; - } - m_lock.unlock(); - break; - } - m_stop = false; - if (!m_nextText.isEmpty()) { - QString text = m_nextText; - int voice = m_nextVoice; - m_nextText.clear(); - m_lock.unlock(); - statusCode = processText(text, voice); - } else { - m_lock.unlock(); - } - } -} - -bool QTextToSpeechProcessor::audioStart(int sampleRate, int channelCount, QString *errorString) -{ - QMutexLocker lock(&m_lock); - QAudioFormat format; - format.setSampleRate(sampleRate); - format.setChannelCount(channelCount); - format.setSampleSize(16); - format.setSampleType(QAudioFormat::SignedInt); - format.setCodec("audio/pcm"); - if (errorString) - *errorString = QString(); - if (m_audio) - delete m_audio; - m_audio = new QAudioOutput(format); - m_audioBuffer = m_audio->start(); - updateVolume(m_volume); - if (m_audioBuffer && m_audio->state() == QAudio::IdleState) - return true; - if (errorString) - *errorString = QLatin1String("Failed to start audio output (error ") - + QString::number(m_audio->error()) + QLatin1Char(')'); - delete m_audio; - m_audio = nullptr; - m_audioBuffer = nullptr; - return false; -} - -bool QTextToSpeechProcessor::audioOutput(const char *data, qint64 dataSize, QString *errorString) -{ - bool ret = true; - int bytesWritten = 0; - QString error; - forever { - m_lock.lock(); - if (m_paused) { - m_audio->suspend(); - do { - m_lock.unlock(); - m_speakSem.acquire(); // Wait for any command - m_lock.lock(); - } while (m_paused); - m_audio->resume(); - } - if (m_stop || !m_audioBuffer - || m_audio->state() == QAudio::StoppedState || isInterruptionRequested()) { - if (m_audio->error() != QAudio::NoError) { - error = QLatin1String("Audio error (") - + QString::number(m_audio->error()) + QLatin1Char(')'); - } - m_lock.unlock(); - ret = false; - break; - } - bytesWritten += m_audioBuffer->write(data + bytesWritten, dataSize - bytesWritten); - m_lock.unlock(); - if (bytesWritten >= dataSize) - break; - QThread::msleep(50); - } - if (errorString) - *errorString = error; - return ret; -} - -void QTextToSpeechProcessor::audioStop(bool abort) -{ - QMutexLocker lock(&m_lock); - if (m_audio) { - if (abort) { - m_audio->reset(); // Discard buffered audio - } else { - // TODO: Find a way to reliably check if all the audio has been written out before stopping - m_audioBuffer->write(QByteArray(1024, 0)); - QThread::msleep(200); - m_audio->stop(); - } - delete m_audio; - m_audio = nullptr; - m_audioBuffer = nullptr; - } -} - -bool QTextToSpeechProcessor::updateRate(double rate) -{ - Q_UNUSED(rate); - return true; -} - -bool QTextToSpeechProcessor::updatePitch(double pitch) -{ - Q_UNUSED(pitch); - return true; -} - -bool QTextToSpeechProcessor::updateVolume(double volume) -{ - if (m_audio) - m_audio->setVolume(volume); - return true; -} - - -QT_END_NAMESPACE diff --git a/src/plugins/tts/common/qtexttospeechprocessor_p.h b/src/plugins/tts/common/qtexttospeechprocessor_p.h deleted file mode 100644 index 4f5a74a..0000000 --- a/src/plugins/tts/common/qtexttospeechprocessor_p.h +++ /dev/null @@ -1,132 +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$ -** -****************************************************************************/ - -#ifndef QTEXTTOSPEECHPROCESSOR_P_H -#define QTEXTTOSPEECHPROCESSOR_P_H - -#include "qvoice.h" - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -// A common base class for text-to-speech engine integrations -// that require audio output implementation and thread handling. -// -// QAudioOutput is used for audio, and each call to say() cancels -// any previous processing. The public interface is thread-safe. -class QTextToSpeechProcessor : public QThread { - Q_OBJECT - -public: - struct VoiceInfo - { - int id; - QString name; - QString locale; - QVoice::Gender gender; - QVoice::Age age; - }; - QTextToSpeechProcessor(); - ~QTextToSpeechProcessor() override; - void say(const QString &text, int voiceId); - void stop(); - void pause(); - void resume(); - bool isIdle() const; - bool setRate(double rate); - bool setPitch(double pitch); - bool setVolume(double volume); - double rate() const; - double pitch() const; - double volume() const; - virtual const QList &voices() const = 0; - -protected: - // These are re-implemented QThread methods. - // exit() waits until the processor thread finishes or the wait times out. - void start(QThread::Priority = QThread::InheritPriority); - void exit(int retcode = 0); - - // These methods can be used for audio output. - // audioOutput() blocks until all the audio has been written or processing - // is interrupted. - bool audioStart(int sampleRate, int channelCount, QString *errorString = nullptr); - bool audioOutput(const char* data, qint64 dataSize, QString *errorString = nullptr); - void audioStop(bool abort = false); - - // These methods should be re-implemented if the parameters need - // to be changed while TTS is speaking. By default, updateVolume() just - // changes the QAudioOutput volume. The other methods do nothing by default. - virtual bool updateRate(double rate); - virtual bool updatePitch(double pitch); - virtual bool updateVolume(double volume); - - // This method is called from the internal processor thread, and should block - // until the given text has been processed or processing is interrupted. - virtual int processText(const QString &text, int voiceId) = 0; - -signals: - // This signal is emitted when the processor goes to idle state, i.e. when no - // new text is set to be spoken. The parameter is the latest return value of - // processText(). As the signal is emitted from the internal thread, the recipient - // should call isIdle() to get updated state. - void notSpeaking(int statusCode); - -private: - void run() override; - mutable QMutex m_lock; - volatile bool m_stop; - volatile bool m_idle; - volatile bool m_paused; - double m_rate; - double m_pitch; - double m_volume; - QSemaphore m_speakSem; - QString m_nextText; - int m_nextVoice; - QAudioOutput *m_audio; - QIODevice *m_audioBuffer; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/tts/flite/CMakeLists.txt b/src/plugins/tts/flite/CMakeLists.txt index 6cd0694..de1345b 100644 --- a/src/plugins/tts/flite/CMakeLists.txt +++ b/src/plugins/tts/flite/CMakeLists.txt @@ -1,14 +1,10 @@ -# Generated from flite.pro. +find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Multimedia) -##################################################################### -## QTextToSpeechEngineFlite Plugin: -##################################################################### - -qt_internal_add_plugin(QTextToSpeechEngineFlite +qt_internal_add_plugin(QTextToSpeechFlitePlugin OUTPUT_NAME qttexttospeech_flite PLUGIN_TYPE texttospeech SOURCES - ../common/qtexttospeechprocessor.cpp ../common/qtexttospeechprocessor_p.h + qtexttospeechprocessor.cpp qtexttospeechprocessor_p.h qtexttospeech_flite.cpp qtexttospeech_flite.h qtexttospeech_flite_plugin.cpp qtexttospeech_flite_plugin.h qtexttospeech_flite_processor.cpp qtexttospeech_flite_processor.h @@ -19,14 +15,7 @@ qt_internal_add_plugin(QTextToSpeechEngineFlite Qt::TextToSpeech ) -#### Keys ignored in scope 1:.:.:flite.pro:: -# OTHER_FILES = "flite_plugin.json" -# QT_FOR_CONFIG = "texttospeech-private" - -## Scopes: -##################################################################### - -qt_internal_extend_target(QTextToSpeechEngineFlite CONDITION QT_FEATURE_flite_alsa +qt_internal_extend_target(QTextToSpeechFlitePlugin CONDITION QT_FEATURE_flite_alsa LIBRARIES ALSA::ALSA ) diff --git a/src/plugins/tts/flite/flite.pro b/src/plugins/tts/flite/flite.pro deleted file mode 100644 index acf60cc..0000000 --- a/src/plugins/tts/flite/flite.pro +++ /dev/null @@ -1,25 +0,0 @@ -TARGET = qttexttospeech_flite -QT = core multimedia texttospeech -QT_FOR_CONFIG += texttospeech-private - -PLUGIN_TYPE = texttospeech -PLUGIN_CLASS_NAME = QTextToSpeechEngineFlite -load(qt_plugin) - -include(../common/common.pri) - -HEADERS += \ - qtexttospeech_flite.h \ - qtexttospeech_flite_plugin.h \ - qtexttospeech_flite_processor.h - -SOURCES += \ - qtexttospeech_flite.cpp \ - qtexttospeech_flite_plugin.cpp \ - qtexttospeech_flite_processor.cpp - -OTHER_FILES += \ - flite_plugin.json - -QMAKE_USE_PRIVATE += flite -qtConfig(flite_alsa): QMAKE_USE_PRIVATE += flite_alsa diff --git a/src/plugins/tts/flite/qtexttospeech_flite_plugin.cpp b/src/plugins/tts/flite/qtexttospeech_flite_plugin.cpp index adf3f54..fb7b0a7 100644 --- a/src/plugins/tts/flite/qtexttospeech_flite_plugin.cpp +++ b/src/plugins/tts/flite/qtexttospeech_flite_plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcSpeechTtsFlite, "qt.speech.tts.flite") -QTextToSpeechEngine *QTextToSpeechPluginFlite::createTextToSpeechEngine( +QTextToSpeechEngine *QTextToSpeechFlitePlugin::createTextToSpeechEngine( const QVariantMap ¶meters, QObject *parent, QString *errorString) const { QTextToSpeechEngineFlite *flite = new QTextToSpeechEngineFlite(parameters, parent); diff --git a/src/plugins/tts/flite/qtexttospeech_flite_plugin.h b/src/plugins/tts/flite/qtexttospeech_flite_plugin.h index 6873858..747338a 100644 --- a/src/plugins/tts/flite/qtexttospeech_flite_plugin.h +++ b/src/plugins/tts/flite/qtexttospeech_flite_plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcSpeechTtsFlite) -class QTextToSpeechPluginFlite : public QObject, public QTextToSpeechPlugin +class QTextToSpeechFlitePlugin : public QObject, public QTextToSpeechPlugin { Q_OBJECT Q_INTERFACES(QTextToSpeechPlugin) diff --git a/src/plugins/tts/flite/qtexttospeechprocessor.cpp b/src/plugins/tts/flite/qtexttospeechprocessor.cpp new file mode 100644 index 0000000..5ce4756 --- /dev/null +++ b/src/plugins/tts/flite/qtexttospeechprocessor.cpp @@ -0,0 +1,310 @@ +/**************************************************************************** +** +** 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 "qtexttospeechprocessor_p.h" + +#include + +QT_BEGIN_NAMESPACE + +QTextToSpeechProcessor::QTextToSpeechProcessor(): + m_stop(true), + m_idle(true), + m_paused(false), + m_rate(0), + m_pitch(0), + m_volume(1.0), + m_audio(nullptr), + m_audioBuffer(nullptr) +{ +} + +QTextToSpeechProcessor::~QTextToSpeechProcessor() +{ +} + +void QTextToSpeechProcessor::say(const QString &text, int voiceId) +{ + if (isInterruptionRequested()) + return; + QMutexLocker lock(&m_lock); + bool wasPaused = m_paused; + m_stop = true; // Cancel any previous utterance + m_idle = false; + m_paused = false; + m_nextText = text; + m_nextVoice = voiceId; + // If the speech was paused, one signal is needed to release the pause + // and another to start processing the new text. + m_speakSem.release(wasPaused ? 2 : 1); +} + +void QTextToSpeechProcessor::stop() +{ + QMutexLocker lock(&m_lock); + m_stop = true; + m_paused = false; + m_nextText.clear(); + m_speakSem.release(); +} + +void QTextToSpeechProcessor::pause() +{ + QMutexLocker lock(&m_lock); + m_paused = true; + m_speakSem.release(); +} + +void QTextToSpeechProcessor::resume() +{ + QMutexLocker lock(&m_lock); + m_paused = false; + m_speakSem.release(); +} + +bool QTextToSpeechProcessor::setRate(double rate) +{ + QMutexLocker lock(&m_lock); + if (rate >= -1.0 && rate <= 1.0) { + if (updateRate(rate)) { + m_rate = rate; + return true; + } + } + return false; +} + +bool QTextToSpeechProcessor::setPitch(double pitch) +{ + QMutexLocker lock(&m_lock); + if (pitch >= -1.0 && pitch <= 1.0) { + if (updatePitch(pitch)) { + m_pitch = pitch; + return true; + } + } + return false; +} + +bool QTextToSpeechProcessor::setVolume(double volume) +{ + QMutexLocker lock(&m_lock); + if (volume >= 0.0 && volume <= 1.0) { + if (updateVolume(volume)) { + m_volume = volume; + return true; + } + } + return false; +} + +bool QTextToSpeechProcessor::isIdle() const +{ + QMutexLocker lock(&m_lock); + return m_idle; +} + +double QTextToSpeechProcessor::rate() const +{ + QMutexLocker lock(&m_lock); + return m_rate; +} + +double QTextToSpeechProcessor::pitch() const +{ + QMutexLocker lock(&m_lock); + return m_pitch; +} + +double QTextToSpeechProcessor::volume() const +{ + QMutexLocker lock(&m_lock); + return m_volume; +} + +void QTextToSpeechProcessor::start(QThread::Priority priority) +{ + QThread::start(priority); +} + +void QTextToSpeechProcessor::exit(int retcode) +{ + QThread::exit(retcode); + QThread::requestInterruption(); + stop(); + if (!QThread::wait(5000)) { + QThread::terminate(); + QThread::wait(); + } +} + +void QTextToSpeechProcessor::run() +{ + int statusCode = 0; + forever { + m_lock.lock(); + if (!m_speakSem.tryAcquire()) { + m_idle = true; + m_lock.unlock(); + emit notSpeaking(statusCode); // Going idle + m_speakSem.acquire(); + m_lock.lock(); + } + if (isInterruptionRequested()) { + if (m_audio) { + delete m_audio; + m_audio = nullptr; + m_audioBuffer = nullptr; + } + m_lock.unlock(); + break; + } + m_stop = false; + if (!m_nextText.isEmpty()) { + QString text = m_nextText; + int voice = m_nextVoice; + m_nextText.clear(); + m_lock.unlock(); + statusCode = processText(text, voice); + } else { + m_lock.unlock(); + } + } +} + +bool QTextToSpeechProcessor::audioStart(int sampleRate, int channelCount, QString *errorString) +{ + QMutexLocker lock(&m_lock); + QAudioFormat format; + format.setSampleRate(sampleRate); + format.setChannelCount(channelCount); + format.setSampleSize(16); + format.setSampleType(QAudioFormat::SignedInt); + format.setCodec("audio/pcm"); + if (errorString) + *errorString = QString(); + if (m_audio) + delete m_audio; + m_audio = new QAudioOutput(format); + m_audioBuffer = m_audio->start(); + updateVolume(m_volume); + if (m_audioBuffer && m_audio->state() == QAudio::IdleState) + return true; + if (errorString) + *errorString = QLatin1String("Failed to start audio output (error ") + + QString::number(m_audio->error()) + QLatin1Char(')'); + delete m_audio; + m_audio = nullptr; + m_audioBuffer = nullptr; + return false; +} + +bool QTextToSpeechProcessor::audioOutput(const char *data, qint64 dataSize, QString *errorString) +{ + bool ret = true; + int bytesWritten = 0; + QString error; + forever { + m_lock.lock(); + if (m_paused) { + m_audio->suspend(); + do { + m_lock.unlock(); + m_speakSem.acquire(); // Wait for any command + m_lock.lock(); + } while (m_paused); + m_audio->resume(); + } + if (m_stop || !m_audioBuffer + || m_audio->state() == QAudio::StoppedState || isInterruptionRequested()) { + if (m_audio->error() != QAudio::NoError) { + error = QLatin1String("Audio error (") + + QString::number(m_audio->error()) + QLatin1Char(')'); + } + m_lock.unlock(); + ret = false; + break; + } + bytesWritten += m_audioBuffer->write(data + bytesWritten, dataSize - bytesWritten); + m_lock.unlock(); + if (bytesWritten >= dataSize) + break; + QThread::msleep(50); + } + if (errorString) + *errorString = error; + return ret; +} + +void QTextToSpeechProcessor::audioStop(bool abort) +{ + QMutexLocker lock(&m_lock); + if (m_audio) { + if (abort) { + m_audio->reset(); // Discard buffered audio + } else { + // TODO: Find a way to reliably check if all the audio has been written out before stopping + m_audioBuffer->write(QByteArray(1024, 0)); + QThread::msleep(200); + m_audio->stop(); + } + delete m_audio; + m_audio = nullptr; + m_audioBuffer = nullptr; + } +} + +bool QTextToSpeechProcessor::updateRate(double rate) +{ + Q_UNUSED(rate); + return true; +} + +bool QTextToSpeechProcessor::updatePitch(double pitch) +{ + Q_UNUSED(pitch); + return true; +} + +bool QTextToSpeechProcessor::updateVolume(double volume) +{ + if (m_audio) + m_audio->setVolume(volume); + return true; +} + + +QT_END_NAMESPACE diff --git a/src/plugins/tts/flite/qtexttospeechprocessor_p.h b/src/plugins/tts/flite/qtexttospeechprocessor_p.h new file mode 100644 index 0000000..4f5a74a --- /dev/null +++ b/src/plugins/tts/flite/qtexttospeechprocessor_p.h @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** 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 QTEXTTOSPEECHPROCESSOR_P_H +#define QTEXTTOSPEECHPROCESSOR_P_H + +#include "qvoice.h" + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +// A common base class for text-to-speech engine integrations +// that require audio output implementation and thread handling. +// +// QAudioOutput is used for audio, and each call to say() cancels +// any previous processing. The public interface is thread-safe. +class QTextToSpeechProcessor : public QThread { + Q_OBJECT + +public: + struct VoiceInfo + { + int id; + QString name; + QString locale; + QVoice::Gender gender; + QVoice::Age age; + }; + QTextToSpeechProcessor(); + ~QTextToSpeechProcessor() override; + void say(const QString &text, int voiceId); + void stop(); + void pause(); + void resume(); + bool isIdle() const; + bool setRate(double rate); + bool setPitch(double pitch); + bool setVolume(double volume); + double rate() const; + double pitch() const; + double volume() const; + virtual const QList &voices() const = 0; + +protected: + // These are re-implemented QThread methods. + // exit() waits until the processor thread finishes or the wait times out. + void start(QThread::Priority = QThread::InheritPriority); + void exit(int retcode = 0); + + // These methods can be used for audio output. + // audioOutput() blocks until all the audio has been written or processing + // is interrupted. + bool audioStart(int sampleRate, int channelCount, QString *errorString = nullptr); + bool audioOutput(const char* data, qint64 dataSize, QString *errorString = nullptr); + void audioStop(bool abort = false); + + // These methods should be re-implemented if the parameters need + // to be changed while TTS is speaking. By default, updateVolume() just + // changes the QAudioOutput volume. The other methods do nothing by default. + virtual bool updateRate(double rate); + virtual bool updatePitch(double pitch); + virtual bool updateVolume(double volume); + + // This method is called from the internal processor thread, and should block + // until the given text has been processed or processing is interrupted. + virtual int processText(const QString &text, int voiceId) = 0; + +signals: + // This signal is emitted when the processor goes to idle state, i.e. when no + // new text is set to be spoken. The parameter is the latest return value of + // processText(). As the signal is emitted from the internal thread, the recipient + // should call isIdle() to get updated state. + void notSpeaking(int statusCode); + +private: + void run() override; + mutable QMutex m_lock; + volatile bool m_stop; + volatile bool m_idle; + volatile bool m_paused; + double m_rate; + double m_pitch; + double m_volume; + QSemaphore m_speakSem; + QString m_nextText; + int m_nextVoice; + QAudioOutput *m_audio; + QIODevice *m_audioBuffer; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/tts/ios/CMakeLists.txt b/src/plugins/tts/ios/CMakeLists.txt index 9bf8616..a688b90 100644 --- a/src/plugins/tts/ios/CMakeLists.txt +++ b/src/plugins/tts/ios/CMakeLists.txt @@ -1,10 +1,4 @@ -# Generated from ios.pro. - -##################################################################### -## QTextToSpeechPluginIos Plugin: -##################################################################### - -qt_internal_add_plugin(QTextToSpeechPluginIos +qt_internal_add_plugin(QTextToSpeechIosPlugin OUTPUT_NAME qtexttospeech_speechios PLUGIN_TYPE texttospeech SOURCES @@ -17,6 +11,3 @@ qt_internal_add_plugin(QTextToSpeechPluginIos Qt::Gui Qt::TextToSpeech ) - -#### Keys ignored in scope 1:.:.:ios.pro:: -# OTHER_FILES = "ios_plugin.json" diff --git a/src/plugins/tts/ios/ios.pro b/src/plugins/tts/ios/ios.pro deleted file mode 100644 index 6f04e55..0000000 --- a/src/plugins/tts/ios/ios.pro +++ /dev/null @@ -1,23 +0,0 @@ -TARGET = qtexttospeech_speechios -PLUGIN_TYPE = texttospeech -PLUGIN_CLASS_NAME = QTextToSpeechPluginIos - -load(qt_plugin) - -QT += core texttospeech -LIBS += -framework Foundation -framework AVFoundation - -HEADERS += \ - qtexttospeech_ios_plugin.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/qtexttospeech_ios_plugin.cpp b/src/plugins/tts/ios/qtexttospeech_ios_plugin.cpp index 356bf73..94bb05b 100644 --- a/src/plugins/tts/ios/qtexttospeech_ios_plugin.cpp +++ b/src/plugins/tts/ios/qtexttospeech_ios_plugin.cpp @@ -37,7 +37,7 @@ #include "qtexttospeech_ios_plugin.h" #include "qtexttospeech_ios.h" -QTextToSpeechEngine *QTextToSpeechPluginIos::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const +QTextToSpeechEngine *QTextToSpeechIosPlugin::createTextToSpeechEngine(const QVariantMap ¶meters, 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 index 159dd84..5b54f20 100644 --- a/src/plugins/tts/ios/qtexttospeech_ios_plugin.h +++ b/src/plugins/tts/ios/qtexttospeech_ios_plugin.h @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE -class QTextToSpeechPluginIos : public QObject, public QTextToSpeechPlugin +class QTextToSpeechIosPlugin : public QObject, public QTextToSpeechPlugin { Q_OBJECT Q_INTERFACES(QTextToSpeechPlugin) diff --git a/src/plugins/tts/macos/CMakeLists.txt b/src/plugins/tts/macos/CMakeLists.txt new file mode 100644 index 0000000..af39feb --- /dev/null +++ b/src/plugins/tts/macos/CMakeLists.txt @@ -0,0 +1,12 @@ +qt_internal_add_plugin(QTextToSpeechMacOSPlugin + OUTPUT_NAME qtexttospeech_speech_macos + PLUGIN_TYPE texttospeech + SOURCES + qtexttospeech_macos.h qtexttospeech_macos.mm + qtexttospeech_macos_plugin.cpp qtexttospeech_macos_plugin.h + LIBRARIES + ${FWCocoa} + Qt::Core + Qt::Gui + Qt::TextToSpeech +) diff --git a/src/plugins/tts/macos/macos_plugin.json b/src/plugins/tts/macos/macos_plugin.json new file mode 100644 index 0000000..1884aa7 --- /dev/null +++ b/src/plugins/tts/macos/macos_plugin.json @@ -0,0 +1,6 @@ +{ + "Keys": ["macos"], + "Provider": "macos", + "Version": 100, + "Features": [] +} diff --git a/src/plugins/tts/macos/qtexttospeech_macos.h b/src/plugins/tts/macos/qtexttospeech_macos.h new file mode 100644 index 0000000..28c84ca --- /dev/null +++ b/src/plugins/tts/macos/qtexttospeech_macos.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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_MACOS_H +#define QTEXTTOSPEECHENGINE_MACOS_H + +#include +#include +#include +#include +#include +#include + +Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(StateDelegate)); +Q_FORWARD_DECLARE_OBJC_CLASS(NSSpeechSynthesizer); +Q_FORWARD_DECLARE_OBJC_CLASS(NSString); + +QT_BEGIN_NAMESPACE + +class QTextToSpeechEngineMacOS : public QTextToSpeechEngine +{ + Q_OBJECT + +public: + QTextToSpeechEngineMacOS(const QVariantMap ¶meters, QObject *parent); + ~QTextToSpeechEngineMacOS(); + + // Plug-in API: + QList availableLocales() const override; + QList 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 speechStopped(bool); + +private: + void updateVoices(); + bool isSpeaking() const; + bool isPaused() const; + + QTextToSpeech::State m_state; +// QVoice m_currentVoice; + + QVoice voiceForNSVoice(NSString *voiceString) const; + NSSpeechSynthesizer *speechSynthesizer; + QT_MANGLE_NAMESPACE(StateDelegate) *stateDelegate; + QList m_locales; + QMultiMap m_voices; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/tts/macos/qtexttospeech_macos.mm b/src/plugins/tts/macos/qtexttospeech_macos.mm new file mode 100644 index 0000000..5df84a8 --- /dev/null +++ b/src/plugins/tts/macos/qtexttospeech_macos.mm @@ -0,0 +1,277 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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 +#include "qtexttospeech_macos.h" +#include + +@interface QT_MANGLE_NAMESPACE(StateDelegate) : NSObject +@end + +@implementation QT_MANGLE_NAMESPACE(StateDelegate) +{ + QT_PREPEND_NAMESPACE(QTextToSpeechEngineMacOS) *speechPrivate; +} + +- (instancetype)initWithSpeechPrivate:(QTextToSpeechEngineMacOS *) priv +{ + if ((self = [self init])) { + speechPrivate = priv; + } + return self; +} +- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)success { + Q_UNUSED(sender); + speechPrivate->speechStopped(success); +} +@end + +QT_BEGIN_NAMESPACE + +QTextToSpeechEngineMacOS::QTextToSpeechEngineMacOS(const QVariantMap &/*parameters*/, QObject *parent) + : QTextToSpeechEngine(parent), m_state(QTextToSpeech::Ready) +{ + stateDelegate = [[QT_MANGLE_NAMESPACE(StateDelegate) alloc] initWithSpeechPrivate:this]; + + speechSynthesizer = [[NSSpeechSynthesizer alloc] init]; + [speechSynthesizer setDelegate: stateDelegate]; + updateVoices(); +} + +QTextToSpeechEngineMacOS::~QTextToSpeechEngineMacOS() +{ + [speechSynthesizer setDelegate: nil]; + if ([speechSynthesizer isSpeaking]) + [speechSynthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary]; + [speechSynthesizer release]; + [stateDelegate release]; +} + + +QTextToSpeech::State QTextToSpeechEngineMacOS::state() const +{ + return m_state; +} + +bool QTextToSpeechEngineMacOS::isSpeaking() const +{ + return [speechSynthesizer isSpeaking]; +} + +void QTextToSpeechEngineMacOS::speechStopped(bool success) +{ + Q_UNUSED(success); + if (m_state != QTextToSpeech::Ready) { + m_state = QTextToSpeech::Ready; + emit stateChanged(m_state); + } +} + +void QTextToSpeechEngineMacOS::say(const QString &text) +{ + if (text.isEmpty()) + return; + + if (m_state != QTextToSpeech::Ready) + stop(); + + if([speechSynthesizer isSpeaking]) { + [speechSynthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary]; + } + + NSString *ntext = text.toNSString(); + [speechSynthesizer startSpeakingString:ntext]; + + if (m_state != QTextToSpeech::Speaking) { + m_state = QTextToSpeech::Speaking; + emit stateChanged(m_state); + } +} + +void QTextToSpeechEngineMacOS::stop() +{ + if([speechSynthesizer isSpeaking]) + [speechSynthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary]; +} + +void QTextToSpeechEngineMacOS::pause() +{ + if ([speechSynthesizer isSpeaking]) { + [speechSynthesizer pauseSpeakingAtBoundary: NSSpeechWordBoundary]; + m_state = QTextToSpeech::Paused; + emit stateChanged(m_state); + } +} + +bool QTextToSpeechEngineMacOS::isPaused() const +{ + return m_state == QTextToSpeech::Paused; +} + +void QTextToSpeechEngineMacOS::resume() +{ + m_state = QTextToSpeech::Speaking; + emit stateChanged(m_state); + [speechSynthesizer continueSpeaking]; +} + +double QTextToSpeechEngineMacOS::rate() const +{ + return ([speechSynthesizer rate] - 200) / 200.0; +} + +bool QTextToSpeechEngineMacOS::setPitch(double pitch) +{ + // 30 to 65 + double p = 30.0 + ((pitch + 1.0) / 2.0) * 35.0; + [speechSynthesizer setObject:[NSNumber numberWithFloat:p] forProperty:NSSpeechPitchBaseProperty error:nil]; + return true; +} + +double QTextToSpeechEngineMacOS::pitch() const +{ + double pitch = [[speechSynthesizer objectForProperty:NSSpeechPitchBaseProperty error:nil] floatValue]; + return (pitch - 30.0) / 35.0 * 2.0 - 1.0; +} + +double QTextToSpeechEngineMacOS::volume() const +{ + return [speechSynthesizer volume]; +} + +bool QTextToSpeechEngineMacOS::setRate(double rate) +{ + // NSSpeechSynthesizer supports words per minute, + // human speech is 180 to 220 - use 0 to 400 as range here + [speechSynthesizer setRate: 200 + (rate * 200)]; + return true; +} + +bool QTextToSpeechEngineMacOS::setVolume(double volume) +{ + [speechSynthesizer setVolume: volume]; + return true; +} + +QLocale localeForVoice(NSString *voice) +{ + NSDictionary *attrs = [NSSpeechSynthesizer attributesForVoice:voice]; + return QLocale(QString::fromNSString(attrs[NSVoiceLocaleIdentifier])); +} + +QVoice QTextToSpeechEngineMacOS::voiceForNSVoice(NSString *voiceString) const +{ + NSDictionary *attrs = [NSSpeechSynthesizer attributesForVoice:voiceString]; + QString voiceName = QString::fromNSString(attrs[NSVoiceName]); + + NSString *genderString = attrs[NSVoiceGender]; + QVoice::Gender gender = [genderString isEqualToString:NSVoiceGenderMale] ? QVoice::Male : + [genderString isEqualToString:NSVoiceGenderFemale] ? QVoice::Female : + QVoice::Unknown; + + NSNumber *ageNSNumber = attrs[NSVoiceAge]; + int ageInt = ageNSNumber.intValue; + QVoice::Age age = (ageInt < 13 ? QVoice::Child : + ageInt < 20 ? QVoice::Teenager : + ageInt < 45 ? QVoice::Adult : + ageInt < 90 ? QVoice::Senior : QVoice::Other); + QVariant data = QString::fromNSString(attrs[NSVoiceIdentifier]); + QVoice voice = createVoice(voiceName, gender, age, data); + return voice; +} + +QVector QTextToSpeechEngineMacOS::availableLocales() const +{ + return m_locales; +} + +bool QTextToSpeechEngineMacOS::setLocale(const QLocale &locale) +{ + NSArray *voices = [NSSpeechSynthesizer availableVoices]; + NSString *voice = [NSSpeechSynthesizer defaultVoice]; + // always prefer default + if (locale == localeForVoice(voice)) { + [speechSynthesizer setVoice:voice]; + return true; + } + + for (voice in voices) { + QLocale voiceLocale = localeForVoice(voice); + if (locale == voiceLocale) { + [speechSynthesizer setVoice:voice]; + return true; + } + } + return false; +} + +QLocale QTextToSpeechEngineMacOS::locale() const +{ + NSString *voice = [speechSynthesizer voice]; + return localeForVoice(voice); +} + +void QTextToSpeechEngineMacOS::updateVoices() +{ + NSArray *voices = [NSSpeechSynthesizer availableVoices]; + for (NSString *voice in voices) { + QLocale locale = localeForVoice(voice); + QVoice data = voiceForNSVoice(voice); + if (!m_locales.contains(locale)) + m_locales.append(locale); + m_voices.insert(locale.name(), data); + } +} + +QVector QTextToSpeechEngineMacOS::availableVoices() const +{ + return m_voices.values(locale().name()).toVector(); +} + +bool QTextToSpeechEngineMacOS::setVoice(const QVoice &voice) +{ + NSString *identifier = voiceData(voice).toString().toNSString(); + [speechSynthesizer setVoice:identifier]; + return true; +} + +QVoice QTextToSpeechEngineMacOS::voice() const +{ + NSString *voice = [speechSynthesizer voice]; + return voiceForNSVoice(voice); +} + +QT_END_NAMESPACE diff --git a/src/plugins/tts/macos/qtexttospeech_macos_plugin.cpp b/src/plugins/tts/macos/qtexttospeech_macos_plugin.cpp new file mode 100644 index 0000000..61d4e36 --- /dev/null +++ b/src/plugins/tts/macos/qtexttospeech_macos_plugin.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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_macos_plugin.h" +#include "qtexttospeech_macos.h" + +QTextToSpeechEngine *QTextToSpeechMacOSPlugin::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const +{ + Q_UNUSED(errorString); + return new QTextToSpeechEngineMacOS(parameters, parent); +} diff --git a/src/plugins/tts/macos/qtexttospeech_macos_plugin.h b/src/plugins/tts/macos/qtexttospeech_macos_plugin.h new file mode 100644 index 0000000..e412d6c --- /dev/null +++ b/src/plugins/tts/macos/qtexttospeech_macos_plugin.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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_MACOS_H +#define QTEXTTOSPEECHPLUGIN_MACOS_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QTextToSpeechMacOSPlugin : public QObject, public QTextToSpeechPlugin +{ + Q_OBJECT + Q_INTERFACES(QTextToSpeechPlugin) + Q_PLUGIN_METADATA(IID "org.qt-project.qt.speech.tts.plugin/5.0" + FILE "macos_plugin.json") + +public: + QTextToSpeechEngine *createTextToSpeechEngine( + const QVariantMap ¶meters, + QObject *parent, + QString *errorString) const override; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/tts/osx/CMakeLists.txt b/src/plugins/tts/osx/CMakeLists.txt deleted file mode 100644 index 7adea16..0000000 --- a/src/plugins/tts/osx/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Generated from osx.pro. - -##################################################################### -## QTextToSpeechPluginOsx Plugin: -##################################################################### - -qt_internal_add_plugin(QTextToSpeechPluginOsx - OUTPUT_NAME qtexttospeech_speechosx - PLUGIN_TYPE texttospeech - SOURCES - qtexttospeech_osx.h qtexttospeech_osx.mm - qtexttospeech_osx_plugin.cpp qtexttospeech_osx_plugin.h - LIBRARIES - ${FWCocoa} - Qt::Core - Qt::Gui - Qt::TextToSpeech -) - -#### Keys ignored in scope 1:.:.:osx.pro:: -# OTHER_FILES = "osx_plugin.json" diff --git a/src/plugins/tts/osx/osx.pro b/src/plugins/tts/osx/osx.pro deleted file mode 100644 index dba58f8..0000000 --- a/src/plugins/tts/osx/osx.pro +++ /dev/null @@ -1,22 +0,0 @@ -TARGET = qtexttospeech_speechosx -PLUGIN_TYPE = texttospeech -PLUGIN_CLASS_NAME = QTextToSpeechPluginOsx - -load(qt_plugin) - -QT += core texttospeech - -LIBS += -framework Cocoa - -HEADERS += \ - qtexttospeech_osx_plugin.h \ - qtexttospeech_osx.h \ - -SOURCES += \ - qtexttospeech_osx_plugin.cpp \ - -OBJECTIVE_SOURCES += \ - qtexttospeech_osx.mm \ - -OTHER_FILES += \ - osx_plugin.json diff --git a/src/plugins/tts/osx/osx_plugin.json b/src/plugins/tts/osx/osx_plugin.json deleted file mode 100644 index 5b039f3..0000000 --- a/src/plugins/tts/osx/osx_plugin.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Keys": ["osx"], - "Provider": "osx", - "Version": 100, - "Features": [] -} diff --git a/src/plugins/tts/osx/qtexttospeech_osx.h b/src/plugins/tts/osx/qtexttospeech_osx.h deleted file mode 100644 index 904dee0..0000000 --- a/src/plugins/tts/osx/qtexttospeech_osx.h +++ /dev/null @@ -1,99 +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$ -** -****************************************************************************/ - -#ifndef QTEXTTOSPEECHENGINE_OSX_H -#define QTEXTTOSPEECHENGINE_OSX_H - -#include -#include -#include -#include -#include -#include - -Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(StateDelegate)); -Q_FORWARD_DECLARE_OBJC_CLASS(NSSpeechSynthesizer); -Q_FORWARD_DECLARE_OBJC_CLASS(NSString); - -QT_BEGIN_NAMESPACE - -class QTextToSpeechEngineOsx : public QTextToSpeechEngine -{ - Q_OBJECT - -public: - QTextToSpeechEngineOsx(const QVariantMap ¶meters, QObject *parent); - ~QTextToSpeechEngineOsx(); - - // Plug-in API: - QList availableLocales() const override; - QList 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 speechStopped(bool); - -private: - void updateVoices(); - bool isSpeaking() const; - bool isPaused() const; - - QTextToSpeech::State m_state; -// QVoice m_currentVoice; - - QVoice voiceForNSVoice(NSString *voiceString) const; - NSSpeechSynthesizer *speechSynthesizer; - QT_MANGLE_NAMESPACE(StateDelegate) *stateDelegate; - QList m_locales; - QMultiMap m_voices; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/tts/osx/qtexttospeech_osx.mm b/src/plugins/tts/osx/qtexttospeech_osx.mm deleted file mode 100644 index 32578bd..0000000 --- a/src/plugins/tts/osx/qtexttospeech_osx.mm +++ /dev/null @@ -1,277 +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 -#include "qtexttospeech_osx.h" -#include - -@interface QT_MANGLE_NAMESPACE(StateDelegate) : NSObject -@end - -@implementation QT_MANGLE_NAMESPACE(StateDelegate) -{ - QT_PREPEND_NAMESPACE(QTextToSpeechEngineOsx) *speechPrivate; -} - -- (instancetype)initWithSpeechPrivate:(QTextToSpeechEngineOsx *) priv -{ - if ((self = [self init])) { - speechPrivate = priv; - } - return self; -} -- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)success { - Q_UNUSED(sender); - speechPrivate->speechStopped(success); -} -@end - -QT_BEGIN_NAMESPACE - -QTextToSpeechEngineOsx::QTextToSpeechEngineOsx(const QVariantMap &/*parameters*/, QObject *parent) - : QTextToSpeechEngine(parent), m_state(QTextToSpeech::Ready) -{ - stateDelegate = [[QT_MANGLE_NAMESPACE(StateDelegate) alloc] initWithSpeechPrivate:this]; - - speechSynthesizer = [[NSSpeechSynthesizer alloc] init]; - [speechSynthesizer setDelegate: stateDelegate]; - updateVoices(); -} - -QTextToSpeechEngineOsx::~QTextToSpeechEngineOsx() -{ - [speechSynthesizer setDelegate: nil]; - if ([speechSynthesizer isSpeaking]) - [speechSynthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary]; - [speechSynthesizer release]; - [stateDelegate release]; -} - - -QTextToSpeech::State QTextToSpeechEngineOsx::state() const -{ - return m_state; -} - -bool QTextToSpeechEngineOsx::isSpeaking() const -{ - return [speechSynthesizer isSpeaking]; -} - -void QTextToSpeechEngineOsx::speechStopped(bool success) -{ - Q_UNUSED(success); - if (m_state != QTextToSpeech::Ready) { - m_state = QTextToSpeech::Ready; - emit stateChanged(m_state); - } -} - -void QTextToSpeechEngineOsx::say(const QString &text) -{ - if (text.isEmpty()) - return; - - if (m_state != QTextToSpeech::Ready) - stop(); - - if([speechSynthesizer isSpeaking]) { - [speechSynthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary]; - } - - NSString *ntext = text.toNSString(); - [speechSynthesizer startSpeakingString:ntext]; - - if (m_state != QTextToSpeech::Speaking) { - m_state = QTextToSpeech::Speaking; - emit stateChanged(m_state); - } -} - -void QTextToSpeechEngineOsx::stop() -{ - if([speechSynthesizer isSpeaking]) - [speechSynthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary]; -} - -void QTextToSpeechEngineOsx::pause() -{ - if ([speechSynthesizer isSpeaking]) { - [speechSynthesizer pauseSpeakingAtBoundary: NSSpeechWordBoundary]; - m_state = QTextToSpeech::Paused; - emit stateChanged(m_state); - } -} - -bool QTextToSpeechEngineOsx::isPaused() const -{ - return m_state == QTextToSpeech::Paused; -} - -void QTextToSpeechEngineOsx::resume() -{ - m_state = QTextToSpeech::Speaking; - emit stateChanged(m_state); - [speechSynthesizer continueSpeaking]; -} - -double QTextToSpeechEngineOsx::rate() const -{ - return ([speechSynthesizer rate] - 200) / 200.0; -} - -bool QTextToSpeechEngineOsx::setPitch(double pitch) -{ - // 30 to 65 - double p = 30.0 + ((pitch + 1.0) / 2.0) * 35.0; - [speechSynthesizer setObject:[NSNumber numberWithFloat:p] forProperty:NSSpeechPitchBaseProperty error:nil]; - return true; -} - -double QTextToSpeechEngineOsx::pitch() const -{ - double pitch = [[speechSynthesizer objectForProperty:NSSpeechPitchBaseProperty error:nil] floatValue]; - return (pitch - 30.0) / 35.0 * 2.0 - 1.0; -} - -double QTextToSpeechEngineOsx::volume() const -{ - return [speechSynthesizer volume]; -} - -bool QTextToSpeechEngineOsx::setRate(double rate) -{ - // NSSpeechSynthesizer supports words per minute, - // human speech is 180 to 220 - use 0 to 400 as range here - [speechSynthesizer setRate: 200 + (rate * 200)]; - return true; -} - -bool QTextToSpeechEngineOsx::setVolume(double volume) -{ - [speechSynthesizer setVolume: volume]; - return true; -} - -QLocale localeForVoice(NSString *voice) -{ - NSDictionary *attrs = [NSSpeechSynthesizer attributesForVoice:voice]; - return QLocale(QString::fromNSString(attrs[NSVoiceLocaleIdentifier])); -} - -QVoice QTextToSpeechEngineOsx::voiceForNSVoice(NSString *voiceString) const -{ - NSDictionary *attrs = [NSSpeechSynthesizer attributesForVoice:voiceString]; - QString voiceName = QString::fromNSString(attrs[NSVoiceName]); - - NSString *genderString = attrs[NSVoiceGender]; - QVoice::Gender gender = [genderString isEqualToString:NSVoiceGenderMale] ? QVoice::Male : - [genderString isEqualToString:NSVoiceGenderFemale] ? QVoice::Female : - QVoice::Unknown; - - NSNumber *ageNSNumber = attrs[NSVoiceAge]; - int ageInt = ageNSNumber.intValue; - QVoice::Age age = (ageInt < 13 ? QVoice::Child : - ageInt < 20 ? QVoice::Teenager : - ageInt < 45 ? QVoice::Adult : - ageInt < 90 ? QVoice::Senior : QVoice::Other); - QVariant data = QString::fromNSString(attrs[NSVoiceIdentifier]); - QVoice voice = createVoice(voiceName, gender, age, data); - return voice; -} - -QVector QTextToSpeechEngineOsx::availableLocales() const -{ - return m_locales; -} - -bool QTextToSpeechEngineOsx::setLocale(const QLocale &locale) -{ - NSArray *voices = [NSSpeechSynthesizer availableVoices]; - NSString *voice = [NSSpeechSynthesizer defaultVoice]; - // always prefer default - if (locale == localeForVoice(voice)) { - [speechSynthesizer setVoice:voice]; - return true; - } - - for (voice in voices) { - QLocale voiceLocale = localeForVoice(voice); - if (locale == voiceLocale) { - [speechSynthesizer setVoice:voice]; - return true; - } - } - return false; -} - -QLocale QTextToSpeechEngineOsx::locale() const -{ - NSString *voice = [speechSynthesizer voice]; - return localeForVoice(voice); -} - -void QTextToSpeechEngineOsx::updateVoices() -{ - NSArray *voices = [NSSpeechSynthesizer availableVoices]; - for (NSString *voice in voices) { - QLocale locale = localeForVoice(voice); - QVoice data = voiceForNSVoice(voice); - if (!m_locales.contains(locale)) - m_locales.append(locale); - m_voices.insert(locale.name(), data); - } -} - -QVector QTextToSpeechEngineOsx::availableVoices() const -{ - return m_voices.values(locale().name()).toVector(); -} - -bool QTextToSpeechEngineOsx::setVoice(const QVoice &voice) -{ - NSString *identifier = voiceData(voice).toString().toNSString(); - [speechSynthesizer setVoice:identifier]; - return true; -} - -QVoice QTextToSpeechEngineOsx::voice() const -{ - NSString *voice = [speechSynthesizer voice]; - return voiceForNSVoice(voice); -} - -QT_END_NAMESPACE diff --git a/src/plugins/tts/osx/qtexttospeech_osx_plugin.cpp b/src/plugins/tts/osx/qtexttospeech_osx_plugin.cpp deleted file mode 100644 index 178d181..0000000 --- a/src/plugins/tts/osx/qtexttospeech_osx_plugin.cpp +++ /dev/null @@ -1,44 +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 "qtexttospeech_osx_plugin.h" -#include "qtexttospeech_osx.h" - -QTextToSpeechEngine *QTextToSpeechPluginOsx::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const -{ - Q_UNUSED(errorString); - return new QTextToSpeechEngineOsx(parameters, parent); -} diff --git a/src/plugins/tts/osx/qtexttospeech_osx_plugin.h b/src/plugins/tts/osx/qtexttospeech_osx_plugin.h deleted file mode 100644 index e321f90..0000000 --- a/src/plugins/tts/osx/qtexttospeech_osx_plugin.h +++ /dev/null @@ -1,63 +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$ -** -****************************************************************************/ - -#ifndef QTEXTTOSPEECHPLUGIN_OSX_H -#define QTEXTTOSPEECHPLUGIN_OSX_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QTextToSpeechPluginOsx : public QObject, public QTextToSpeechPlugin -{ - Q_OBJECT - Q_INTERFACES(QTextToSpeechPlugin) - Q_PLUGIN_METADATA(IID "org.qt-project.qt.speech.tts.plugin/5.0" - FILE "osx_plugin.json") - -public: - QTextToSpeechEngine *createTextToSpeechEngine( - const QVariantMap ¶meters, - QObject *parent, - QString *errorString) const override; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/tts/sapi/.prev_CMakeLists.txt b/src/plugins/tts/sapi/.prev_CMakeLists.txt deleted file mode 100644 index 5c9d555..0000000 --- a/src/plugins/tts/sapi/.prev_CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Generated from sapi.pro. - -##################################################################### -## QTextToSpeechPluginSapi Plugin: -##################################################################### - -qt_internal_add_plugin(QTextToSpeechPluginSapi - OUTPUT_NAME qtexttospeech_sapi - TYPE texttospeech - SOURCES - qtexttospeech_sapi.cpp qtexttospeech_sapi.h - qtexttospeech_sapi_plugin.cpp qtexttospeech_sapi_plugin.h - PUBLIC_LIBRARIES - Qt::Core - Qt::Gui - Qt::TextToSpeech - COMPILE_OPTIONS - --Zc:strictStrings -) - -#### Keys ignored in scope 1:.:.:sapi.pro:: -# OTHER_FILES = "sapi_plugin.json" -# QMAKE_CFLAGS = "--Zc:strictStrings" -# QMAKE_CFLAGS_RELEASE = "--Zc:strictStrings" -# QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO = "--Zc:strictStrings" -# QMAKE_CXXFLAGS_RELEASE = "--Zc:strictStrings" -# QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO = "--Zc:strictStrings" - -## Scopes: -##################################################################### - -qt_internal_extend_target(QTextToSpeechPluginSapi CONDITION MINGW - PUBLIC_LIBRARIES - ole32 - sapi - uuid -) diff --git a/src/plugins/tts/sapi/CMakeLists.txt b/src/plugins/tts/sapi/CMakeLists.txt index 43a57d6..8a3fe2c 100644 --- a/src/plugins/tts/sapi/CMakeLists.txt +++ b/src/plugins/tts/sapi/CMakeLists.txt @@ -1,10 +1,4 @@ -# Generated from sapi.pro. - -##################################################################### -## QTextToSpeechPluginSapi Plugin: -##################################################################### - -qt_internal_add_plugin(QTextToSpeechPluginSapi +qt_internal_add_plugin(QTextToSpeechSapiPlugin OUTPUT_NAME qtexttospeech_sapi PLUGIN_TYPE texttospeech SOURCES @@ -16,23 +10,12 @@ qt_internal_add_plugin(QTextToSpeechPluginSapi Qt::TextToSpeech ) -#### Keys ignored in scope 1:.:.:sapi.pro:: -# OTHER_FILES = "sapi_plugin.json" -# QMAKE_CFLAGS = "--Zc:strictStrings" -# QMAKE_CFLAGS_RELEASE = "--Zc:strictStrings" -# QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO = "--Zc:strictStrings" -# QMAKE_CXXFLAGS_RELEASE = "--Zc:strictStrings" -# QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO = "--Zc:strictStrings" - -## Scopes: -##################################################################### - -qt_internal_extend_target(QTextToSpeechPluginSapi CONDITION MSVC +qt_internal_extend_target(QTextToSpeechSapiPlugin CONDITION MSVC COMPILE_OPTIONS /Zc:strictStrings ) -qt_internal_extend_target(QTextToSpeechPluginSapi CONDITION MINGW +qt_internal_extend_target(QTextToSpeechSapiPlugin CONDITION MINGW LIBRARIES ole32 sapi diff --git a/src/plugins/tts/sapi/qtexttospeech_sapi_plugin.cpp b/src/plugins/tts/sapi/qtexttospeech_sapi_plugin.cpp index c5bd476..6bf3ef3 100644 --- a/src/plugins/tts/sapi/qtexttospeech_sapi_plugin.cpp +++ b/src/plugins/tts/sapi/qtexttospeech_sapi_plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. @@ -37,7 +37,7 @@ #include "qtexttospeech_sapi_plugin.h" #include "qtexttospeech_sapi.h" -QTextToSpeechEngine *QTextToSpeechPluginSapi::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const +QTextToSpeechEngine *QTextToSpeechSapiPlugin::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const { Q_UNUSED(errorString); return new QTextToSpeechEngineSapi(parameters, parent); diff --git a/src/plugins/tts/sapi/qtexttospeech_sapi_plugin.h b/src/plugins/tts/sapi/qtexttospeech_sapi_plugin.h index 65afb8c..4f953f8 100644 --- a/src/plugins/tts/sapi/qtexttospeech_sapi_plugin.h +++ b/src/plugins/tts/sapi/qtexttospeech_sapi_plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE -class QTextToSpeechPluginSapi : public QObject, public QTextToSpeechPlugin +class QTextToSpeechSapiPlugin : public QObject, public QTextToSpeechPlugin { Q_OBJECT Q_INTERFACES(QTextToSpeechPlugin) diff --git a/src/plugins/tts/sapi/sapi.pro b/src/plugins/tts/sapi/sapi.pro deleted file mode 100644 index 5a919ee..0000000 --- a/src/plugins/tts/sapi/sapi.pro +++ /dev/null @@ -1,28 +0,0 @@ -TARGET = qtexttospeech_sapi -PLUGIN_TYPE = texttospeech -PLUGIN_CLASS_NAME = QTextToSpeechPluginSapi - -# sapi.h contains some parts that fail with "strictStrings" -QMAKE_CFLAGS_RELEASE -= -Zc:strictStrings -QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings -QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings -QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings -QMAKE_CFLAGS -= -Zc:strictStrings -QMAKE_CXXFLAGS -= -Zc:strictStrings - -load(qt_plugin) - -QT += core texttospeech - -mingw: LIBS += -luuid -lsapi -lole32 - -HEADERS += \ - qtexttospeech_sapi.h \ - qtexttospeech_sapi_plugin.h \ - -SOURCES += \ - qtexttospeech_sapi.cpp \ - qtexttospeech_sapi_plugin.cpp \ - -OTHER_FILES += \ - sapi_plugin.json diff --git a/src/plugins/tts/speechdispatcher/CMakeLists.txt b/src/plugins/tts/speechdispatcher/CMakeLists.txt index 39fa14b..aef58a7 100644 --- a/src/plugins/tts/speechdispatcher/CMakeLists.txt +++ b/src/plugins/tts/speechdispatcher/CMakeLists.txt @@ -1,10 +1,4 @@ -# Generated from speechdispatcher.pro. - -##################################################################### -## QTextToSpeechPluginSpeechd Plugin: -##################################################################### - -qt_internal_add_plugin(QTextToSpeechPluginSpeechd +qt_internal_add_plugin(QTextToSpeechSpeechdPlugin OUTPUT_NAME qtexttospeech_speechd PLUGIN_TYPE texttospeech SOURCES @@ -15,14 +9,7 @@ qt_internal_add_plugin(QTextToSpeechPluginSpeechd Qt::TextToSpeech ) -#### Keys ignored in scope 1:.:.:speechdispatcher.pro:: -# OTHER_FILES = "speechd_plugin.json" -# QT_FOR_CONFIG = "texttospeech-private" - -## Scopes: -##################################################################### - -qt_internal_extend_target(QTextToSpeechPluginSpeechd CONDITION QT_FEATURE_speechd +qt_internal_extend_target(QTextToSpeechSpeechdPlugin CONDITION QT_FEATURE_speechd LIBRARIES SpeechDispatcher::SpeechDispatcher ) diff --git a/src/plugins/tts/speechdispatcher/qtexttospeech_speechd_plugin.cpp b/src/plugins/tts/speechdispatcher/qtexttospeech_speechd_plugin.cpp index 392db80..2702a3d 100644 --- a/src/plugins/tts/speechdispatcher/qtexttospeech_speechd_plugin.cpp +++ b/src/plugins/tts/speechdispatcher/qtexttospeech_speechd_plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. @@ -37,7 +37,7 @@ #include "qtexttospeech_speechd_plugin.h" #include "qtexttospeech_speechd.h" -QTextToSpeechEngine *QTextToSpeechPluginSpeechd::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const +QTextToSpeechEngine *QTextToSpeechSpeechdPlugin::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const { Q_UNUSED(errorString); return new QTextToSpeechEngineSpeechd(parameters, parent); diff --git a/src/plugins/tts/speechdispatcher/qtexttospeech_speechd_plugin.h b/src/plugins/tts/speechdispatcher/qtexttospeech_speechd_plugin.h index a9589c9..eec0394 100644 --- a/src/plugins/tts/speechdispatcher/qtexttospeech_speechd_plugin.h +++ b/src/plugins/tts/speechdispatcher/qtexttospeech_speechd_plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE //Q_DECLARE_LOGGING_CATEGORY(lcSpeechTtsSpeechd) -class QTextToSpeechPluginSpeechd : public QObject, public QTextToSpeechPlugin +class QTextToSpeechSpeechdPlugin : public QObject, public QTextToSpeechPlugin { Q_OBJECT Q_INTERFACES(QTextToSpeechPlugin) diff --git a/src/plugins/tts/speechdispatcher/speechdispatcher.pro b/src/plugins/tts/speechdispatcher/speechdispatcher.pro deleted file mode 100644 index d600700..0000000 --- a/src/plugins/tts/speechdispatcher/speechdispatcher.pro +++ /dev/null @@ -1,21 +0,0 @@ -TARGET = qtexttospeech_speechd -PLUGIN_TYPE = texttospeech -PLUGIN_CLASS_NAME = QTextToSpeechPluginSpeechd - -load(qt_plugin) - -QT = core texttospeech -QT_FOR_CONFIG += texttospeech-private - -HEADERS += \ - qtexttospeech_speechd.h \ - qtexttospeech_speechd_plugin.h \ - -SOURCES += \ - qtexttospeech_speechd.cpp \ - qtexttospeech_speechd_plugin.cpp \ - -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 deleted file mode 100644 index 693bda1..0000000 --- a/src/plugins/tts/tts.pro +++ /dev/null @@ -1,20 +0,0 @@ -TEMPLATE = subdirs - -QT_FOR_CONFIG += texttospeech-private -unix { - qtConfig(speechd) { - SUBDIRS += speechdispatcher - } -} - -windows:!winrt: SUBDIRS += sapi -winrt: SUBDIRS += winrt - -osx: SUBDIRS += osx -uikit: SUBDIRS += ios - -android: SUBDIRS += android - -qtConfig(flite) { - qtHaveModule(multimedia): SUBDIRS += flite -} diff --git a/src/plugins/tts/winrt/CMakeLists.txt b/src/plugins/tts/winrt/CMakeLists.txt index 79debaf..2b3756d 100644 --- a/src/plugins/tts/winrt/CMakeLists.txt +++ b/src/plugins/tts/winrt/CMakeLists.txt @@ -4,7 +4,7 @@ ## QTextToSpeechPluginWinRT Plugin: ##################################################################### -qt_internal_add_plugin(QTextToSpeechPluginWinRT +qt_internal_add_plugin(QTextToSpeechWinRTPlugin OUTPUT_NAME qtexttospeech_winrt PLUGIN_TYPE texttospeech SOURCES diff --git a/src/plugins/tts/winrt/qtexttospeech_winrt_plugin.cpp b/src/plugins/tts/winrt/qtexttospeech_winrt_plugin.cpp index d2cba9c..6f75b32 100644 --- a/src/plugins/tts/winrt/qtexttospeech_winrt_plugin.cpp +++ b/src/plugins/tts/winrt/qtexttospeech_winrt_plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. @@ -37,7 +37,7 @@ #include "qtexttospeech_winrt_plugin.h" #include "qtexttospeech_winrt.h" -QTextToSpeechEngine *QTextToSpeechPluginWinRT::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const +QTextToSpeechEngine *QTextToSpeechWinRTPlugin::createTextToSpeechEngine(const QVariantMap ¶meters, QObject *parent, QString *errorString) const { Q_UNUSED(errorString); return new QTextToSpeechEngineWinRT(parameters, parent); diff --git a/src/plugins/tts/winrt/qtexttospeech_winrt_plugin.h b/src/plugins/tts/winrt/qtexttospeech_winrt_plugin.h index b622eed..4e0260b 100644 --- a/src/plugins/tts/winrt/qtexttospeech_winrt_plugin.h +++ b/src/plugins/tts/winrt/qtexttospeech_winrt_plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE -class QTextToSpeechPluginWinRT : public QObject, public QTextToSpeechPlugin +class QTextToSpeechWinRTPlugin : public QObject, public QTextToSpeechPlugin { Q_OBJECT Q_INTERFACES(QTextToSpeechPlugin) diff --git a/src/plugins/tts/winrt/winrt.pro b/src/plugins/tts/winrt/winrt.pro deleted file mode 100644 index 6896620..0000000 --- a/src/plugins/tts/winrt/winrt.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = qtexttospeech_winrt -PLUGIN_TYPE = texttospeech -PLUGIN_CLASS_NAME = QTextToSpeechPluginWinRT - -load(qt_plugin) - -QT += core core-private texttospeech - -HEADERS += \ - qtexttospeech_winrt.h \ - qtexttospeech_winrt_plugin.h \ - -SOURCES += \ - qtexttospeech_winrt.cpp \ - qtexttospeech_winrt_plugin.cpp \ - -OTHER_FILES += \ - winrt_plugin.json diff --git a/src/src.pro b/src/src.pro deleted file mode 100644 index 16ec641..0000000 --- a/src/src.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = tts plugins doc - -plugins.depends = tts diff --git a/src/tts/CMakeLists.txt b/src/tts/CMakeLists.txt index ec7f35d..1667c68 100644 --- a/src/tts/CMakeLists.txt +++ b/src/tts/CMakeLists.txt @@ -1,9 +1,3 @@ -# Generated from tts.pro. - -##################################################################### -## TextToSpeech Module: -##################################################################### - qt_internal_add_module(TextToSpeech PLUGIN_TYPES texttospeech SOURCES @@ -30,6 +24,3 @@ if(ANDROID) plugins/texttospeech/libplugins_texttospeech_qttexttospeech_android.so ) endif() - -#### Keys ignored in scope 1:.:.:tts.pro:: -# MODULE = "texttospeech" diff --git a/src/tts/tts.pro b/src/tts/tts.pro deleted file mode 100644 index 6eeed2b..0000000 --- a/src/tts/tts.pro +++ /dev/null @@ -1,27 +0,0 @@ -TARGET = QtTextToSpeech -QT = core-private -DEFINES += QTEXTTOSPEECH_LIBRARY -MODULE = texttospeech -MODULE_PLUGIN_TYPES = texttospeech - -load(qt_module) - -HEADERS = \ - qtexttospeech.h \ - qtexttospeechplugin.h \ - qtexttospeechengine.h \ - qtexttospeech_p.h \ - qtexttospeech_global.h \ - qvoice.h \ - qvoice_p.h \ - -SOURCES = \ - qtexttospeech.cpp \ - qtexttospeechplugin.cpp \ - qtexttospeechengine.cpp \ - qvoice.cpp \ - -ANDROID_BUNDLED_JAR_DEPENDENCIES = \ - jar/Qt$${QT_MAJOR_VERSION}AndroidTextToSpeech.jar -ANDROID_LIB_DEPENDENCIES = \ - plugins/texttospeech/libplugins_texttospeech_qttexttospeech_android.so diff --git a/sync.profile b/sync.profile index 5984692..03258be 100644 --- a/sync.profile +++ b/sync.profile @@ -3,16 +3,3 @@ ); %moduleheaders = ( # restrict the module headers to those found in relative path ); -# Module dependencies. -# Every module that is required to build this module should have one entry. -# Each of the module version specifiers can take one of the following values: -# - A specific Git revision. -# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch) -# -%dependencies = ( - "qtbase" => "", - "qtxmlpatterns" => "", - "qtdeclarative" => "", - "qtmultimedia" => "" -); - diff --git a/tests/.prev_CMakeLists.txt b/tests/.prev_CMakeLists.txt deleted file mode 100644 index 2214137..0000000 --- a/tests/.prev_CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Generated from tests.pro. - -if(QT_BUILD_STANDALONE_TESTS) - # Add qt_find_package calls for extra dependencies that need to be found when building - # the standalone tests here. -endif() -qt_build_tests() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2214137..2e6270a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from tests.pro. - if(QT_BUILD_STANDALONE_TESTS) # Add qt_find_package calls for extra dependencies that need to be found when building # the standalone tests here. diff --git a/tests/auto/.prev_CMakeLists.txt b/tests/auto/.prev_CMakeLists.txt deleted file mode 100644 index 52f0893..0000000 --- a/tests/auto/.prev_CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -# Generated from auto.pro. - -add_subdirectory(cmake) -add_subdirectory(texttospeech) diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 57e92e7..cf7b9df 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -1,4 +1 @@ -# Generated from auto.pro. - -# add_subdirectory(cmake) # special case add_subdirectory(texttospeech) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro deleted file mode 100644 index 61e0135..0000000 --- a/tests/auto/auto.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - cmake \ - texttospeech diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt deleted file mode 100644 index 95c1309..0000000 --- a/tests/auto/cmake/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -project(qmake_cmake_files) -enable_testing() -find_package(Qt5Core REQUIRED) - -include("${_Qt5CTestMacros}") - -test_module_includes( - TextToSpeech QTextToSpeech -) diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro deleted file mode 100644 index c4ef553..0000000 --- a/tests/auto/cmake/cmake.pro +++ /dev/null @@ -1,4 +0,0 @@ -# Cause make to do nothing. -TEMPLATE = subdirs -CMAKE_QT_MODULES_UNDER_TEST = texttospeech -CONFIG += ctest_testcase diff --git a/tests/auto/texttospeech/.prev_CMakeLists.txt b/tests/auto/texttospeech/.prev_CMakeLists.txt deleted file mode 100644 index 35a30fb..0000000 --- a/tests/auto/texttospeech/.prev_CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Generated from texttospeech.pro. - -##################################################################### -## tst_qtexttospeech Test: -##################################################################### - -add_qt_test(tst_qtexttospeech - SOURCES - tst_qtexttospeech.cpp - PUBLIC_LIBRARIES - Qt::TextToSpeechPrivate -) - -## Scopes: -##################################################################### - -extend_target(tst_qtexttospeech CONDITION QT_FEATURE_speechd - PUBLIC_LIBRARIES - SpeechDispatcher::SpeechDispatcher -) diff --git a/tests/auto/texttospeech/CMakeLists.txt b/tests/auto/texttospeech/CMakeLists.txt index 8bac777..a15b209 100644 --- a/tests/auto/texttospeech/CMakeLists.txt +++ b/tests/auto/texttospeech/CMakeLists.txt @@ -1,9 +1,3 @@ -# Generated from texttospeech.pro. - -##################################################################### -## tst_qtexttospeech Test: -##################################################################### - qt_internal_add_test(tst_qtexttospeech SOURCES tst_qtexttospeech.cpp @@ -11,10 +5,7 @@ qt_internal_add_test(tst_qtexttospeech Qt::TextToSpeechPrivate ) -## Scopes: -##################################################################### - -qt_find_package(SpeechDispatcher PROVIDED_TARGETS SpeechDispatcher::SpeechDispatcher) # special case +qt_find_package(SpeechDispatcher PROVIDED_TARGETS SpeechDispatcher::SpeechDispatcher) qt_internal_extend_target(tst_qtexttospeech CONDITION QT_FEATURE_speechd PUBLIC_LIBRARIES SpeechDispatcher::SpeechDispatcher diff --git a/tests/auto/texttospeech/texttospeech.pro b/tests/auto/texttospeech/texttospeech.pro deleted file mode 100644 index 8d89574..0000000 --- a/tests/auto/texttospeech/texttospeech.pro +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG += testcase -TARGET = tst_qtexttospeech -QT = testlib core texttospeech-private -SOURCES += tst_qtexttospeech.cpp - -qtConfig(speechd): QMAKE_USE += speechd diff --git a/tests/auto/texttospeech/tst_qtexttospeech.cpp b/tests/auto/texttospeech/tst_qtexttospeech.cpp index 6c0dafd..fe416e8 100644 --- a/tests/auto/texttospeech/tst_qtexttospeech.cpp +++ b/tests/auto/texttospeech/tst_qtexttospeech.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Speech module of the Qt Toolkit. diff --git a/tests/tests.pro b/tests/tests.pro deleted file mode 100644 index 15dd97b..0000000 --- a/tests/tests.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs -CONFIG += no_docs_target -SUBDIRS = auto -- cgit v1.2.3