cLeopard - C Quick Start

Platforms

  • Linux (x86_64)
  • macOS (x86_64, arm64)
  • Windows (x86_64)
  • NVIDIA Jetson Nano
  • Raspberry Pi (3, 4)

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/leopard.git

Usage

  1. Include the public header files (picovoice.h and pv_leopard.h).
  2. Link the project to an appropriate precompiled library for the target platform and load it.
  3. Download a custom model from Picovoice Console or the default model.
  4. Construct the Leopard object:
static const char* ACCESS_KEY = "${ACCESS_KEY}";
const char *model_file_path = "${MODEL_FILE_PATH}";
pv_leopard_t *leopard;
const pv_status_t status = pv_leopard_init(
ACCESS_KEY
model_file_path,
&leopard);
if (status != PV_STATUS_SUCCESS) {
// error handling logic
}
  1. Pass in an audio path to the pv_leopard_process_file function:
static const char* audio_path = "${AUDIO_FILE_PATH}";
char *transcript = NULL;
const pv_status_t status = pv_leopard_process_file(leopard, audio_path, &transcript);
if (status != PV_STATUS_SUCCESS) {
// error handling logic
}
fprintf(stdout, "%s\n", transcript);
free(transcript); // make sure to free transcript result
  1. Release resources explicitly when done with Leopard:
pv_leopard_delete(leopard);

Demo

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

Setup

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

Usage

To see the usage options for the demo:

./demo/c/build/leopard_demo

Run the command corresponding to your platform from the root of the repository:

./demo/c/build/leopard_demo \
-l lib/${PLATFORM}/${ARCH}/libpv_leopard.so \
-m lib/common/leopard_params.pv \
-a ${ACCESS_KEY} \
${AUDIO_PATH1} ${AUDIO_PATH2} ...

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

Resources

API

GitHub

Benchmark


Issue with this doc? Please let us know.