Voice Biometrics - Android
Introduction
Voice biometrics is a technology that uses the unique characteristics of a person’s voice to identify or authenticate them.
Use cases
Authentication: Verifies if the speaker matches a specific enrolled identity.
Identification: Determines which enrolled user is speaking.
Providers
Feature | TSSV | IDVoice |
|---|---|---|
Accuracy & Performance | Faster, but less accurate | Slower, but more accurate |
Result Behavior | Returns results only if confidence ≥ threshold | Returns all results, regardless of confidence |
Language Dependency | Language-agnostic | Language-agnostic |
Enrollment Flow | Identical for both providers | Identical for both providers |
Supported Modes | Text-dependent and text-independent | Text-dependent and text-independent |
Audio Format
The input audio data for enrollment and recognition is a 16-bit signed PCM buffer in Little-Endian format. It is always mono (1 channel), and the sample rate 16KHz.
Getting Started
Before you begin, make sure you’ve completed all the necessary preparation steps.
There are two ways to prepare your Android project for Voice Biometrics:
Using sample code
Starting from scratch
From Sample Code
Start by downloading the sample package from the Vivoka Console:
Open the Vivoka Console and navigate to your Project Settings.
Go to the Downloads section.
In the search bar enter package name from table.
📦 sample-voice-biometrics-x.x.x-tssv-android-deps-vsdk-x.x.x.zip or
📦 sample-voice-biometrics-x.x.x-idvoice-tssv-android-deps-vsdk-x.x.x.zip or
📦 sample-voice-biometrics-x.x.x-idvoice-android-deps-vsdk-x.x.x.zip
Once downloaded, you’ll have a fully functional project that you can test, customize, and extend to fit your specific use case.
From Scratch
Before proceeding, make sure you’ve completed the following steps:
1. Prepare your VDK Studio project
Create a new project in VDK Studio
Add the Voice Recognition technology
Export the project to generate the required assets and configuration
2. Set up your Android project
Install the necessary libraries (
vsdk-tssv-x.x.x-android-deps-vsdk-x.x.x.ziporvsdk-idvoice-x.x.x-android-deps-vsdk-x.x.x.zip)Initialize VSDK in your application code
These steps are better explained in the Android Get Started guide.
Start Recognition
1. Initialize Engine
Start by initializing the VSDK, followed by the Voice Recognition engine:
SDK: vsdk-tssv
import com.vivoka.vsdk.Vsdk;
Vsdk.init(context, "config/vsdk.json", vsdkSuccess -> {
if (vsdkSuccess) {
com.vivoka.vsdk.biometrics.tssv.Engine.getInstance().init(engineSuccess -> {
if (engineSuccess) {
// At this point the engine has been initialized.
}
});
}
});
SDK: vsdk-idvoice
import com.vivoka.vsdk.Vsdk;
Vsdk.init(context, "config/vsdk.json", vsdkSuccess -> {
if (vsdkSuccess) {
com.vivoka.vsdk.biometrics.idvoice.Engine.getInstance().init(engineSuccess -> {
if (engineSuccess) {
// At this point the engine has been initialized.
}
});
}
});
Different SDKs will give you different results, for example vsdk-idvoice reports varying results as it analyzes the audio, while vsdk-tssv only sends you result if the engine thinks it is acceptable (depending of the confidence level you set).
We recommend that you try it out the application in real situation to select your custom minimum score required to satisfy your need in false rejection and false acceptation. But by default you can just check if the score is above 0.
You cannot create two instances of the same engine.
If you call Engine.getInstance() multiple times, you will receive the same singleton instance.
2. Enroll users
Model model = Engine.getInstance().getModel("model-1", ModelType.TEXT_INDEPENDANT);
Model model = Engine.getInstance().getModel("model-1", ModelType.TEXT_DEPENDANT);
Models contain enrollment data that recognition operations need.
If a model was previously created with the same name it will be loaded. You can check enrolled users with:
if (model.getUsers().size() == 0) {
// No enrolled users.
}
Adding a user to the model
// model.addRecord(String name, Buffer buffer);
model.addRecord("victorien", buffer);
The more data you give the model, the better the result will be.
Prefer to register the data in the condition of the use case of the model.
The format is preferred to be 16Khz mono-channel.
3. Identify
import com.vivoka.vsdk.biometrics.Identificator;
Identificator identificator = Engine.getInstance().getIdentificator("ident", model,
(resultType, resultStatus, result, isFinal) -> {
Log.e("IdentificatorResult", result.toString());
final String name = result.optString("name");
final double probability = result.optDouble("probability");
final double score = result.optDouble("score");
}
});
4. Authenticate
import com.vivoka.vsdk.biometrics.Authenticator;
Authenticator authenticator = Engine.getInstance().getAuthenticator("ident", model,
(resultType, resultStatus, result, isFinal) -> {
Log.e("AuthenticatorResult", result.toString());
final String name = result.optString("name");
final double probability = result.optDouble("probability");
final double score = result.optDouble("score");
}
});
authenticator.setUserToRecognize("victorien");
5. Release Engine
Engine.getInstance().release();