File indexing completed on 2025-04-20 12:50:01
0001 /* 0002 SPDX-FileCopyrightText: 2014-2023 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 Q_REQUIRED_RESULT bool isReady() const; 0029 0030 enum State { 0031 Ready = 0, 0032 Speaking, 0033 Paused, 0034 BackendError, 0035 }; 0036 0037 Q_REQUIRED_RESULT double volume() const; 0038 Q_REQUIRED_RESULT QVector<QLocale> availableLocales() const; 0039 Q_REQUIRED_RESULT QStringList availableEngines() const; 0040 Q_REQUIRED_RESULT QStringList availableVoices() const; 0041 0042 Q_REQUIRED_RESULT QLocale locale() const; 0043 0044 void reloadSettings(); 0045 public Q_SLOTS: 0046 void say(const QString &text); 0047 void stop(); 0048 void pause(); 0049 void resume(); 0050 0051 void setRate(double rate); 0052 void setPitch(double pitch); 0053 void setVolume(double volume); 0054 void setLocale(const QLocale &locale) const; 0055 0056 Q_SIGNALS: 0057 void stateChanged(TextToSpeech::State); 0058 0059 private: 0060 TEXTEDITTEXTTOSPEECH_NO_EXPORT void slotStateChanged(); 0061 TEXTEDITTEXTTOSPEECH_NO_EXPORT explicit TextToSpeech(QObject *parent = nullptr); 0062 0063 std::unique_ptr<TextToSpeechPrivate> const d; 0064 }; 0065 }