cOctopus - C Quick Start

Platforms

  • Linux (x86_64)
  • macOS (x86_64, arm64)
  • Windows (x86_64)

Requirements

  • C99-compatible compiler
  • CMake (3.13+)
  • For Windows Only: MinGW is required to build the demo

Picovoice Account & AccessKey

Signup or Login to Picovoice Console to get your AccessKey. Make sure to keep your AccessKey secret.

Quick Start

Setup

  1. Clone the repository:
git clone --recurse-submodules https://github.com/Picovoice/octopus.git

Usage

  1. Include the public header files (picovoice.h and pv_octopus.h).
  2. Link the project to an appropriate precompiled library for the target platform and load it.
  3. Construct the Octopus object:
static const char* ACCESS_KEY = "${ACCESS_KEY}";
const char *model_file_path = "${MODEL_FILE_PATH}";
pv_octopus_t *octopus;
const pv_status_t status = pv_octopus_init(
ACCESS_KEY
model_file_path,
&octopus);
if (status != PV_STATUS_SUCCESS) {
// error handling logic
}
  1. Pass in an audio path to the pv_octopus_index_file function:
static const char* audio_path = "${AUDIO_FILE_PATH}";
void *indices = NULL;
int32_t num_indices_byte = 0;
const pv_status_t status = pv_octopus_index_file(
octopus,
&indices,
&num_indices_byte);
if (status != PV_STATUS_SUCCESS) {
// error handling logic
}
  1. Search for a phrase using pv_octopus_search function:
pv_octopus_match_t *matches = NULL;
int32_t num_matches = 0;
const pv_status_t status = pv_octopus_search(
octopus,
indices,
num_indices_byte,
phrase,
&matches,
&num_matches);
if (status != PV_STATUS_SUCCESS) {
// error handling logic
}
  1. Release resources explicitly when done with Octopus:
free(indices)
free(matches)
pv_octopus_delete(octopus);

Demo

For the Octopus SDK, we offer demo applications that demonstrate how to use the Speech-to-Index engine on audio recordings.

Setup

  1. Clone the Octopus repository from GitHub using HTTPS:
git clone --recurse-submodules https://github.com/Picovoice/octopus.git
  1. Build the demo:
cd octopus
cmake -S demo/c/. -B demo/c/build
cmake --build demo/c/build --target octopus_demo

Usage

Index a given audio file and save the metadata:

./demo/c/build/octopus_index_demo \
lib/${PLATFORM}/${ARCH}/libpv_octopus.so \
lib/common/octopus_params.pv \
${ACCESS_KEY} \
${AUDIO_PATH} \
${INDEX_PATH}

Run the search demo with the index metadata saved from above:

./demo/c/build/octopus_index_demo \
lib/${PLATFORM}/${ARCH}/libpv_octopus.so \
lib/common/octopus_params.pv \
${ACCESS_KEY} \
${INDEX_PATH} \
${PHRASE}

For more information on our Octopus demos for C, head over to our GitHub repository.

Resources

API

GitHub

Benchmark

Further Reading


Issue with this doc? Please let us know.