Skip to main content
Skip table of contents

VSDK - Android

The Vivoka SDK is meant to greatly facilitate the creation of voice-enabled applications, regardless of who's providing the underlying technologies!

Installation

Simply import the .aar file into your project with Android Studio and add a gradle dependency to use it.

Forexample,for the vsdk-csdk library:

JAVA
implementation project(path: 'vsdk')
implementation project(path: ':vsdk-csdk')

Configuration

All VSDK engines are to be initialized with a JSON configuration file. This file contains a version, then each engine will declare its own configuration block:

JSON
{
    "version": "2.0",
    "csdk": {
        ...
    },
    ...
}

We strongly recommend you put this file under a config directory because most engines will generate additional configuration files or use a cache (configurable).

Library versions

You can access the version of VSDK like so:

JAVA
String vsdk_version = Vsdk.getVersion();

Error Handling

The SDK will throw exceptions on each function call. A custom exception class has been created to help track the origin of the error.

JAVA
try
{
    Vsdk.init(context, "configPath", callback);
}
catch (com.vivoka.vsdk.Exception e)
{
    // print the stacktrace (recommanded)
    e.printFormattedMessage();

    // get the stacktrace in a string
    String error = e.getFormattedMessage();

    // as com.vivoka.vsdk.Exception inherits from the java.lang.Exception class, you can also do this
    e.printStackTrace();
}

Audio Management

VSDK being a SDK around voice technologies, audio is a central component. Starting from version 4, audio pipelining has been added for greater power and simplicity.

Pipeline

An audio pipeline is composed of 3 types of audio modules: one Producer, zero or more Modifiers and zero or more Consumers. Simply put: a producer sends audio (either synchronously or asynchronously) into modifiers (if any), and the resulting audio is finally given to consumers (if any).

JAVA
// Create a pipeline
Pipeline pipeline = new Pipeline();

// Create an audio recorder which inherit from the ProducerModule
AudioRecorder audioRecorder = new AudioRecorder();
try
{
    pipeline.setProducer(audioRecorder);
}
catch (Exception e)
{
    e.printFormattedMessage();
}

// Create a recognizer which is inherited from the ConsumerModule
Recognizer recognizer;
try
{
    pipeline.pushBackConsumer(recognizer);
}
catch (Exception e)
{
    e.printFormattedMessage();
}

If you would like to create your own Audio Module, inherit from ProducerModule, ModifierModule or ConsumerModule.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.