summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-05-24 15:16:38 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-05-30 09:27:10 +0200
commit511e23d1bf2dfbca1c419bddf49b2b9c11251a0b (patch)
tree8764a8d541488abb2559cda4a5e76c53e0a97574 /src
parent747d2cc1a15ffcbb3743b77f8f9ba71d1feceb95 (diff)
API review: remove the synthesized signal and the simple slot
They were only need for QML clients, for C++ client the version taking a callable is more convenient. But QML clients cannot really use QAudioFormat (there is no QML version of the type), and operating on QByteArrays is also not something we want QML (or JavaScript code) to do. The engines still emit a signal, as that makes it easier to implement the engine. Change-Id: Ie24a41195cd5b7e27ec2b1562fb3f8e515c5adc3 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Jeremy Whiting <jpwhiting@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/tts/qml/qvoiceselector_p.h54
-rw-r--r--src/tts/qtexttospeech.cpp52
-rw-r--r--src/tts/qtexttospeech.h2
3 files changed, 61 insertions, 47 deletions
diff --git a/src/tts/qml/qvoiceselector_p.h b/src/tts/qml/qvoiceselector_p.h
new file mode 100644
index 0000000..2af1149
--- /dev/null
+++ b/src/tts/qml/qvoiceselector_p.h
@@ -0,0 +1,54 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QVOICESELECTOR_H
+#define QVOICESELECTOR_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qregularexpression.h>
+#include <QtQml/qqml.h>
+#include <QtTextToSpeech/qvoice.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QVoiceSelector
+{
+ Q_GADGET
+ QML_VALUE_TYPE(voiceSelector)
+ QML_STRUCTURED_VALUE
+
+ Q_PROPERTY(QRegularExpression name READ name WRITE setName);
+ Q_PROPERTY(QLocale locale READ locale WRITE setLocale);
+ Q_PROPERTY(QVoice::Age age READ age WRITE setAge);
+ Q_PROPERTY(QVoice::Gender gender READ gender WRITE setGender);
+
+public:
+ QRegularExpression name() const { return m_name; }
+ void setName(const QRegularExpression &name) { m_name = name; }
+ QLocale locale() const { return m_locale; }
+ void setLocale(const QLocale &locale) { m_locale = locale; }
+ QVoice::Age age() const { return m_age; }
+ void setAge(QVoice::Age age) { m_age = age; }
+ QVoice::Gender gender() const { return m_gender; }
+ void setGender(QVoice::Gender gender) { m_gender = gender; }
+
+ QRegularExpression m_name;
+ QLocale m_locale = QLocale::C;
+ QVoice::Age m_age = QVoice::Age(-1);
+ QVoice::Gender m_gender = QVoice::Gender(-1);
+};
+
+QT_END_NAMESPACE
+
+#endif // QVOICESELECTOR_H
diff --git a/src/tts/qtexttospeech.cpp b/src/tts/qtexttospeech.cpp
index bcebc46..193fc8e 100644
--- a/src/tts/qtexttospeech.cpp
+++ b/src/tts/qtexttospeech.cpp
@@ -84,8 +84,6 @@ void QTextToSpeechPrivate::setEngineProvider(const QString &engine, const QVaria
q, [this, q](const QString &word, qsizetype start, qsizetype length){
emit q->sayingWord(word, m_currentUtterance, start, length);
});
- QObject::connect(m_engine.get(), &QTextToSpeechEngine::synthesized,
- q, &QTextToSpeech::synthesized);
} else {
m_providerName.clear();
}
@@ -839,36 +837,6 @@ qsizetype QTextToSpeech::enqueue(const QString &utterance)
}
/*!
- Synthesizes the \a text into raw audio data.
- \since 6.6
-
- This function synthesizes the speech asynchronously into raw audio data.
- When data is available, the \l synthesized() signal is emitted with the
- bytes, and the \l {QAudioFormat}{format} that the data is in.
-
- The \l state property is set to \l Synthesizing when the synthesis starts,
- and to \l Ready once the synthesis is finished. While synthesizing, the
- synthesized() signal might be emitted multiple times, possibly with
- changing values for \c format.
-
- If synthesizing is already in progress, the new text will be queued up
- and synthesized after previously enqueued text has been processed.
-
- \sa say(), stop()
-*/
-void QTextToSpeech::synthesize(const QString &text)
-{
- Q_D(QTextToSpeech);
- if (!d->m_engine)
- return;
-
- if (d->m_engine->state() == QTextToSpeech::Synthesizing)
- d->m_pendingUtterances.enqueue(text);
- else
- d->m_engine->synthesize(text);
-}
-
-/*!
\fn template<typename Functor> void QTextToSpeech::synthesize(
const QString &text, Functor &&functor)
\fn template<typename Functor> void QTextToSpeech::synthesize(
@@ -949,21 +917,15 @@ void QTextToSpeech::synthesizeImpl(const QString &text,
};
d->m_synthesizeConnection = connect(d->m_engine.get(), &QTextToSpeechEngine::synthesized,
context ? context : this, receive);
- synthesize(text);
-}
-/*!
- \fn void QTextToSpeech::synthesized(const QAudioFormat &format, const QByteArray &data)
- \since 6.6
-
- This signal is emitted when pcm \a data is available. The data is encoded in \a format.
- A single call to \l synthesize() might result in several emissions of this signal.
-
- \note This signal requires that the engine has the
- \l {QTextToSpeech::Capability::}{Synthesize} capability.
+ if (!d->m_engine)
+ return;
- \sa synthesize()
-*/
+ if (d->m_engine->state() == QTextToSpeech::Synthesizing)
+ d->m_pendingUtterances.enqueue(text);
+ else
+ d->m_engine->synthesize(text);
+}
/*!
\qmlmethod TextToSpeech::stop(BoundaryHint boundaryHint)
diff --git a/src/tts/qtexttospeech.h b/src/tts/qtexttospeech.h
index 6792cf6..88c6b2a 100644
--- a/src/tts/qtexttospeech.h
+++ b/src/tts/qtexttospeech.h
@@ -149,7 +149,6 @@ public:
public Q_SLOTS:
void say(const QString &text);
qsizetype enqueue(const QString &text);
- void synthesize(const QString &text);
void stop(QTextToSpeech::BoundaryHint boundaryHint = QTextToSpeech::BoundaryHint::Default);
void pause(QTextToSpeech::BoundaryHint boundaryHint = QTextToSpeech::BoundaryHint::Default);
void resume();
@@ -172,7 +171,6 @@ Q_SIGNALS:
void voiceChanged(const QVoice &voice);
void sayingWord(const QString &word, qsizetype id, qsizetype start, qsizetype length);
- void synthesized(const QAudioFormat &format, const QByteArray &data);
void aboutToSynthesize(qsizetype id);
protected: