build_grammar_module.cpp
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <unistd.h>
3 #include <fstream>
4 #include <iostream>
5 #include <string>
7 #include "common_config.h"
8 #include "asr/xunfei/msp_cmn.h"
10 #include "asr/xunfei/qisr.h"
11 
12 using std::endl;
13 using std::string;
14 
15 // 构建离线语法,生成相应文件。构建的语法文件存储在 /config 目录下
16 int main(int argc, const char** argv)
17 {
18  // 此处使用 roslaunch 启动参数为 node path; arg1; arg2; arg3; __name; __log;
19  // 使用 rosrun 启动参数为四个
20  if (argc != 3 && argc != 5)
21  {
22  std::cout << "Wrong number of parameters!" << std::endl;
24  }
25  string base_path(argv[1]);
26  // 生成的语法文件储存路径,与用户自定义文件存放在同意文件夹下
27  string grammar_file(argv[2]);
28  // 使用制定路径存放 grammar.bnf 文件(默认存放在 xbot_talker/cache/grammar_config/grammar 中)
29  string grammar_build_path = grammar_file + "/grammar";
30  grammar_file = grammar_file + "/grammar.bnf";
32  UserData asr_data;
33  // 讯飞语音sdk参数配置
34  //这个路径前必须加一个fo|,否则就会语法构建不通过
35  string asr_res_path = "fo|res/asr/common.jet";
36  // 讯飞登录
37  CommonConfig& xunfei_config = CommonConfig::get_instance();
38  xunfei_config.loginToXunfei(base_path);
39 
40  // 调用 build_grammar 函数,生成语法文件
41  build_grammar.buildGrammar(&asr_data, base_path, grammar_build_path, asr_res_path, grammar_file);
42 
43  return 0;
44 }
static CommonConfig & get_instance()
void loginToXunfei(const std::string base_path)
void build_grammar()
Mobile Speech Platform Common Interface Header File.
iFLY Speech Recognizer Header File
const std::string base_path
void buildGrammar(UserData *udata, const string base_path, const string grammar_build_path, const string asr_res_path, const string grammar_file)
int main(int argc, const char **argv)


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