cordova-plugin-voiceit-api-2
v1.0.4
Published
This plugin is a Cordova VoiceIt plugin that encapsulates VoiceIt's Face and Voice Verification API
Downloads
84
Maintainers
Readme
An Apache Cordova plugin that lets you easily integrate VoiceIt's Face and Voice Verification API into your Cordova Based iOS and Android apps.
For more information on VoiceIt API 2 and its features, see the website and documentation for expected JSON responses.
- Supported Platforms
- Getting Started
- Installation
- API Calls
- Initialization
- Get all Users
- Get Phrases
- Create User
- Check User Exists
- Get Groups for User
- Delete User
- Get all Groups
- Get Group
- Group Exists
- Create Group
- Add User to Group
- Remove User from Group
- Delete User
- Get all Voice Enrollments
- Get all Face Enrollments
- Get all Video Enrollments
- Delete Voice Enrollment
- Delete Face Enrollment
- Delete Video Enrollment
- Delete all Voice Enrollments
- Delete all Face Enrollments
- Delete all Video Enrollments
- Delete all Enrollments
- Encapsulated Voice Enroll User
- Encapsulated Face Enroll User
- Encapsulated Video Enroll User
- Encapsulated Voice Verification
- Encapsulated Face Verification
- Encapsulated Video Verification
- Encapsulated Voice Identification
- Encapsulated Face Identification
- Encapsulated Video Identification
Supported Platforms
- Android
- iOS
Getting Started
To use the VoiceIt Cordova Plugin in your Cordova Project, if you haven't already, please Sign Up for a free Developer Id at voiceit.io/signup. Then in the settings page, you should now be able view the API Key and Token (as shown below).
Installation
First please cd into your Cordova App's root directory via the terminal/command line and then run the following command (feel free to change the microphone and camera usage description below before running the command):
$ cordova plugin add cordova-plugin-voiceit-api-2 --variable MICROPHONE_USAGE_DESCRIPTION="This app needs to access to your microphone for voice biometrics" --variable CAMERA_USAGE_DESCRIPTION="This app needs to access to your camera for face biometrics"
API Calls
Here are code snippets that show you how you can call the Various VoiceIt API 2 API calls inside of your Cordova Project JavaScript Files.
Initialization
Initialize a variable as the reference to VoiceIt API 2, passing in the API Key and Token from the settings page, and optionally a hexadecimal theme color to match your app.
var myVoiceIt = new VoiceItAPITwo({ apiKey : 'API_KEY_HERE', apiToken: 'API_TOKEN_HERE', themeColor: '#FBC132'});
Get all Users
To get all users for the apiKey call the getAllUsers function like this with no parameters:
myVoiceIt.getAllUsers(function(jsonResponse) {
console.log("All users for developer :");
jsonResponse.users.forEach(function(user){
console.log(user.userId + ',');
});
});
Get Phrases
To get phrases for the apiKey call getPhrases, padding the contentLanguage
myVoiceIt.getPhrases({
contentLanguage: "CONTENT_LANGUAGE_HERE"
},function(jsonResponse) {
console.log("All phrases for developer :");
jsonResponse.phrases.forEach(function(phrase){
console.log(phrase.text + ',');
});
});
Create User
To create a new user call the createUser function like this with no parameters:
myVoiceIt.createUser(function(jsonResponse) {
console.log("User created with userId : " + jsonResponse.userId);
});
Check User Exists
To check if a user exists call checkUserExists, passing the userId:
myVoiceIt.checkUserExists({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log("User exists : " + jsonResponse.exists);
});
Get Groups for User
To get groups that the user belongs to call getGroupsForUser, passing the userId:
myVoiceIt.getGroupsForUser({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log("Groups for user :");
jsonResponse.groups.forEach(function(groupId){
console.log(groupId + ',');
});
});
Delete User
To delete a user call deleteUser, passing the userId:
myVoiceIt.deleteUser({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Get all Groups
To get all groups for the apiKey call the getAllGroups function like this with no parameters:
myVoiceIt.getAllGroups(function(jsonResponse) {
console.log("All groups for developer :");
jsonResponse.groups.forEach(function(group){
console.log(group.groupId + ',');
});
});
Get Group
To get a group's details call getGroup, passing the groupId:
myVoiceIt.getGroup({
groupId: "GROUP_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Group Exists
To check if a group exists call groupExists, passing the groupId:
myVoiceIt.groupExists({
groupId: "GROUP_ID_HERE"
}, function(jsonResponse) {
console.log("Group exists : ",jsonResponse.exist);
});
Create Group
To create a new group call the createGroup function like this with no parameters:
myVoiceIt.createGroup(function(jsonResponse) {
console.log("Group created with groupId : " + jsonResponse.groupId);
});
Add User to Group
To add a user to a group call the addUserToGroup function, passing the groupId and userId:
myVoiceIt.addUserToGroup({
userId:"USER_ID_HERE", groupId: "GROUP_ID_HERE"
}, function(jsonResponse) {
console.log("User added to group: " + jsonResponse);
});
Remove User from Group
To remove a user from a group call the removeUserFromGroup function, passing the groupId and userId:
myVoiceIt.removeUserFromGroup({
userId:"USER_ID_HERE", groupId: "GROUP_ID_HERE"
}, function(jsonResponse) {
console.log("User removed from group: " + jsonResponse);
});
Delete Group
To delete a group call deleteGroup, passing the groupId:
myVoiceIt.deleteGroup({
groupId: "GROUP_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Get all Voice Enrollments
To get all voice enrollments for a user call getAllVoiceEnrollments, passing the userId:
myVoiceIt.getAllVoiceEnrollments({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log("All voice enrollments for user :");
jsonResponse.voiceEnrollments.forEach(function(enrollment){
console.log(enrollment.voiceEnrollmentId + ',');
});
});
Get all Face Enrollments
To get all face enrollments for a user call getAllFaceEnrollments, passing the userId:
myVoiceIt.getAllFaceEnrollments({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log("All face enrollments for user :");
jsonResponse.faceEnrollments.forEach(function(enrollment){
console.log(enrollment.faceEnrollmentId + ',');
});
});
Get all Video Enrollments
To get all video enrollments for a user call getAllVideoEnrollments, passing the userId:
myVoiceIt.getAllVideoEnrollments({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log("All video enrollments for user :");
jsonResponse.videoEnrollments.forEach(function(enrollment){
console.log(enrollment.videoEnrollmentId + ',');
});
});
Delete Voice Enrollment
To delete a voice enrollment call deleteVoiceEnrollment, passing the userId and voiceEnrollmentId parameters:
myVoiceIt.deleteEnrollment({
userId: "USER_ID_HERE",
voiceEnrollmentId:"VOICE_ENROLLMENT_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Delete Face Enrollment
To delete a face enrollment call deleteFaceEnrollment, passing the userId and faceEnrollmentId parameters:
myVoiceIt.deleteFaceEnrollment({
userId: "USER_ID_HERE",
faceEnrollmentId:"FACE_ENROLLMENT_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Delete Video Enrollment
To delete a video enrollment call deleteVideoEnrollment, passing the userId and videoEnrollmentId parameters:
myVoiceIt.deleteVideoEnrollment({
userId: "USER_ID_HERE",
videoEnrollmentId:"VIDEO_ENROLLMENT_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Delete All Voice Enrollments
To delete all voice enrollments call deleteAllVoiceEnrollments, passing the userId:
myVoiceIt.deleteAllVoiceEnrollments({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Delete All Face Enrollments
To delete all face enrollments call deleteAllFaceEnrollments, passing the userId:
myVoiceIt.deleteAllFaceEnrollments({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Delete All Face Enrollments
To delete all video enrollments call deleteAllVideoEnrollments, passing the userId:
myVoiceIt.deleteAllVideoEnrollments({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Delete All Enrollments
To delete all voice,face and video enrollments for a user call deleteAllEnrollments, passing the userId:
myVoiceIt.deleteAllEnrollments({
userId: "USER_ID_HERE"
}, function(jsonResponse) {
console.log(jsonResponse);
});
Encapsulated Voice Enroll User
To enroll a user's voice, call the encapsulatedVoiceEnrollUser function, passing the userId, contentLanguage, and phrase ( make sure you use an approved phrase for your developer account at https://voiceit.io/phraseManagement) parameters. This method includes the UI and walks the user through three successful voice enrollments before returning.
myVoiceIt.encapsulatedVoiceEnrollUser({
userId: "USER_ID_HERE",
contentLanguage:"en-US",
phrase:"my face and voice identify me"
}, function() {
console.log("User cancelled enrollments");
}, function() {
console.log("User successfully completed enrolling");
});
Encapsulated Face Enroll User
To enroll a user's face, call the encapsulatedFaceEnrollUser function passing the userId to enroll. This method includes the UI and walks the user through a successful face enrollment before returning;
myVoiceIt.encapsulatedFaceEnrollUser({
userId: "USER_ID_HERE"
}, function() {
console.log("User cancelled face enrollment");
}, function() {
console.log("User successfully completed enrolling");
});
Encapsulated Video Enroll User
To enroll a user's face and voice, call the encapsulatedVideoEnrollUser function, passing the userId, contentLanguage, and phrase ( make sure you use an approved phrase for your developer account at https://voiceit.io/phraseManagement) parameters. This method includes the UI and walks the user through three successful enrollments before returning.
myVoiceIt.encapsulatedVideoEnrollUser({
userId: "USER_ID_HERE",
contentLanguage:"en-US",
phrase:"my face and voice identify me"
}, function() {
console.log("User cancelled enrollments");
}, function() {
console.log("User successfully completed enrolling");
});
Encapsulated Voice Verification
To verify a user's voice, call the encapsulatedVoiceVerification function, passing the userId, contentLanguage, and phrase (make sure you use an approved phrase for your developer account at https://voiceit.io/phraseManagement) parameters. This method includes the UI for voice verification and returns the voice confidence.
myVoiceIt.encapsulatedVoiceVerification({
userId: "USER_ID_HERE",
contentLanguage:"en-US",
phrase:"my face and voice identify me"
}, function() {
console.log("User cancelled verifications");
}, function(jsonResponse) {
console.log("User successfully completed verification with voiceConfidence : " + jsonResponse.voiceConfidence);
});
Encapsulated Face Verification
To verify a user's face call the encapsulatedFaceVerification function, passing the userId and doLivenessDetection parameters. doLivenessDetection is a boolean that makes the user attempt liveness challenges, such as smiling, blinking, moving their face left/right for enhanced security. This method includes the UI for face verification and returns the face confidence.
myVoiceIt.encapsulatedFaceVerification({
userId: "USER_ID_HERE",
doLivenessDetection: true
}, function() {
console.log("User cancelled verifications");
}, function(jsonResponse) {
console.log("User successfully completed verification with faceConfidence : " + jsonResponse.faceConfidence);
});
Encapsulated Video Verification
To verify a user's face and voice, call the encapsulatedVideoVerification function, passing the userId, contentLanguage, phrase( make sure you use an approved phrase for your developer account at https://voiceit.io/phraseManagement) and doLivenessDetection parameters. doLivenessDetection is a boolean that makes the user attempt liveness challenges, such as smiling, blinking, moving their face left/right for enhanced security. This method includes the UI for face and voice verification and returns the face and voice confidence.
myVoiceIt.encapsulatedVideoVerification({
userId: "USER_ID_HERE",
contentLanguage:"en-US",
phrase:"my face and voice identify me",
doLivenessDetection: true
}, function() {
console.log("User cancelled verifications");
}, function(jsonResponse) {
console.log("User successfully completed verification with faceConfidence : " + jsonResponse.faceConfidence + " and voiceConfidence : " + jsonResponse.voiceConfidence);
});
Encapsulated Voice Identification
To identify a user's voice, call the encapsulatedVoiceIdentification function, passing the groupId, contentLanguage, and phrase (make sure you use an approved phrase for your developer account at https://voiceit.io/phraseManagement) parameters. This method includes the UI for voice identification and returns the voice confidence.
myVoiceIt.encapsulatedVoiceIdentification({
groupId: "GROUP_ID_HERE",
contentLanguage:"en-US",
phrase:"my face and voice identify me"
}, function() {
console.log("User cancelled identification");
}, function(jsonResponse) {
console.log("User successfully completed identification with voiceConfidence : " + jsonResponse.voiceConfidence);
});
Encapsulated Face Identification
To identify a user's face call the encapsulatedFaceIdentification function, passing the groupId and doLivenessDetection parameters. doLivenessDetection is a boolean that makes the user attempt liveness challenges, such as smiling, blinking, moving their face left/right for enhanced security. This method includes the UI for face identification and returns the face confidence.
myVoiceIt.encapsulatedFaceIdentification({
groupId: "GROUP_ID_HERE",
doLivenessDetection: true
}, function() {
console.log("User cancelled identification");
}, function(jsonResponse) {
console.log("User successfully completed identification with faceConfidence : " + jsonResponse.faceConfidence);
});
Encapsulated Video Identification
To identify a user's face and voice out of a group, call the encapsulatedVideoIdentification function, passing the groupId, contentLanguage, phrase( make sure you use an approved phrase for your developer account at https://voiceit.io/phraseManagement) and doLivenessDetection parameters. doLivenessDetection is a boolean that makes the user attempt liveness challenges, such as smiling, blinking, moving their face left/right for enhanced security. This method includes the UI for face and voice identification and returns the face and voice confidence.
myVoiceIt.encapsulatedVideoIdentification({
groupId: "USER_ID_HERE",
contentLanguage:"en-US",
phrase:"my face and voice identify me",
doLivenessDetection: true
}, function() {
console.log("User cancelled identification");
}, function(jsonResponse) {
console.log("User " + jsonResponse.userId + " was successfully identified with faceConfidence : " + jsonResponse.faceConfidence + " and voiceConfidence : " + jsonResponse.voiceConfidence);
});
Authors
Cordova
armaanbindra, [email protected]
iOS
armaanbindra, [email protected]
Android
stephenakers, [email protected]
License
Cordova Plugin VoiceIt API 2 is available under the GNU GENERAL PUBLIC LICENSE. See the LICENSE file for more info.