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 #include "generateinstalledlanguageinfojob.h"
0008 #include "libvoskspeechtotext_debug.h"
0009 #include <KLocalizedString>
0010 
0011 GenerateInstalledLanguageInfoJob::GenerateInstalledLanguageInfoJob(QObject *parent)
0012     : QObject{parent}
0013 {
0014 }
0015 
0016 GenerateInstalledLanguageInfoJob::~GenerateInstalledLanguageInfoJob() = default;
0017 
0018 void GenerateInstalledLanguageInfoJob::start()
0019 {
0020     if (canStart()) {
0021         if (!VoskEngineUtils::createInstalledLanguageInfo(mInfo.pathToStore, mInfo.info)) {
0022             qCWarning(LIBVOSKSPEECHTOTEXT_LOG) << " Impossible to store installed language info " << mInfo;
0023             Q_EMIT errorText(i18n("Impossible to store language info."));
0024         }
0025     }
0026     Q_EMIT generatedDone();
0027     deleteLater();
0028 }
0029 
0030 bool GenerateInstalledLanguageInfoJob::canStart() const
0031 {
0032     return mInfo.isValid();
0033 }
0034 
0035 GenerateInstalledLanguageInfoJob::LanguageInfo GenerateInstalledLanguageInfoJob::info() const
0036 {
0037     return mInfo;
0038 }
0039 
0040 void GenerateInstalledLanguageInfoJob::setInfo(const GenerateInstalledLanguageInfoJob::LanguageInfo &newInfo)
0041 {
0042     mInfo = newInfo;
0043 }
0044 
0045 bool GenerateInstalledLanguageInfoJob::LanguageInfo::isValid() const
0046 {
0047     return !pathToStore.isEmpty() && info.isValid();
0048 }
0049 
0050 QDebug operator<<(QDebug d, const GenerateInstalledLanguageInfoJob::LanguageInfo &t)
0051 {
0052     d << "info " << t.info;
0053     d << "pathToStore " << t.pathToStore;
0054     return d;
0055 }
0056 
0057 #include "moc_generateinstalledlanguageinfojob.cpp"