Skip to main content
Skip table of contents

VSDK - C++

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

Installation

Upon getting your access through your sales representative, the SDK is installable through Conan, the C++ package manager. Please refer to the accompanying the page How-to: Download, Compile & Run C++ Samples for dedicated setup instructions. In case Conan is already configured but you don't want to go through installing a sample, you can directly install libraries like so:

CPP
# List the packages you have access to
conan search -r vivoka-customer 'vsdk-*/*@vivoka/customer'
# Install a specific version
conan install <package_reference>

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",
    "vasr": {
        ...
    },
    ...
}

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 versions of both VSDK and the engine like so:

CPP
#include <vsdk/global.hpp>

// Engine creation is explained later
fmt::print("VSDK v{} ; Engine v{}\n", Vsdk::version(), engine->version());

Error Handling

The SDK will throw exceptions as a way to report errors and avoid having to check every single function call. An exception stack is made to help track the origin of the error, so the following base program is recommended to print the whole stack of errors:

CPP
#include <vsdk/Exception.hpp>

int main() try
{
    // use VSDK here
    return EXIT_SUCCESS;
}
catch (std::exception const & e)
{
    fmt::print(stderr, "A fatal error occured:\n");
    Vsdk::printExceptionStack(e);
    return EXIT_FAILURE;
}

Please note that some part of the SDK might run on another thread of execution, and exceptions can't cross thread boundaries. You have to protect your threads from exceptions by either catching them inside or sending tasks to the main thread.

The libvteffect.so is not available yet for arm architecture and therofore you can have the following warning: [WARN] Failed to load the following module: [libvteffect] (10000)

Audio Management

VSDK being a SDK around voice technologies, audio is a central component. Starting from version 6, 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).

CPP
#include <vsdk/audio/Pipeline.hpp>
#include <vsdk/audio/producers/File.hpp>
#include <vsdk/audio/consumers/File.hpp>

using namespace Vsdk::Audio;

void copyAudioFile(std::string const & inPath, std::string const & outPath)
{
    Pipeline p;
    
    // Here we construct the modules directly into the pipeline but you can do so outside!
    p.setProducer<Producer::File>(inPath);
    p.pushBackConsumer<Consumer::File>(outPath);
    p.run(); // blocking call
    
    // Asynchronous execution would rather call p.start() and p.stop() instead
    // but not all ProducerModule support it!
}
JavaScript errors detected

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

If this problem persists, please contact our support.