NonStreamingSpeechRecognitionDlg.h
1.5 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// NonStreamingSpeechRecognitionDlg.h : header file
//
#pragma once
#include <string>
#include <vector>
#include "portaudio.h"
#include "sherpa-onnx/c-api/c-api.h"
class Microphone {
public:
Microphone();
~Microphone();
};
// CNonStreamingSpeechRecognitionDlg dialog
class CNonStreamingSpeechRecognitionDlg : public CDialogEx {
// Construction
public:
CNonStreamingSpeechRecognitionDlg(
CWnd *pParent = nullptr); // standard constructor
~CNonStreamingSpeechRecognitionDlg();
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_NONSTREAMINGSPEECHRECOGNITION_DIALOG };
#endif
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOk();
int RunThread();
private:
Microphone mic_;
const SherpaOnnxOfflineRecognizer *recognizer_ = nullptr;
SherpaOnnxOfflineRecognizerConfig config_;
PaStream *pa_stream_ = nullptr;
CButton my_btn_;
CEdit my_text_;
std::vector<std::string> results_;
public:
bool started_ = false;
std::vector<float> samples_;
private:
void AppendTextToEditCtrl(const std::string &s);
void AppendLineToMultilineEditCtrl(const std::string &s);
void InitMicrophone();
bool Exists(const std::string &filename);
void InitRecognizer();
void InitParaformer();
void InitWhisper();
void ShowInitRecognizerHelpMessage();
};