10 std::string login_parameters =
"appid = 5ade9569, work_dir = " + base_path +
"/defaultconfig";
11 int error_code =
MSPLogin(NULL, NULL, login_parameters.c_str());
14 std::cout <<
"MSPLogin failed :" <<
handleErrorcode(error_code) <<
"errorcode:" << error_code << std::endl;
22 std::ifstream infile(file_path);
33 std::cout <<
"Fail to open expected Json file" << file_path << std::endl;
43 const std::string ASR_RES_PATH =
"fo|res/asr/common.jet";
44 const std::string GRAMMAR_FILE = grammar_file;
45 const std::string GRAMMAR_BUILD_PATH = GRAMMAR_FILE +
"/grammar";
48 std::string filepath = GRAMMAR_BUILD_PATH +
"/info.txt";
51 return std::string(
"engine_type = local, " 52 "asr_denoise=1,vad_bos=10000,vad_eos=10000,asr_res_path =" +
53 ASR_RES_PATH +
", sample_rate = " + to_string(
SAMPLE_RATE_16K) +
", grm_build_path = " +
54 GRAMMAR_BUILD_PATH +
", local_grammar = " + asr_data.
grammar_id +
55 ", result_type = json, result_encoding = UTF-8 ");
67 return "Invalid parameters!";
70 return "Invalid parameter value!";
73 return "Invalid username!";
76 return "Invalid password!";
79 return "Invalid app ID!";
82 return "Not initialized!";
85 return "Fail to create session instance!";
88 return "Invalid session ID!";
94 return "Null handle!";
97 return "Buffer overflow!";
100 return "Please refer to msp_errors.h or official development " 101 "documentation for error codes.";
std::string handleErrorcode(const int errorcode)
static const int SAMPLE_RATE_16K
int MSPAPI MSPLogin(const char *usr, const char *pwd, const char *params)
void loginToXunfei(const std::string base_path)
Mobile Speech Platform Common Interface Header File.
char grammar_id[MAX_GRAMMARID_LEN]
const std::string base_path
std::string configGramParas(const std::string base_path, const std::string grammar_file)
static void readConfig(const string file_path, UserData *info)