public class

VoiceResultJsonParser

extends Object
java.lang.Object
   ↳ com.nuwarobotics.service.agent.VoiceResultJsonParser

Class Overview

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)
 }
 

Summary

Public Constructors
VoiceResultJsonParser()
Public Methods
static Object parseExtraData(String json, String key)
Get value of specific key field
static String parseVoiceResult(String json)
Get recognize result string from JSON
static int parseVoiceType(String json)
Get recognized result type from JSON
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public VoiceResultJsonParser ()

Public Methods

public static Object parseExtraData (String json, String key)

Get value of specific key field

Parameters
json recognized result json
key specific field
Returns
  • result object

public static String parseVoiceResult (String json)

Get recognize result string from JSON

Parameters
json recognized result json
Returns
  • recognized voice string

public static int parseVoiceType (String json)

Get recognized result type from JSON

Parameters
json recognized result json
Returns
  • recognized type