A fully comprehensive SDK that gives you access to VoiceIt's API 2.0 featuring Voice + Face Verification and Identification right in your Android app.
- Getting Started
- Requirements
- Installation
- Local Installation
- API Calls
- Theme
The following show Voice Verification, Face Verification (With liveness detection on) and Video Verification (with Liveness turned off), respectively.
Contact us at [email protected] to get started with an account to use API 2.0.
The minumum Android SDK version (API level) should be set to 17 in your build.gradle file:
minSdkVersion: 17
Contact us at [email protected] to get started with an account to use API 2.0.
Make sure you review your Voiceprint Phrases by navigating to Dashboard in order to know what to pass for voicePrintPhrase parameter.
Make sure your project has the useAndroidX and enableJetifier flags as true: Navigate to the gradle.properties of your project and add the following:
android.useAndroidX=true
android.enableJetifier=true
VoiceItApi2AndroidSDK is available through JitPack.
- Clone the repo
- Open your android project in android studio, and navigate to File -> New -> Import Module
- Select the Android SDK repo that you just cloned. Check off the app module, only include the voiceit2 module
First import VoiceItAPI2 and then initialize a reference to the SDK inside an Activity, passing in your API Credentials or user token.
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 {
private VoiceItAPI2 myVoiceIt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// If using user tokens, replace API_KEY below with the user token,
// and leave the second argument as an empty string
myVoiceIt = new VoiceItAPI2("API_KEY","API_TOK");
}
}
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 with ellipses 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());
}
}
});
For our Encapsulated Face and Video Verification methods, liveness detection can be enabled by parameter. This enables a pre-check(prompting to the user to turn their head or smile) before the verification API call to decrease the chance a user is able to spoof with a photo of someone else. This helps to mitigate replay attacks.
Encapsulated Methods take care of all the logic of enrollment/verification and the UI in new Android Activities. Immediately upon calling a method it displays a enrollment/verification view controller that enrolls/verifies the user and provides relevant callbacks for whether the API calls were successful or not with associated biometric confidence. Note: If less than the required enrollments exist for a user, enrollment methods delete them and re-enroll.
Create three voice enrollments user with given userId(begins with 'usr_'), contentLanguage('en-US','es-ES' etc.), and a given phrase such as "Never forget tomorrow is a new day".
myVoiceIt.encapsulatedVoiceEnrollment(Activity, "USER_ID_HERE", "CONTENT_LANGUAGE_HERE", "PHRASE_HERE", new JsonHttpResponseHandler() {...});
Verify user with given userId(begins with 'usr_'), contentLanguage('en-US','es-ES' etc.), and a given phrase such as "Never forget tomorrow is a new day".
myVoiceIt.encapsulatedVoiceVerification(Activity, "USER_ID_HERE", "CONTENT_LANGUAGE_HERE", "PHRASE_HERE", new JsonHttpResponseHandler() {...});
Identify user from given groupId(begins with 'grp_'), contentLanguage('en-US','es-ES' etc.), and a given phrase such as "Never forget tomorrow is a new day".
myVoiceIt.encapsulatedVoiceIdentification(Activity, "GROUP_ID_HERE", "CONTENT_LANGUAGE_HERE", "PHRASE_HERE", new JsonHttpResponseHandler() {...});
Create three face enrollments for user with given userId(begins with 'usr_').
myVoiceIt.encapsulatedFaceEnrollment(Activity, "USER_ID_HERE", new JsonHttpResponseHandler() {...});
Verify user with given userId(begins with 'usr_'), and a boolean to enable liveness detection.
myVoiceIt.encapsulatedFaceVerification(Activity, "USER_ID_HERE", true, new JsonHttpResponseHandler() {...});
with optional boolean to disable or enable liveness tutorial:
myVoiceIt.encapsulatedFaceVerification(Activity, "USER_ID_HERE", true, true, new JsonHttpResponseHandler() {...});
Identify user from given groupId(begins with 'grp_'), and a boolean to enable liveness detection.
myVoiceIt.encapsulatedFaceIdentification(Activity, "GROUP_ID_HERE", true, 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".
myVoiceIt.encapsulatedVideoEnrollment(Activity, "USER_ID_HERE", "CONTENT_LANGUAGE_HERE", "PHRASE_HERE", new JsonHttpResponseHandler() {...});
Verify user with given userId(begins with 'usr_'), contentLanguage('en-US','es-ES' etc.), a given phrase such as "my face and voice identify me", and a boolean to enable liveness detection.
myVoiceIt.encapsulatedVideoVerification(Activity, "USER_ID_HERE", "CONTENT_LANGUAGE_HERE", "PHRASE_HERE", true, new JsonHttpResponseHandler() {...});
With optional boolean to enable or disable liveness tutorial:
myVoiceIt.encapsulatedVideoVerification(Activity, "USER_ID_HERE", "CONTENT_LANGUAGE_HERE", "PHRASE_HERE", true, true, new JsonHttpResponseHandler() {...});
Identify user from given groupId(begins with 'grp_'), contentLanguage('en-US','es-ES' etc.), a given phrase such as "my face and voice identify me", and a boolean to enable liveness detection.
myVoiceIt.encapsulatedVideoIdentification(Activity, "GROUP_ID_HERE", "CONTENT_LANGUAGE_HERE", "PHRASE_HERE", true, new JsonHttpResponseHandler() {...});
To set the theme, please initialize the voiceit Module with the Color integer as the third argument:
myVoiceIt = new VoiceItAPI2("API_KEY","API_TOK", Color.parseColor("HEX_COLOR_VALUE_HERE"));
Please make sure that the color is a valid Hex value. The parseColor method throws an IllegalArgumentException so it is recommended to wrap the initialize method in try-catch blocks
Please refer to https://api.voiceit.io/?java# for information about all API calls
Remember to add "new JsonHttpResponseHandler() {...}" as the last argument
For example, you can check whether a user exists for the given userId(begins with 'usr_')
myVoiceIt.checkUserExists("USER_ID_HERE", new JsonHttpResponseHandler() {...});
All strings and prompts utilized in the encapsulated views can be overwitten by adding strings with the same names as found in:
/voiceit2/src/main/res/values/strings.xml
to the strings.xml file in your app.
VoiceIt Technologies, [email protected]
VoiceItApi2AndroidSDK is available under the MIT license. See the LICENSE file for more info.