Natural Language Understanding - Android
Introduction
VSDK includes built-in support for Natural Language Understanding (NLU) through the VNLU engine, developed by Vivoka. Integrated under the module name vsdk-vnlu, it is designed to work alongside an ASR engine to extract meaning and structure from spoken commands.
With VNLU, your application can go beyond recognizing words—it can understand intents (what the user wants to do) and entities (the relevant pieces of information within a sentence). This makes it ideal for building natural and conversational voice interfaces.
Example: Smart Home
User says: "Turn on the kitchen lights"
Extracted Intent:TurnOnDevice
Extracted Entities:
device: "lights"location: "kitchen"
Training model
NLU is domain-specific module, meaning it’s trained on the vocabulary and sentence structures relevant to your use case. We have a guide that could help you build you dataset and train your model.
Languages
🇫🇷
fra-FR– French (France)🇺🇸
eng-US– English (United States)🇮🇹
ita-IT– Italian (Italy)🇪🇸
spa-SP– Spanish (Spain)🇩🇪
deu-DE– German (Germany)
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 integration of NLU:
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-commands-language-understanding-X.X.X-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-vnlu-X.X.X-android-deps-vsdk-X.X.X.zip)Initialize VSDK in your application code
These steps are better explained in the Integrating Vsdk Libraries guide.
Start Parsing Text
1. Initialize Engine
Start by initializing the VSDK, followed by the NLU engine:
import com.vivoka.vsdk.Vsdk;
Vsdk.init(context, "config/vsdk.json", vsdkSuccess -> {
if (vsdkSuccess) {
com.vivoka.vsdk.nlu.vnlu.Engine.getInstance().init(engineSuccess -> {
if (!engineSuccess) {
return;
}
// The NLU engine is now ready
});
}
});
You cannot create two instances of the same engine.
If you call Engine.getInstance() multiple times, you will receive the same singleton instance.
2. Create Parser
import com.vivoka.vsdk.nlu.vnlu.result.Result;
import com.vivoka.vsdk.nlu.vnlu.result.Intent;
import com.vivoka.vsdk.nlu.vnlu.result.Entity;
import com.vivoka.vsdk.nlu.vnlu.IParserListener;
parser = com.vivoka.vsdk.nlu.vnlu.Engine.getInstance().getParser("model-name", new IParserListener() {
@Override
public void onResult(String res) {
Log.e(TAG, "Res: " + res);
Result nluResult = new Result(res);
Intent intent = nluResult.getIntent();
ArrayList<Entity> entities = nluResult.getEntities();
Log.i(TAG, String.format("Found res with lang '%s' for orig sentence '%s'", nluResult.getLang(), nluResult.getOriginalSentence()));
Log.i(TAG, String.format("Found intent '%s' with confidence '%f'", intent.getName(), intent.getConfiddence()));
for (Entity entity : entities) {
Log.i(TAG, String.format("Found entity '%s' with value '%s'", entity.getName(), entity.getValue()));
}
}
@Override
public void onError(String error) {
Log.i(TAG, "ERROR: " + error);
}
});
3. Parse Text
parser.process("Turn on the kitchen lights");
4. Release the Engine
com.vivoka.vsdk.nlu.vnlu.Engine.getInstance().release();