File indexing completed on 2024-05-12 08:43:39

0001 /*
0002    SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "textedittexttospeech_export.h"
0010 #include <QObject>
0011 #include <memory>
0012 
0013 namespace TextEditTextToSpeech
0014 {
0015 class TextToSpeechPrivate;
0016 /**
0017  * @brief The TextToSpeech class
0018  * @author Laurent Montel <montel@kde.org>
0019  */
0020 class TEXTEDITTEXTTOSPEECH_EXPORT TextToSpeech : public QObject
0021 {
0022     Q_OBJECT
0023 public:
0024     static TextToSpeech *self();
0025 
0026     ~TextToSpeech() override;
0027 
0028     [[nodiscard]] bool isReady() const;
0029 
0030     enum State {
0031         Ready = 0,
0032         Speaking,
0033         Paused,
0034         BackendError,
0035         Synthesizing,
0036     };
0037 
0038     [[nodiscard]] double volume() const;
0039     [[nodiscard]] QVector<QLocale> availableLocales() const;
0040     [[nodiscard]] QStringList availableEngines() const;
0041     [[nodiscard]] QStringList availableVoices() const;
0042 
0043     [[nodiscard]] QLocale locale() const;
0044 
0045     void reloadSettings();
0046 public Q_SLOTS:
0047     void say(const QString &text);
0048     void stop();
0049     void pause();
0050     void resume();
0051 
0052     void setRate(double rate);
0053     void setPitch(double pitch);
0054     void setVolume(double volume);
0055     void setLocale(const QLocale &locale) const;
0056 
0057 Q_SIGNALS:
0058     void stateChanged(TextToSpeech::State);
0059 
0060 private:
0061     TEXTEDITTEXTTOSPEECH_NO_EXPORT void slotStateChanged();
0062     TEXTEDITTEXTTOSPEECH_NO_EXPORT explicit TextToSpeech(QObject *parent = nullptr);
0063 
0064     std::unique_ptr<TextToSpeechPrivate> const d;
0065 };
0066 }