File indexing completed on 2024-12-22 04:28:25
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 #include "textspeechtotext_export.h" 0009 #include <QObject> 0010 #include <memory> 0011 namespace TextSpeechToText 0012 { 0013 /** 0014 * @brief The SpeechToTextPlugin class 0015 * @author Laurent Montel <montel@kde.org> 0016 */ 0017 class SpeechToTextPluginPrivate; 0018 class TEXTSPEECHTOTEXT_EXPORT SpeechToTextPlugin : public QObject 0019 { 0020 Q_OBJECT 0021 public: 0022 enum PluginStatus { 0023 Unknown = 0, 0024 NoMicrophoneFound, 0025 Waiting, 0026 Running, 0027 Paused, 0028 PermissionMissing, 0029 }; 0030 Q_ENUM(PluginStatus) 0031 0032 explicit SpeechToTextPlugin(QObject *parent = nullptr); 0033 ~SpeechToTextPlugin() override; 0034 0035 [[nodiscard]] QString result() const; 0036 0037 virtual void speechToText() = 0; 0038 0039 [[nodiscard]] virtual int sampleRate() const = 0; 0040 0041 [[nodiscard]] QString defaultLanguage() const; 0042 [[nodiscard]] virtual QIODevice *audioDevice() const = 0; 0043 0044 void setDefaultLanguage(const QString &language); 0045 0046 [[nodiscard]] virtual bool loadSettings() = 0; 0047 0048 virtual void clear() = 0; 0049 0050 Q_SIGNALS: 0051 void speechToTextDone(const QString &result); 0052 0053 private: 0054 std::unique_ptr<SpeechToTextPluginPrivate> const d; 0055 }; 0056 }