xfei_speech_recog.h
Go to the documentation of this file.
1 
7 #ifndef XFEI_SPEECH_RECOG_H_
8 #define XFEI_SPEECH_RECOG_H_
9 #include <iostream>
10 #include "file_operation.h"
11 #include "linuxrec.h"
12 
13 /* 科大讯飞识别状态和参数 */
15 {
16  int ep_stat;
17  int rec_stat; /* 关键词识别状态 */
18  int audio_status; /* 录音buffer的状态 */
19  volatile int state;
20  char* session_begin_params; /* asr各种参数 */
21 };
22 
23 /* 科大讯飞语音识别模块 */
25 {
26 public:
27  XfeiSpeechRecog() : recog_result_vector(2)
28  {
29  }
30 
39  void setAsrParams(const std::string base_path, const std::string pcm_file, const std::string params,
40  const int channel);
41 
46  void initAsr();
47 
52  void getPcmFileData();
53 
59  void getPCMData(struct DataBuff pcm_buff);
60 
68  struct DataBuff recordThroughMIC(const float record_time, bool enable_audio_save);
69 
76  void writeAudioData(const char* audio_data, unsigned int audio_len);
77 
83  char* dataLoopRecog();
84 
89  void uninitAsr();
90 
95  void stopRecordThroughMIC();
96 
102  std::vector<std::string> resultFromJson();
103 
104 private:
110  char* getRecogResultLoop();
111 
117  struct DataBuff getOneChannelData();
118 
123  void saveRecordDataToFile();
124 
125  int record_loops_ = 0;
126  std::vector<std::string> recog_result_vector;
127  const char* session_id_ = NULL;
129  struct DataBuff pcm_data_ = { NULL, 0 }; // 存储pcm音频数据
130  struct speech_recog speech_recog_;
131  char* rec_result_ = NULL; // 保存语音识别结果
132  std::string final_recog_result_;
133  int recog_confidence_ = 0;
134  std::string base_path_;
135  std::string pcm_file_;
136  std::string asr_params_;
137  int channel_;
138  struct recorder* asr_record_ = NULL;
141 };
142 
143 #endif // XFEI_SPEECH_RECOG_H_
std::string asr_params_
std::string pcm_file_
FileOperation pcm_file_operation
volatile int state
std::vector< std::string > recog_result_vector
char * session_begin_params
std::string base_path_
std::string final_recog_result_
const std::string base_path
RecordAlsaAPI record_alsa


xbot_talker
Author(s): wangxiaoyun
autogenerated on Sat Oct 10 2020 03:27:54