-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDeepSpeechC.h
42 lines (31 loc) · 1.13 KB
/
DeepSpeechC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef DEEPSPEECHC_H
#define DEEPSPEECHC_H
#include <QObject>
#include <QQmlEngine>
#include <QtMultimedia/QAudioInput>
#include <QThread>
#include <mutex>
#include "deepspeech.h"
//Wraps Deepspeech library and also handles all AudioInput recording and passing recorded buffers to deepspeech via callbacks
class DeepSpeech : public QObject
{
Q_OBJECT
public:
explicit DeepSpeech(QObject* parent = nullptr);
~DeepSpeech();
public slots:
void init();
void transcribeAudio(); //Takes recorded buffers and pass to deepspeech to transcribe
void setHotword(QString hotword);
void stopRecording();
void startRecording();
signals:
void transcript(QString text); //Signal to inform listeners that new transribed text is ready
private:
QAudioInput* recorder = nullptr; //Records audio from mic
ModelState* model = nullptr; //deepspeech library model
StreamingState* state = nullptr; //deepspeech state
int samplesCollected = 0;
std::mutex lock; //Mutex to prevent race conditions and sync access to deepspeech from other threads
};
#endif // DEEPSPEECHC_H