Octopus - C Quick Start
Platforms
- Linux (x86_64)
- macOS (x86_64, arm64)
- Windows (x86_64)
Requirements
Picovoice Account & AccessKey
Signup or Login to Picovoice Console to get your AccessKey
.
Make sure to keep your AccessKey
secret.
Quick Start
Setup
- Clone the repository:
git clone --recurse-submodules https://github.com/Picovoice/octopus.git
Usage
- Include the public header files (
picovoice.h
andpv_octopus.h
). - Link the project to an appropriate precompiled library for the target platform and load it.
- 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_KEYmodel_file_path,&octopus);if (status != PV_STATUS_SUCCESS) {// error handling logic}
- 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}
- 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}
- 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
- Clone the Octopus repository from GitHub using HTTPS:
git clone --recurse-submodules https://github.com/Picovoice/octopus.git
- Build the demo:
cd octopuscmake -S demo/c/. -B demo/c/buildcmake --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.