diff --git a/voiceplusplus/src/Test.java b/voiceplusplus/src/Test.java index fcf46aa..0a02e97 100644 --- a/voiceplusplus/src/Test.java +++ b/voiceplusplus/src/Test.java @@ -23,11 +23,16 @@ public static void main(String[] args) { String pwdString = "*"; // ¿ÚÁîÄÚÈÝ // Create server - Client client = new Client("65e02ffc45b0d01bd09fa3e0e9fe1b14", "65e02ffc45b0d01bd09fa3e0e9fe1b14"); - client.setServer("192.168.1.253", 11638, "1", Constants.TEXT_DEPENDENT); + Client client = new Client("26bf86dc87c11982ec9905ddce8dd6e8", "26bf86dc87c11982ec9905ddce8dd6e8"); + client.setServer("127.0.0.1", 81, "1", Constants.TEXT_DEPENDENT); - // Create Person + // Delete Person Person person = new Person(client, idString, nameString); + if ((ret = person.delete()) != Constants.RETURN_SUCCESS) { + System.err.println(person.getLastErr()+":"+String.valueOf(ret)); + } + + // Create Person if ( (ret = person.getInfo()) != Constants.RETURN_SUCCESS) { if ( (ret = person.create()) != Constants.RETURN_SUCCESS) { System.err.println(person.getLastErr()+":"+String.valueOf(ret)); @@ -58,14 +63,23 @@ public static void main(String[] args) { // Verify voiceprint for speaker VerifyRes res = new VerifyRes(); - speech.setRule("5318"); - speech.setData(readWavform("wav/ver_4digits_5318.wav")); + speech.setRule("4752"); + speech.setVerify(true); + speech.setData(readWavform("wav/imp_4digits_0475.wav")); if ((ret = client.verifyVoiceprint(person, speech, res)) != Constants.RETURN_SUCCESS) { System.err.println(person.getLastErr()+":"+String.valueOf(ret)); } // Output result System.out.println(person.getId()+"\t"+person.getName()+": "+res.getResult()+"-"+res.getSimilarity()); + + // Identify voiceprint for speaker + if ((ret = client.identifyVoiceprint_2(person, speech, res)) != Constants.RETURN_SUCCESS) { + System.err.println(person.getLastErr()+":"+String.valueOf(ret)); + } + + // Output result + System.out.println(person.getId()+"\t"+person.getName()+": "+res.getResult()+"-"+res.getSimilarity()); } public static byte[] readWavform(String filename) { diff --git a/voiceplusplus/src/client/Client.java b/voiceplusplus/src/client/Client.java index 1bc20ca..01b71f6 100644 --- a/voiceplusplus/src/client/Client.java +++ b/voiceplusplus/src/client/Client.java @@ -154,28 +154,7 @@ public synchronized int identifyVoiceprint_2(Person person, Speech speech, int ret = Constants.RETURN_SUCCESS; JSONObject result = getClientService().clientIdentifyVoiceprint_2(person.getId(), - speech.getCodec(), speech.getSampleRate(), speech.getData()); - - if (!result.getBoolean(Constants.SUCCESS)) { - ret = result.getInt(Constants.ERROR_CODE); - super.setLastErr(result.getString(Constants.ERROR)); - super.setErrCode(ret); - } else { - person.setId(result.getString(Constants.ID)); - person.setName(result.getString(Constants.NAME)); - res.setResult(result.getBoolean(Constants.RESULT)); - res.setSimilarity(result.getDouble(Constants.SIMILARITY)); - } - - return ret; - } - - public synchronized int identifyVoiceprint_3(Person person, Speech speech, - VerifyRes res) { - int ret = Constants.RETURN_SUCCESS; - - JSONObject result = getClientService().clientIdentifyVoiceprint_3(person.getId(), - speech.getCodec(), speech.getSampleRate(), speech.getData()); + speech.getCodec(),speech.getSampleRate(), speech.getVerify(), speech.getRule(), speech.getData()); if (!result.getBoolean(Constants.SUCCESS)) { ret = result.getInt(Constants.ERROR_CODE); diff --git a/voiceplusplus/src/service/ClientService.java b/voiceplusplus/src/service/ClientService.java index 9e710a3..78fa72e 100644 --- a/voiceplusplus/src/service/ClientService.java +++ b/voiceplusplus/src/service/ClientService.java @@ -29,6 +29,7 @@ public JSONObject clientVerifyVoiceprint(String id, String name, String codec, i parameters.put(Constants.API_KEY, super.getClient().getKey()); parameters.put(Constants.API_SECRET, super.getClient().getSecret()); parameters.put(Constants.ID, id); + parameters.put(Constants.NAME, name); parameters.put(Constants.CODEC, codec); parameters.put(Constants.SAMPLERATE, String.valueOf(sr)); parameters.put(Constants.VERIFY, String.valueOf(bVerify)); @@ -56,12 +57,14 @@ public JSONObject clientIdentifyVoiceprint(String id, String codec, int sr, byte return tokenJson; } - public JSONObject clientIdentifyVoiceprint_2(String id, String codec, int sr, byte[] data) { + public JSONObject clientIdentifyVoiceprint_2(String id, String codec, int sr, boolean bVerify, String rule, byte[] data) { Map parameters = new HashMap(); parameters.put(Constants.API_KEY, super.getClient().getKey()); parameters.put(Constants.API_SECRET, super.getClient().getSecret()); parameters.put(Constants.CODEC, codec); parameters.put(Constants.SAMPLERATE, String.valueOf(sr)); + parameters.put(Constants.VERIFY, String.valueOf(bVerify)); + parameters.put(Constants.SPEECH_RULE, rule); parameters.put(Constants.ID, id); String tokenResult = HttpURLUtils.doUploadFile(super.getClient().getServerString()+Constants.URL_MODEL_IDENTIFY_2, parameters, @@ -71,21 +74,6 @@ public JSONObject clientIdentifyVoiceprint_2(String id, String codec, int sr, by return tokenJson; } - public JSONObject clientIdentifyVoiceprint_3(String id, String codec, int sr, byte[] data) { - Map parameters = new HashMap(); - parameters.put(Constants.API_KEY, super.getClient().getKey()); - parameters.put(Constants.API_SECRET, super.getClient().getSecret()); - parameters.put(Constants.CODEC, codec); - parameters.put(Constants.SAMPLERATE, String.valueOf(sr)); - parameters.put(Constants.ID, id); - - String tokenResult = HttpURLUtils.doUploadFile(super.getClient().getServerString()+Constants.URL_MODEL_IDENTIFY_3, parameters, - Constants.FILEPARAM, "./testfile.wav", "multipart/form-data;", data); - JSONObject tokenJson = (JSONObject) JSONObject.fromObject(tokenResult); - - return tokenJson; - } - public JSONObject personFindAll(int limit) { Map parameters = new HashMap(); parameters.put(Constants.API_KEY, super.getClient().getKey()); diff --git a/voiceplusplus/src/utils/Constants.java b/voiceplusplus/src/utils/Constants.java index 00c41e0..038aa05 100644 --- a/voiceplusplus/src/utils/Constants.java +++ b/voiceplusplus/src/utils/Constants.java @@ -86,5 +86,4 @@ public class Constants { public static final String URL_MODEL_VERIFY = "/model/verify.json"; public static final String URL_MODEL_IDENTIFY = "/model/identify.json"; public static final String URL_MODEL_IDENTIFY_2 = "/model/identify_2.json"; - public static final String URL_MODEL_IDENTIFY_3 = "/model/identify_3.json"; } diff --git a/voiceplusplus/wav/imp_4digits_0475.wav b/voiceplusplus/wav/imp_4digits_0475.wav new file mode 100644 index 0000000..7026190 Binary files /dev/null and b/voiceplusplus/wav/imp_4digits_0475.wav differ diff --git a/voiceplusplus/wav/imp_4digits_0641.wav b/voiceplusplus/wav/imp_4digits_0641.wav new file mode 100644 index 0000000..9211627 Binary files /dev/null and b/voiceplusplus/wav/imp_4digits_0641.wav differ diff --git a/voiceplusplus/wav/imp_4digits_1047.wav b/voiceplusplus/wav/imp_4digits_1047.wav new file mode 100644 index 0000000..387845c Binary files /dev/null and b/voiceplusplus/wav/imp_4digits_1047.wav differ diff --git a/voiceplusplus/wav/imp_4digits_3408.wav b/voiceplusplus/wav/imp_4digits_3408.wav new file mode 100644 index 0000000..39099ca Binary files /dev/null and b/voiceplusplus/wav/imp_4digits_3408.wav differ diff --git a/voiceplusplus/wav/imp_4digits_6234.wav b/voiceplusplus/wav/imp_4digits_6234.wav new file mode 100644 index 0000000..ef36405 Binary files /dev/null and b/voiceplusplus/wav/imp_4digits_6234.wav differ diff --git a/voiceplusplus/wav/ver_4digits_3408.wav b/voiceplusplus/wav/ver_4digits_3408.wav new file mode 100644 index 0000000..f1511e4 Binary files /dev/null and b/voiceplusplus/wav/ver_4digits_3408.wav differ diff --git a/voiceplusplus/wav/ver_4digits_3506.wav b/voiceplusplus/wav/ver_4digits_3506.wav new file mode 100644 index 0000000..79789bf Binary files /dev/null and b/voiceplusplus/wav/ver_4digits_3506.wav differ diff --git a/voiceplusplus/wav/ver_4digits_4752.wav b/voiceplusplus/wav/ver_4digits_4752.wav new file mode 100644 index 0000000..d08cd51 Binary files /dev/null and b/voiceplusplus/wav/ver_4digits_4752.wav differ