A fully comprehensive SDK that gives you access to the VoiceIt's New VoiceIt API 2.0 featuring Voice + Face Verification and Identification right in your Android app.
- Getting Started
- Installation
- API Calls
Sign up for a free Developer Account at VoiceIt.io and activate API 2.0 from the settings page. Then you should be able view the API Key and Token (as shown below). You can also review the HTTP Documentation at api.voiceit.io.
VoiceItApi2AndroidSDK is available through JitPack.
First import VoiceItAPI2 and then initialize a reference to the SDK inside an Activity, passing in the API Credentials.
import com.loopj.android.http.JsonHttpResponseHandler;
import cz.msebera.android.httpclient.Header;
import org.json.JSONObject;
import com.voiceit.voiceit2.VoiceItAPI2;
public class MainActivity extends AppCompatActivity {
public VoiceItAPI2 myVoiceIt2;
public Activity mActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myVoiceIt2 = new VoiceItAPI2("API_KEY","API_TOK");
mActivity = this;
}
}
For each API call, a JsonHttpResponseHandler is needed to receive the result of the call. You can Override the response handlers like so, and abbreviated below:
new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
System.out.println("JSONResult : " + response.toString());
}
@Override
public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
if (errorResponse != null) {
System.out.println("JSONResult : " + errorResponse.toString());
}
}
});
Get all the users associated with the apiKey
myVoiceIt.getAllUsers(new JsonHttpResponseHandler() {...});
Create a new user
myVoiceIt.createUser(new JsonHttpResponseHandler() {...});
Check whether a user exists for the given userId(begins with 'usr_')
myVoiceIt.getUser("USER_ID_HERE", new JsonHttpResponseHandler() {...});
Delete user with given userId(begins with 'usr_')
myVoiceIt.deleteUser("USER_ID_HERE", new JsonHttpResponseHandler() {...});
Get a list of groups that the user with given userId(begins with 'usr_') is a part of
myVoiceIt.getGroupsForUser("USER_ID_HERE", new JsonHttpResponseHandler() {...});
Get all the groups associated with the apiKey
myVoiceIt.getAllGroups(new JsonHttpResponseHandler() {...});
Returns a group for the given groupId(begins with 'grp_')
myVoiceIt.getGroup("GROUP_ID_HERE", new JsonHttpResponseHandler() {...});
Checks if group with given groupId(begins with 'grp_') exists
myVoiceIt.groupExists("GROUP_ID_HERE", new JsonHttpResponseHandler() {...});
Create a new group with the given description
myVoiceIt.createGroup("Sample Group Description", new JsonHttpResponseHandler() {...});
Adds user with given userId(begins with 'usr_') to group with given groupId(begins with 'grp_')
myVoiceIt.addUserToGroup("GROUP_ID_HERE", "USER_ID_HERE", new JsonHttpResponseHandler() {...});
Removes user with given userId(begins with 'usr_') from group with given groupId(begins with 'grp_')
myVoiceIt.removeUserFromGroup( "GROUP_ID_HERE", "USER_ID_HERE", new JsonHttpResponseHandler() {...});
Delete group with given groupId(begins with 'grp_'), note: this call does not delete any users, but simply deletes the group and disassociates the users from the group
myVoiceIt.deleteGroup("GROUP_ID_HERE", new JsonHttpResponseHandler() {...});
Gets all enrollment for user with given userId(begins with 'usr_')
myVoiceIt.getAllEnrollmentsForuser("USER_ID_HERE", new JsonHttpResponseHandler() {...});
Delete enrollment for user with given userId(begins with 'usr_') and enrollmentId(integer)
myVoiceIt.deleteEnrollmentForUser( "USER_ID_HERE", "ENROLLMENT_ID_HERE", new JsonHttpResponseHandler() {...});
Create audio enrollment for user with given userId(begins with 'usr_') and contentLanguage('en-US','es-ES' etc.). Note: Immediately upon calling this method it records the user saying their VoicePrint phrase for 5 seconds calling the recordingFinished callback first, then it sends the recording to be added as an enrollment and returns the result in the callback
myVoiceIt.createVoiceEnrollment("USER_ID_HERE", "CONTENT_LANGUAGE_HERE", new JsonHttpResponseHandler() {...});
Create video enrollment for user with given userId(begins with 'usr_') and contentLanguage('en-US','es-ES' etc.). Note: File recording need to be no less than 1.2 seconds and no more than 5 seconds
myVoiceIt.createVideoEnrollment("USER_ID_HERE", "CONTENT_LANGUAGE_HERE", File video, new JsonHttpResponseHandler() {...});
Create three video enrollments for user with given userId(begins with 'usr_') and contentLanguage('en-US','es-ES', etc.) and a given phrase such as "my face and voice identify me". Note: Immediately upon calling this method it displays the user and enrollment view controller that completely takes care of the three enrollments, including the UI and then provides relevant callbacks for whether the user cancelled their enrollments or successfully completed them. Also note, if less than the required enrollments exist for the user, it deletes them and reenrolls.
myVoiceIt.encapsulatedVideoEnrollUser(Activity, "USER_ID_HERE", "CONTENT_LANGUAGE_HERE", "my face and voice identify me", new JsonHttpResponseHandler() {...});
Verify user with the given userId(begins with 'usr_') and contentLanguage('en-US','es-ES' etc.). Note: Immediately upon calling this method it records the user saying their VoicePrint phrase for 5 seconds calling the recordingFinished callback first, then it sends the recording to be verified and returns the resulting confidence in the callback
myVoiceIt.voiceVerification("USER_ID_HERE", "CONTENT_LANGUAGE_HERE", new JsonHttpResponseHandler() {...});
Verify user with given userId(begins with 'usr_') and contentLanguage('en-US','es-ES' etc.). Note: Immediately upon calling this method it displays the camera and starts recording a video of the user saying their VoicePrint phrase for 5 seconds calling the recordingFinished callback first, then it sends the recording to be added as an enrollment and returns the result in the callback
myVoiceIt.videoVerification("USER_ID_HERE", "CONTENT_LANGUAGE_HERE", File video, new JsonHttpResponseHandler() {...});
Verify user with given userId(begins with 'usr_') and contentLanguage('en-US','es-ES' etc.). Note: Immediately upon calling this method it displays a view controller with a camera view that verifies the user and provides relevant callbacks for whether the verification was successful or not with associated voice and face confidences
myVoiceIt.encapsulatedVideoVerification(Activity, "USER_ID_HERE", "CONTENT_LANGUAGE_HERE", "my face and voice identify me", new JsonHttpResponseHandler() {...});
Identify user inside group with the given groupId(begins with 'grp_') and contentLanguage('en-US','es-ES' etc.). Note: Immediately upon calling this method it records the user saying their VoicePrint phrase for 5 seconds calling the recordingFinished callback first, then it sends the recording to be identified and returns the found userId and confidence in the callback
myVoiceIt.voiceIdentification("GROUP_ID_HERE", "CONTENT_LANGUAGE_HERE", new JsonHttpResponseHandler() {...});
Identify user inside group with the given groupId(begins with 'grp_') and contentLanguage('en-US','es-ES' etc.). Note: File recording need to be no less than 1.2 seconds and no more than 5 seconds
myVoiceIt.videoIdentification("GROUP_ID_HERE", "CONTENT_LANGUAGE_HERE", File video, new JsonHttpResponseHandler() {...});
Stephen Akers, stephen@voiceit.io
VoiceItApi2AndroidSDK is available under the MIT license. See the LICENSE file for more info.