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.
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:
{
"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).
This file can get quite complex but is generated for you by the VDK Studio during the project export phase.
Library versions
You can access the versions of both VSDK and the engine like so:
#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:
#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.
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).
#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!
}