BuildGrammar.h
Go to the documentation of this file.
1 #include "asr/xunfei/msp_cmn.h"
3 #include "asr/xunfei/qisr.h"
4 #include <fstream>
5 #include <iostream>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <unistd.h>
9 
10 using std::endl;
11 using std::ifstream;
12 using std::ios;
13 using std::ofstream;
14 using std::string;
15 using std::to_string;
16 
17 static const int FRAME_LEN = 640;
18 static const int BUFFER_SIZE = 4096;
19 static const int SAMPLE_RATE_44K = 44100;
20 static const int SAMPLE_RATE_16K = 16000;
21 static const int SAMPLE_RATE_8K = 8000;
22 static const int MAX_GRAMMARID_LEN = 32;
23 static const int MAX_PARAMS_LEN = 1024;
24 static const int BUILD_FINISH = 1;
25 
26 // 自定义的结构体,保存语法网络构建相关的信息
27 // 结构体实例化为asr_data,之后都是将asr_data当作函数参数进行传递
28 // 在buildGrammar构建语法网络、buildGrammarCallback离线识别语法的回调函数时调用
29 typedef struct _UserData
30 {
31  int build_fini; //标识语法构建是否完成
32  int update_fini; //标识更新词典是否完成
33  int errcode; //记录语法构建或更新词典回调错误码
34  char grammar_id[MAX_GRAMMARID_LEN]; //保存语法构建返回的语法ID
35 } UserData;
36 
38 {
39 private:
40  std::string base_path;
41  std::string grammar_build_path;
42  std::string asr_res_path;
43  std::string grammar_file;
45  static int buildGrammarCallback(int ecode, const char* info, void* udata);
46  static int writeIntoFile(const string file_path, UserData* info);
47 
48 public:
49  BuildGrammar();
50  ~BuildGrammar();
51  void buildGrammar(UserData* udata, const string base_path, const string grammar_build_path, const string asr_res_path,
52  const string grammar_file);
53 };
std::string grammar_build_path
Definition: BuildGrammar.h:41
static const int FRAME_LEN
Definition: BuildGrammar.h:17
static const int SAMPLE_RATE_16K
Definition: BuildGrammar.h:20
int update_fini
Definition: BuildGrammar.h:32
static const int BUFFER_SIZE
Definition: BuildGrammar.h:18
static const int MAX_PARAMS_LEN
Definition: BuildGrammar.h:23
std::string grammar_file
Definition: BuildGrammar.h:43
Mobile Speech Platform Common Interface Header File.
iFLY Speech Recognizer Header File
std::string asr_res_path
Definition: BuildGrammar.h:42
struct _UserData UserData
UserData asr_data
Definition: BuildGrammar.h:44
char grammar_id[MAX_GRAMMARID_LEN]
Definition: BuildGrammar.h:34
std::string base_path
Definition: BuildGrammar.h:40
int build_fini
Definition: BuildGrammar.h:31
static const int MAX_GRAMMARID_LEN
Definition: BuildGrammar.h:22
static const int BUILD_FINISH
Definition: BuildGrammar.h:24
static const int SAMPLE_RATE_8K
Definition: BuildGrammar.h:21
static const int SAMPLE_RATE_44K
Definition: BuildGrammar.h:19


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