KTextAddons

voskspeechtotextplugin.cpp
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "voskspeechtotextplugin.h"
8#include "speechtotext_vosk_debug.h"
9#include "voskspeechtotextdevice.h"
10#include <QIODevice>
11
12VoskSpeechToTextPlugin::VoskSpeechToTextPlugin(QObject *parent)
13 : TextSpeechToText::SpeechToTextPlugin{parent}
14 , mDevice(new VoskSpeechToTextDevice(this))
15{
16 connect(mDevice, &VoskSpeechToTextDevice::result, this, &VoskSpeechToTextPlugin::speechToTextDone);
17}
18
19VoskSpeechToTextPlugin::~VoskSpeechToTextPlugin() = default;
20
21void VoskSpeechToTextPlugin::speechToText()
22{
23 if (!mDevice->available()) {
24 qCWarning(SPEECHTOTEXT_VOSK_LOG) << "Vosk is not available";
25 return;
26 }
27 // TODO
28}
29
30int VoskSpeechToTextPlugin::sampleRate() const
31{
32 return 16000;
33}
34
35QIODevice *VoskSpeechToTextPlugin::audioDevice() const
36{
37 return mDevice;
38}
39
40bool VoskSpeechToTextPlugin::loadSettings()
41{
42 // First setSampleRate
43 VoskSpeechToTextDevice::VoskSpeechToTextDeviceInfo info;
44 info.sampleRate = sampleRate();
45 if (!mDevice->initialize(std::move(info))) {
46 qCWarning(SPEECHTOTEXT_VOSK_LOG) << "Impossible to initialize vosk plugin";
47 return false;
48 }
49 return true;
50}
51
52void VoskSpeechToTextPlugin::clear()
53{
54 mDevice->clear();
55}
56
57#include "moc_voskspeechtotextplugin.cpp"
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:48:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.