Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package qt6-speech for openSUSE:Factory checked in at 2026-11-30 14:24:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/qt6-speech (Old) and /work/SRC/openSUSE:Factory/.qt6-speech.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "qt6-speech" Mon Nov 30 14:24:05 2026 rev:32 rq:1400926 version:6.12.1 Changes: -------- --- /work/SRC/openSUSE:Factory/qt6-speech/qt6-speech.changes 2026-10-18 19:21:55.262270388 +0200 +++ /work/SRC/openSUSE:Factory/.qt6-speech.new.1340718/qt6-speech.changes 2026-11-30 14:24:55.172187156 +0100 @@ -1,0 +2,6 @@ +Tue Nov 24 13:37:51 UTC 2026 - Christophe Marin <[email protected]> + +- Update to 6.12.1 + https://www.qt.io/blog/qt-6.12.1-released + +------------------------------------------------------------------- Old: ---- qtspeech-everywhere-src-6.12.0.tar.xz New: ---- qtspeech-everywhere-src-6.12.1.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ qt6-speech.spec ++++++ --- /var/tmp/diff_new_pack.CJBmZC/_old 2026-11-30 14:24:56.746253848 +0100 +++ /var/tmp/diff_new_pack.CJBmZC/_new 2026-11-30 14:24:56.748253932 +0100 @@ -16,7 +16,7 @@ # -%define real_version 6.12.0 +%define real_version 6.12.1 %define short_version 6.12 %define tar_name qtspeech-everywhere-src %define tar_suffix %{nil} @@ -27,7 +27,7 @@ %endif # Name: qt6-speech%{?pkg_suffix} -Version: 6.12.0 +Version: 6.12.1 Release: 0 Summary: Qt 6 TextToSpeech Library and Plugin License: GPL-2.0-only OR LGPL-3.0-only OR GPL-3.0-only @@ -71,6 +71,7 @@ %package -n qt6-texttospeech-devel Summary: Qt 6 TextToSpeech library - Development files Requires: libQt6TextToSpeech6 = %{version} +Requires: cmake(Qt6Multimedia) = %{real_version} Requires: cmake(Qt6QmlIntegration) = %{real_version} %description -n qt6-texttospeech-devel ++++++ qtspeech-everywhere-src-6.12.0.tar.xz -> qtspeech-everywhere-src-6.12.1.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/.cmake.conf new/qtspeech-everywhere-src-6.12.1/.cmake.conf --- old/qtspeech-everywhere-src-6.12.0/.cmake.conf 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/.cmake.conf 2026-11-17 10:07:37.000000000 +0100 @@ -1,4 +1,4 @@ -set(QT_REPO_MODULE_VERSION "6.12.0") +set(QT_REPO_MODULE_VERSION "6.12.1") set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_ENABLE_STRICT_MODE_UP_TO=QT_VERSION_CHECK(6,11,0)" # not yet in strict mode: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/.tag new/qtspeech-everywhere-src-6.12.1/.tag --- old/qtspeech-everywhere-src-6.12.0/.tag 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/.tag 2026-11-17 10:07:37.000000000 +0100 @@ -1 +1 @@ -332f8a148bf01739140c3a00dd54f3ed98f3b546 +2ac0e41b5f1edbc5bcf75b817a371daa2fac7220 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/coin/axivion/ci_config_linux.json new/qtspeech-everywhere-src-6.12.1/coin/axivion/ci_config_linux.json --- old/qtspeech-everywhere-src-6.12.0/coin/axivion/ci_config_linux.json 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/coin/axivion/ci_config_linux.json 2026-11-17 10:07:37.000000000 +0100 @@ -25,11 +25,11 @@ "_copy_from": "AxivionLinker", "input_files": [ "build/lib/lib*.so*.ir", - "build/qml/*/lib*.so*.ir" + "build/qml/**/lib*.so*.ir" ], "ir": "build/$(env:TESTED_MODULE_COIN).ir", "plugin_files": [ - "build/plugins/*/lib*.so*.ir" + "build/plugins/**/lib*.so*.ir" ] } }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/dependencies.yaml new/qtspeech-everywhere-src-6.12.1/dependencies.yaml --- old/qtspeech-everywhere-src-6.12.0/dependencies.yaml 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/dependencies.yaml 2026-11-17 10:07:37.000000000 +0100 @@ -1,10 +1,10 @@ dependencies: ../qtbase: - ref: 025bdad181de241e81bf853c8a2d7bf3d19261a9 + ref: 5af1a37e31a869cd6eb8a73d82e2c71a450e6634 required: true ../qtdeclarative: - ref: 4332fbbb4c340463dc8cee36dda0c85d932122d8 + ref: 935c3c01bc74fee3b8725ae502cd67bb99e3b7e2 required: false ../qtmultimedia: - ref: 6ca885f084a3984749d53bb50a0e08bdc60e86cc + ref: 1469cb18a238c2f3c442cc1a66e75a1dbf55e717 required: true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/src/plugins/tts/ohos/corespeechkit/texttospeechproxy.cpp new/qtspeech-everywhere-src-6.12.1/src/plugins/tts/ohos/corespeechkit/texttospeechproxy.cpp --- old/qtspeech-everywhere-src-6.12.0/src/plugins/tts/ohos/corespeechkit/texttospeechproxy.cpp 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/src/plugins/tts/ohos/corespeechkit/texttospeechproxy.cpp 2026-11-17 10:07:37.000000000 +0100 @@ -9,6 +9,8 @@ #include <QtCore/private/qnapi_p.h> #include <QtCore/private/qohoslogger_p.h> +#include <functional> + QT_BEGIN_NAMESPACE namespace CoreSpeechKit { @@ -34,6 +36,15 @@ } } +std::optional<std::string> tryGetVoiceStatus(const QNapi::Object &jsVoice) +{ + auto optStatusValue = QNapi::getOptionalPropOrEmpty<QNapi::String>(jsVoice, "status"); + if (optStatusValue.IsEmpty()) + return {}; + + return optStatusValue.Utf8Value(); +} + // Source of values used for EngineMode can be found under section 'online': // https://developer.huawei.com/consumer/en/doc/harmonyos-references/hms-ai-texttospeech#section1638144844811 enum class EngineMode @@ -70,10 +81,12 @@ void speak(const SpeakParams ¶ms) override; void stop() override; - std::vector<VoiceInfo> listVoices() override; void setEngineEventsListener( - std::shared_ptr<TextToSpeechProxy::EngineEventsListener> engineEventsListener); + std::shared_ptr<TextToSpeechProxy::EngineEventsListener> engineEventsListener) override; + + std::string language() const override; + int personTimbre() const override; private: struct JsScopeData @@ -81,7 +94,8 @@ std::shared_ptr<QNapi::Reference<QNapi::Object>> textToSpeechEngineRef; }; - explicit TextToSpeechProxyImpl(const std::string &language, std::shared_ptr<JsScopeData> jsScopeData); + explicit TextToSpeechProxyImpl( + const std::string &language, int personTimbre, std::shared_ptr<JsScopeData> jsScopeData); static q23::expected<std::shared_ptr<JsScopeData>, std::string> tryMakeJsScopeData( const std::string &language, int personTimbre); @@ -89,6 +103,7 @@ std::shared_ptr<JsScopeData> m_jsScopeData; std::shared_ptr<TextToSpeechProxy::EngineEventsListener> m_engineEventsListener; const std::string m_language; + const int m_personTimbre; }; class QtThreadBasedEngineEventsListener : public TextToSpeechProxy::EngineEventsListener @@ -290,7 +305,7 @@ return q23::unexpected(std::move(jsScopeDataOrError.error())); return std::shared_ptr<TextToSpeechProxyImpl>( - new TextToSpeechProxyImpl(language, std::move(jsScopeDataOrError.value()))); + new TextToSpeechProxyImpl(language, personTimbre, std::move(jsScopeDataOrError.value()))); } void TextToSpeechProxyImpl::setEngineEventsListener( @@ -335,12 +350,23 @@ } TextToSpeechProxyImpl::TextToSpeechProxyImpl( - const std::string &language, std::shared_ptr<JsScopeData> jsScopeData) + const std::string &language, int personTimbre, std::shared_ptr<JsScopeData> jsScopeData) : m_jsScopeData(std::move(jsScopeData)) , m_language(language) + , m_personTimbre(personTimbre) { } +std::string TextToSpeechProxyImpl::language() const +{ + return m_language; +} + +int TextToSpeechProxyImpl::personTimbre() const +{ + return m_personTimbre; +} + void TextToSpeechProxyImpl::speak(const SpeakParams ¶ms) { QOhosJsThreadGateway::runAndWait( @@ -381,13 +407,23 @@ Q_FUNC_INFO); } -std::vector<VoiceInfo> TextToSpeechProxyImpl::listVoices() +} + +TextToSpeechProxy::TextToSpeechProxy() = default; + +TextToSpeechProxy::~TextToSpeechProxy() = default; + +TextToSpeechProxy::EngineEventsListener::EngineEventsListener() = default; + +TextToSpeechProxy::EngineEventsListener::~EngineEventsListener() = default; + +std::optional<std::vector<VoiceInfo>> tryListVoices() { - return QOhosJsThreadGateway::evalWithPromise<std::vector<VoiceInfo>>( - [&](QOhosJsState &jsState, QOhosTaskPromise<std::vector<VoiceInfo>> evalPromise) { + return QOhosJsThreadGateway::evalWithPromise<std::optional<std::vector<VoiceInfo>>>( + [](QOhosJsState &jsState, QOhosTaskPromise<std::optional<std::vector<VoiceInfo>>> evalPromise) { auto thenCatchPromises = std::move(evalPromise).makeThenCatchBranches(Q_FUNC_INFO); - m_jsScopeData->textToSpeechEngineRef->evalToPromiseOrRejectOnThrow( - "listVoices(*)", + jsState.evalToPromiseOrRejectOnThrow( + "@kit.CoreSpeechKit.textToSpeech.listVoices(*)", { QNapi::makeObject( jsState.env(), @@ -410,40 +446,27 @@ .gender = jsVoice.get<QNapi::String>("gender"), .description = jsVoice.get<QNapi::String>("description"), .personTimbre = jsVoice.get<QNapi::Number>("person"), + .status = tryGetVoiceStatus(jsVoice), }; })); }) .onCatch( [catchPromise = std::move(thenCatchPromises.second)](const QOhosCallbackInfo &cbInfo) { QtOhos::logJsCallbackError(cbInfo, "listVoices() failed"); - catchPromise({}); + catchPromise(std::nullopt); }); }, Q_FUNC_INFO); } -} - -TextToSpeechProxy::TextToSpeechProxy() = default; - -TextToSpeechProxy::~TextToSpeechProxy() = default; - -TextToSpeechProxy::EngineEventsListener::EngineEventsListener() = default; - -TextToSpeechProxy::EngineEventsListener::~EngineEventsListener() = default; - -q23::expected<std::function<std::shared_ptr<TextToSpeechProxy>(std::shared_ptr<TextToSpeechProxy::EngineEventsListener>)>, std::string> tryMakeTextToSpeechProxyFactory( +q23::expected<std::shared_ptr<TextToSpeechProxy>, std::string> tryMakeTextToSpeechProxy( const std::string &language, int personTimbre) { auto proxyImplInstanceOrError = TextToSpeechProxyImpl::tryMakeInstance(language, personTimbre); if (!proxyImplInstanceOrError) return q23::unexpected(std::move(proxyImplInstanceOrError.error())); - return std::function<std::shared_ptr<TextToSpeechProxy>(std::shared_ptr<TextToSpeechProxy::EngineEventsListener>)>( - [proxyImplInstance = std::move(proxyImplInstanceOrError.value())](std::shared_ptr<TextToSpeechProxy::EngineEventsListener> engineEventsListener) { - proxyImplInstance->setEngineEventsListener(engineEventsListener); - return proxyImplInstance; - }); + return std::move(proxyImplInstanceOrError.value()); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/src/plugins/tts/ohos/corespeechkit/texttospeechproxy.h new/qtspeech-everywhere-src-6.12.1/src/plugins/tts/ohos/corespeechkit/texttospeechproxy.h --- old/qtspeech-everywhere-src-6.12.0/src/plugins/tts/ohos/corespeechkit/texttospeechproxy.h 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/src/plugins/tts/ohos/corespeechkit/texttospeechproxy.h 2026-11-17 10:07:37.000000000 +0100 @@ -8,7 +8,6 @@ #include <QtCore/private/qexpected_p.h> #include <cstdint> -#include <functional> #include <memory> #include <optional> #include <string> @@ -40,6 +39,7 @@ std::string gender; std::string description; int personTimbre; + std::optional<std::string> status; }; class TextToSpeechProxy @@ -66,13 +66,18 @@ virtual void speak(const SpeakParams ¶ms) = 0; virtual void stop() = 0; - virtual std::vector<VoiceInfo> listVoices() = 0; + virtual void setEngineEventsListener(std::shared_ptr<EngineEventsListener> engineEventsListener) = 0; + + virtual std::string language() const = 0; + virtual int personTimbre() const = 0; protected: TextToSpeechProxy(); }; -q23::expected<std::function<std::shared_ptr<TextToSpeechProxy>(std::shared_ptr<TextToSpeechProxy::EngineEventsListener>)>, std::string> tryMakeTextToSpeechProxyFactory( +std::optional<std::vector<VoiceInfo>> tryListVoices(); + +q23::expected<std::shared_ptr<TextToSpeechProxy>, std::string> tryMakeTextToSpeechProxy( const std::string &language, int personTimbre); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/src/plugins/tts/ohos/qtexttospeech_ohos.cpp new/qtspeech-everywhere-src-6.12.1/src/plugins/tts/ohos/qtexttospeech_ohos.cpp --- old/qtspeech-everywhere-src-6.12.0/src/plugins/tts/ohos/qtexttospeech_ohos.cpp 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/src/plugins/tts/ohos/qtexttospeech_ohos.cpp 2026-11-17 10:07:37.000000000 +0100 @@ -9,13 +9,14 @@ #include <QtTextToSpeech/qvoice.h> +#include <QtCore/qcoreapplication.h> #include <QtCore/qlist.h> #include <QtCore/qlocale.h> #include <QtCore/qloggingcategory.h> #include <QtCore/qstring.h> +#include <array> #include <cstdint> -#include <functional> #include <memory> #include <optional> @@ -23,9 +24,7 @@ namespace { -constexpr const char *chineseLanguage = "zh-CN"; constexpr const char *chineseLanguageContext = "zh-CN"; -constexpr int defaultPersonTimbre = 0; QVoice::Gender mapVoiceGender(const std::string &gender) { @@ -34,6 +33,32 @@ QVoice::Gender::Unknown; } +// Source of values used for VoiceStatus can be found under section 'VoiceInfo.status': +// https://developer.huawei.com/consumer/en/doc/harmonyos-references/hms-ai-texttospeech +enum class VoiceStatus +{ + Downloadable, + Installed, + Unavailable, +}; + +std::optional<VoiceStatus> mapVoiceStatus(const std::string &status) +{ + static constexpr std::array<std::pair<VoiceStatus, const char *>, 3> voiceStatuses = {{ + {VoiceStatus::Downloadable, "GA"}, + {VoiceStatus::Installed, "INSTALLED"}, + {VoiceStatus::Unavailable, "EOM"}, + }}; + + for (const auto &[voiceStatus, ohosStatus] : voiceStatuses) { + if (status == ohosStatus) + return voiceStatus; + } + + qCWarning(lcSpeechTtsOhos) << "unexpected voice status:" << QString::fromStdString(status); + return {}; +} + QVariantMap mapVoiceExtraData(const CoreSpeechKit::VoiceInfo &info) { return QVariantMap{ @@ -42,6 +67,48 @@ }; } +struct EngineError +{ + QTextToSpeech::ErrorReason reason; + QString message; +}; + +// Source of the error codes can be found under section 'Error Codes': +// https://developer.huawei.com/consumer/en/doc/harmonyos-references/errorcode-corespeech +EngineError mapTtsError(std::uint32_t errorCode) +{ + static constexpr std::uint32_t ohosTextOutOfRangeOrEmptyValue = 1002300001; + static constexpr std::uint32_t ohosLanguageNotSupportedValue = 1002300002; + static constexpr std::uint32_t ohosPersonNotSupportedValue = 1002300003; + static constexpr std::uint32_t ohosCreateEngineFailedValue = 1002300005; + static constexpr std::uint32_t ohosParameterErrorValue = 1002300009; + + switch (errorCode) { + case ohosTextOutOfRangeOrEmptyValue: + return { + QTextToSpeech::ErrorReason::Input, + QCoreApplication::translate("QTextToSpeech", "Speech synthesizing failure.") + }; + case ohosLanguageNotSupportedValue: + case ohosPersonNotSupportedValue: + case ohosParameterErrorValue: + return { + QTextToSpeech::ErrorReason::Configuration, + QCoreApplication::translate("QTextToSpeech", "Could not apply text-to-speech parameters.") + }; + case ohosCreateEngineFailedValue: + return { + QTextToSpeech::ErrorReason::Initialization, + QCoreApplication::translate("QTextToSpeech", "Failed to initialize text-to-speech engine.") + }; + default: + return { + QTextToSpeech::ErrorReason::Playback, + QCoreApplication::translate("QTextToSpeech", "Unknown error: %1.").arg(errorCode) + }; + } +} + double mapVolumeToOhosVolume(double volume) { constexpr double maxTtsVolume = 2.0; @@ -71,10 +138,7 @@ class QTextToSpeechEngineOhos : public QTextToSpeechEngine { public: - QTextToSpeechEngineOhos( - const QVariantMap ¶meters, QObject *parent, - std::function<std::shared_ptr<CoreSpeechKit::TextToSpeechProxy>( - std::shared_ptr<CoreSpeechKit::TextToSpeechProxy::EngineEventsListener>)> ttsProxyFactory); + QTextToSpeechEngineOhos(const QVariantMap ¶meters, QObject *parent); QList<QLocale> availableLocales() const override; QList<QVoice> availableVoices() const override; @@ -118,13 +182,17 @@ void handleOnError( const QString &utteranceId, std::uint32_t errorCode, const QString &errorMessage); void setState(QTextToSpeech::State state); + void setError(const EngineError &error); + bool prepareTextToSpeechProxyForCurrentVoice(); std::shared_ptr<CoreSpeechKit::TextToSpeechProxy> m_ttsProxy; QTextToSpeech::State m_state; + QTextToSpeech::ErrorReason m_errorReason; + QString m_errorString; QList<QVoice> m_voices; QList<QLocale> m_locales; - QLocale m_currentLocale; + QVoice m_currentVoice; double m_volume; double m_rate; double m_pitch; @@ -159,17 +227,30 @@ QString::fromStdString(utteranceId), errorCode, QString::fromStdString(errorMessage)); } -QTextToSpeechEngineOhos::QTextToSpeechEngineOhos( - const QVariantMap &, QObject *parent, - std::function<std::shared_ptr<CoreSpeechKit::TextToSpeechProxy>(std::shared_ptr<CoreSpeechKit::TextToSpeechProxy::EngineEventsListener>)> ttsProxyFactory) +QTextToSpeechEngineOhos::QTextToSpeechEngineOhos(const QVariantMap &, QObject *parent) : QTextToSpeechEngine(parent) , m_state(QTextToSpeech::Ready) + , m_errorReason(QTextToSpeech::ErrorReason::NoError) , m_volume(1.0) , m_rate(0.0) , m_pitch(0.0) { - m_ttsProxy = ttsProxyFactory(std::make_shared<TextToSpeechEngineEventsListener>(*this)); - for (const auto &voiceInfo : m_ttsProxy->listVoices()) { + auto optVoices = CoreSpeechKit::tryListVoices(); + if (!optVoices) { + setError({ + QTextToSpeech::ErrorReason::Configuration, + QCoreApplication::translate("QTextToSpeech", "Failed to initialize default locale and voice.") + }); + return; + } + + for (const auto &voiceInfo : *optVoices) { + if (voiceInfo.status) { + const auto optStatus = mapVoiceStatus(*voiceInfo.status); + if (optStatus && *optStatus != VoiceStatus::Installed) + continue; + } + QLocale locale(QString::fromStdString(voiceInfo.language)); m_voices.append( createVoice( @@ -181,8 +262,8 @@ m_locales.append(locale); } - if (!m_locales.isEmpty()) - m_currentLocale = m_locales.first(); + if (!m_voices.isEmpty()) + m_currentVoice = m_voices.first(); } void QTextToSpeechEngineOhos::handleOnStart(const QString &) @@ -194,7 +275,10 @@ const QString &, std::optional<CoreSpeechKit::TtsCompletionType> optCompletionType) { if (!optCompletionType) { - setState(QTextToSpeech::Error); + setError({ + QTextToSpeech::ErrorReason::Playback, + QCoreApplication::translate("QTextToSpeech", "Speech synthesizing failure.") + }); return; } @@ -210,18 +294,44 @@ void QTextToSpeechEngineOhos::handleOnError( const QString &utteranceId, std::uint32_t errorCode, const QString &errorMessage) { - setState(QTextToSpeech::Error); qCWarning(lcSpeechTtsOhos) << Q_FUNC_INFO << ": text to speech error: code" << errorCode << errorMessage << ", utteranceId:" << utteranceId; + + setError(mapTtsError(errorCode)); } void QTextToSpeechEngineOhos::setState(QTextToSpeech::State state) { - if (state != m_state) { - m_state = state; + if (m_state == state) + return; + + m_state = state; + Q_EMIT stateChanged(m_state); + + if (m_state == QTextToSpeech::Error) { + Q_EMIT errorOccurred(m_errorReason, m_errorString); + } else { + m_errorReason = QTextToSpeech::ErrorReason::NoError; + m_errorString.clear(); + } +} + +void QTextToSpeechEngineOhos::setError(const EngineError &error) +{ + m_errorReason = error.reason; + m_errorString = error.message; + + if (error.reason == QTextToSpeech::ErrorReason::NoError) { + m_errorString.clear(); + return; + } + + if (m_state != QTextToSpeech::Error) { + m_state = QTextToSpeech::Error; Q_EMIT stateChanged(m_state); } + Q_EMIT errorOccurred(m_errorReason, m_errorString); } QList<QLocale> QTextToSpeechEngineOhos::availableLocales() const @@ -233,18 +343,58 @@ { QList<QVoice> voices; for (const auto &voice : m_voices) { - if (voice.locale() == m_currentLocale) + if (voice.locale() == m_currentVoice.locale()) voices << voice; } return voices; } +bool QTextToSpeechEngineOhos::prepareTextToSpeechProxyForCurrentVoice() +{ + if (m_currentVoice == QVoice()) { + setError({ + QTextToSpeech::ErrorReason::Configuration, + QCoreApplication::translate("QTextToSpeech", "Failed to initialize default locale and voice.") + }); + return false; + } + + const auto language = m_currentVoice.locale().name(QLocale::TagSeparator::Dash).toStdString(); + const auto personTimbre = voiceData(m_currentVoice).toMap()[QStringLiteral("person")].toInt(); + + if (m_ttsProxy && m_ttsProxy->language() == language + && m_ttsProxy->personTimbre() == personTimbre) { + return true; + } + + m_ttsProxy.reset(); + auto ttsProxyOrError = CoreSpeechKit::tryMakeTextToSpeechProxy(language, personTimbre); + + if (!ttsProxyOrError) { + qCWarning(lcSpeechTtsOhos) + << Q_FUNC_INFO << ": could not create an engine for voice" << m_currentVoice.name() + << "TTS error:" << QString::fromStdString(ttsProxyOrError.error()); + setError({ + QTextToSpeech::ErrorReason::Initialization, + QCoreApplication::translate("QTextToSpeech", "Failed to initialize text-to-speech engine.") + }); + return false; + } + + m_ttsProxy = std::move(ttsProxyOrError.value()); + m_ttsProxy->setEngineEventsListener(std::make_shared<TextToSpeechEngineEventsListener>(*this)); + return true; +} + void QTextToSpeechEngineOhos::say(const QString &text) { if (text.isEmpty()) return; + if (!prepareTextToSpeechProxyForCurrentVoice()) + return; + m_ttsProxy->speak( { .text = text.toStdString(), @@ -262,6 +412,9 @@ void QTextToSpeechEngineOhos::stop(QTextToSpeech::BoundaryHint) { + if (!m_ttsProxy) + return; + m_ttsProxy->stop(); } @@ -299,7 +452,7 @@ QLocale QTextToSpeechEngineOhos::locale() const { - return m_currentLocale; + return m_currentVoice.locale(); } bool QTextToSpeechEngineOhos::setLocale(const QLocale &locale) @@ -307,8 +460,17 @@ if (!m_locales.contains(locale)) return false; - m_currentLocale = locale; - return true; + if (m_currentVoice.locale() == locale) + return true; + + for (const auto &voice : m_voices) { + if (voice.locale() == locale) { + m_currentVoice = voice; + return true; + } + } + + return false; } double QTextToSpeechEngineOhos::volume() const @@ -324,12 +486,18 @@ QVoice QTextToSpeechEngineOhos::voice() const { - return {}; + return m_currentVoice; } -bool QTextToSpeechEngineOhos::setVoice(const QVoice &) +bool QTextToSpeechEngineOhos::setVoice(const QVoice &voice) { - return false; + if (!m_voices.contains(voice)) { + qCWarning(lcSpeechTtsOhos) << "voice" << voice.name() << "is not available in this engine"; + return false; + } + + m_currentVoice = voice; + return true; } QTextToSpeech::State QTextToSpeechEngineOhos::state() const @@ -339,14 +507,12 @@ QTextToSpeech::ErrorReason QTextToSpeechEngineOhos::errorReason() const { - qCWarning(lcSpeechTtsOhos) << Q_FUNC_INFO << ": errorReason feature is not supported"; - return QTextToSpeech::ErrorReason::NoError; + return m_errorReason; } QString QTextToSpeechEngineOhos::errorString() const { - qCWarning(lcSpeechTtsOhos) << Q_FUNC_INFO << ": errorString feature is not supported"; - return QString(); + return m_errorString; } } @@ -354,16 +520,8 @@ QTextToSpeechEngine *createQTextToSpeechEngineOhos( const QVariantMap ¶meters, QObject *parent, QString *errorString) { - auto ttsProxyFactoryOrError = CoreSpeechKit::tryMakeTextToSpeechProxyFactory( - chineseLanguage, defaultPersonTimbre); - - if (!ttsProxyFactoryOrError) { - if (errorString != nullptr) - *errorString = QString::fromStdString(ttsProxyFactoryOrError.error()); - return nullptr; - } - return new QTextToSpeechEngineOhos( - parameters, parent, std::move(ttsProxyFactoryOrError.value())); + Q_UNUSED(errorString); + return new QTextToSpeechEngineOhos(parameters, parent); } QT_END_NAMESPACE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/src/tts/doc/src/qttexttospeech-engines.qdoc new/qtspeech-everywhere-src-6.12.1/src/tts/doc/src/qttexttospeech-engines.qdoc --- old/qtspeech-everywhere-src-6.12.0/src/tts/doc/src/qttexttospeech-engines.qdoc 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/src/tts/doc/src/qttexttospeech-engines.qdoc 2026-11-17 10:07:37.000000000 +0100 @@ -85,11 +85,18 @@ {Core Speech Kit} text-to-speech APIs. The system engine synthesizes and plays back the speech. - The Core Speech Kit engine is created for a fixed language, which the plugin sets to - \c {zh-CN}. As stated in the \l{https://developer.huawei.com/consumer/en/doc/harmonyos-references/hms-ai-texttospeech#createengineparams} + A Core Speech Kit engine is created for one language and one timbre, so the plugin + creates it for the currently selected voice, and replaces it when the voice changes. + As stated in the \l{https://developer.huawei.com/consumer/en/doc/harmonyos-references/hms-ai-texttospeech#createengineparams} {createEngine() documentation}, only Chinese and English are supported, with \c {zh-CN} recommended for Chinese and \c {en-US} for English. + \l{QTextToSpeech::}{availableVoices()} reports only the voices whose timbre model + is installed on the device. An engine cannot be created for a voice that is not + installed, so such voices are not offered. Core Speech Kit can download a timbre + model, but there is no API in Qt to request that download; the voice has to be + installed outside the application. + \note The HarmonyOS engine only has the \l{QTextToSpeech::Capabilities}{Speak} capability. It supports neither \l{QTextToSpeech::Capabilities}{PauseResume}, \l{QTextToSpeech::Capabilities}{WordByWordProgress}, nor diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/src/tts/qml/qvoiceselectorattached.cpp new/qtspeech-everywhere-src-6.12.1/src/tts/qml/qvoiceselectorattached.cpp --- old/qtspeech-everywhere-src-6.12.0/src/tts/qml/qvoiceselectorattached.cpp 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/src/tts/qml/qvoiceselectorattached.cpp 2026-11-17 10:07:37.000000000 +0100 @@ -13,6 +13,7 @@ /*! \qmltype VoiceSelector + \nativetype QVoiceSelectorAttached \inqmlmodule QtTextToSpeech \since 6.6 \brief Provides attached properties for selecting the voice of a TextToSpeech diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/src/tts/qtexttospeech.cpp new/qtspeech-everywhere-src-6.12.1/src/tts/qtexttospeech.cpp --- old/qtspeech-everywhere-src-6.12.0/src/tts/qtexttospeech.cpp 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/src/tts/qtexttospeech.cpp 2026-11-17 10:07:37.000000000 +0100 @@ -253,6 +253,7 @@ /*! \qmltype TextToSpeech + \nativetype QTextToSpeech \inqmlmodule QtTextToSpeech \brief The TextToSpeech type provides access to text-to-speech engines. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/src/tts/qvoice.cpp new/qtspeech-everywhere-src-6.12.1/src/tts/qvoice.cpp --- old/qtspeech-everywhere-src-6.12.0/src/tts/qvoice.cpp 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/src/tts/qvoice.cpp 2026-11-17 10:07:37.000000000 +0100 @@ -21,6 +21,7 @@ /*! \qmlvaluetype voice + \nativetype QVoiceForeign \inqmlmodule QtTextToSpeech \brief The voice type represents a particular voice. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtspeech-everywhere-src-6.12.0/tests/auto/qtexttospeech/BLACKLIST new/qtspeech-everywhere-src-6.12.1/tests/auto/qtexttospeech/BLACKLIST --- old/qtspeech-everywhere-src-6.12.0/tests/auto/qtexttospeech/BLACKLIST 2026-09-26 19:45:17.000000000 +0200 +++ new/qtspeech-everywhere-src-6.12.1/tests/auto/qtexttospeech/BLACKLIST 2026-11-17 10:07:37.000000000 +0100 @@ -2,5 +2,12 @@ macos-13 ci # QTBUG-108205 macos-15 arm ci # QTBUG-108205 macos-26 arm ci # QTBUG-108205 + [sayingWordWithPause:darwin] macos-13 ci # QTBUG-108205 + +[sayingWordWithPause:sapi] +ci # QTBUG-151355 + +[synthesize:winrt] +ci # QTBUG-151355
