SimpleGrammarData |
SimpleGrammarData allow user easy to create grammar data
//prepare local command list
ArrayList cmdList = new ArrayList() {{
add("今日の天気");
add("おはよう");
}};//you can customize this list
//Create Grammar class object
//NOTICE : please only use "lower case letter" as naming of grammar name
SimpleGrammarData mGrammarData = new SimpleGrammarData("example");
//setup local command list to grammar class
for (String string : cmdList) {
mGrammarData.addSlot(string);
Log.d(TAG, "add string : " + string);
}
//generate grammar data
mGrammarData.updateBody();
//create and update Grammar to Robot
Log.d(TAG, "createGrammar " + mGrammarData.body);
//NOTICE : please only use "lower case letter" as naming of grammar name
mRobotAPI.createGrammar(mGrammarData.grammar, mGrammarData.body); // Regist cmd
The body in SimpleGrammarData is JSON format and as below
{
"version“: 1.0,
“grammar": "test", //grammar set name
“command": { //command array, if single command only, just only write single array
"single": [
"今日の天気",
"おはよう"
],
}
}
|
VoiceResultJsonParser |
Simple tool to parser Result JSON format
@Override
public void onSpeech2TextComplete(boolean isError, String json) {
String result_string = VoiceResultJsonParser.parseVoiceResult(json);
}
@Override
public void onWakeup(boolean isError, String score, float direction) {
String wakeup_word = VoiceResultJsonParser.parseVoiceResult(score);
}
Json format
{
"version": 1.0, //version control (double base)
"type": 1, //Result format, 1 is Command type, 2 is Recognized type
"result": "Hello", // ASR result(String base)
"class": "com.xxx.lib.voice.hybrid.engine.XXXTWMixEngine", // Engine class name(for debug)
"engine": "ASR solution", //engine solution name
"extra": //extra tag for solution extention (OPTION)
{
//Define :
"content":"String"
},
"content": "XXX", //Extra section (OPTION)
}
|