File indexing completed on 2024-12-22 04:28:22
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 "libvoskspeechtotext_private_export.h" 0009 #include <QCryptographicHash> 0010 #include <QObject> 0011 #include <QUrl> 0012 class QTemporaryFile; 0013 class LIBVOSKSPEECHTOTEXT_TESTS_EXPORT VoskDownloadLanguageJob : public QObject 0014 { 0015 Q_OBJECT 0016 public: 0017 struct LIBVOSKSPEECHTOTEXT_TESTS_EXPORT DownloadLanguageInfo { 0018 QUrl url; 0019 QString checksum; 0020 QString name; 0021 QString version; 0022 [[nodiscard]] bool isValid() const; 0023 }; 0024 explicit VoskDownloadLanguageJob(QObject *parent = nullptr); 0025 ~VoskDownloadLanguageJob() override; 0026 void start(); 0027 0028 [[nodiscard]] bool canStart() const; 0029 0030 [[nodiscard]] DownloadLanguageInfo info() const; 0031 void setInfo(const DownloadLanguageInfo &newInfo); 0032 0033 Q_SIGNALS: 0034 void errorText(const QString &str); 0035 void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); 0036 void extractDone(); 0037 0038 private: 0039 void generateInstalledLanguageInfo(); 0040 void extractLanguage(); 0041 void slotGenerateInstalledLanguageInfoDone(); 0042 DownloadLanguageInfo mInfo; 0043 QCryptographicHash *mHash = nullptr; 0044 QTemporaryFile *mDestination = nullptr; 0045 }; 0046 Q_DECLARE_TYPEINFO(VoskDownloadLanguageJob::DownloadLanguageInfo, Q_MOVABLE_TYPE); 0047 LIBVOSKSPEECHTOTEXT_EXPORT QDebug operator<<(QDebug d, const VoskDownloadLanguageJob::DownloadLanguageInfo &t);