科大讯飞语音实现Android拨号之二

科大讯飞语音实现语音拨号

上篇我们就已经提到需要对讯飞语义理解的结果进行解析,并且我们需要获得Json中的name进行联系人匹配

public  String JsRusult(String jsonString){
        JSONObject jsonObject;
        String peopleName;
        StringBuffer ret = new StringBuffer();
        try{
            jsonObject=new JSONObject(jsonString);
            String strQuestion = jsonObject.getString("text");
            String strService = jsonObject.getString("service");
            if ("telephone".equals(strService)){
                peopleName = jsonObject.getJSONObject("semantic").getJSONObject("slots").getString("name");
                ret.append(jsonObject.getJSONObject("semantic").getJSONObject("slots").getString("name"));
                String operationStr = jsonObject.getString("operation");
                String phoneCode = "";
                phoneCode = jsonObject.getJSONObject("semantic").getJSONObject("slots").getString("code");
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return ret.toString();
    }

以上我们返回值为peopleName,这样我们在语义理解的Result中可以取出这个联系人姓名

 Phonename = json.JsRusult(understanderResult.getResultString());

这样我们就获取到了Phonename ,接下来就只需要进行匹配

你可能感兴趣的:(Android)