Picovoice WordmarkPicovoice Console
Introduction
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonWebWindows
AndroidCiOSPythonWeb
SummaryOctopus Speech-to-IndexGoogle Speech-to-TextMozilla DeepSpeech
FAQ
Introduction
AndroidAngularArduinoBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaMicrocontrollerNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidAngularBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonlinuxmacOSNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidBeagleboneCiOSNvidia JetsonLinuxmacOSPythonRaspberry PiRustWebWindows
AndroidCiOSPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidCiOSPythonWeb
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidAngularArduinoBeagleBoneC.NETFlutterlink to GoiOSJavaNvidia JetsonMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustUnityVueWeb
AndroidAngularCMicrocontroller.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
Picovoice SDK - FAQ
IntroductionSTM32F407G-DISC1 (Arm Cortex-M4)STM32F411E-DISCO (Arm Cortex-M4)STM32F769I-DISCO (Arm Cortex-M7)IMXRT1050-EVKB (Arm Cortex-M7)
FAQGlossary

Picovoice Platform — C API


API Reference for the Picovoice C SDK .


pv_picovoice_t

typedef struct pv_picovoice pv_picovoice_t;

Container representing the Picovoice platform.


pv_inference_t

typedef struct {
bool is_understood;
const char *intent;
int32_t num_slots;
const char **slots;
const char **values;
} pv_inference_t;

Container representing inferred user intent. pv_inference_t exposes the following immutable fields:

  1. is_understood is a flag indicating if the spoken command is understood.
  2. intent is the inferred intent from the voice command. If the command is not understood then it's set to NULL.
  3. num_slots is the number of slots.
  4. slots is a list of slot keys.
  5. values is the corresponding slot values.

pv_inference_delete()

void pv_inference_delete(pv_inference_t *inference);

Destructor for pv_inference_t. Should be called after completion of intent inference.

Parameters

  • inference pv_inference_t * : Inference container.

pv_picovoice_init()

pv_status_t pv_picovoice_init(
const char *access_key,
const char *porcupine_model_path,
const char *keyword_path,
float porcupine_sensitivity,
void (*wake_word_callback)(void),
const char *rhino_model_path,
const char *context_path,
float rhino_sensitivity,
float endpoint_duration_sec,
bool require_endpoint,
void (*inference_callback)(pv_inference_t *),
pv_picovoice_t **object);

Creates a Picovoice instance. Resources should be cleaned when you are done using the pv_picovoice_delete() function.

Parameters

  • access_key char * : AccessKey obtained from Picovoice Console .
  • porcupine_model_path char * : Absolute path to the file containing Porcupine model parameters (.pv).
  • keyword_path char * : Absolute path to Porcupine's keyword model file (.ppn).
  • porcupine_sensitivity float : Wake word detection sensitivity. It should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.
  • wake_word_callback void (*)(void) : User-defined callback invoked upon detection of the wake phrase. The callback accepts no input arguments.
  • rhino_model_path char * : Absolute path to the file containing Rhino model parameters (.pv).
  • context_path char * : Absolute path to file containing context parameters (.rhn). A context represents the set of expressions (spoken commands), intents, and intent arguments (slots) within a domain of interest.
  • rhino_sensitivity float : Inference sensitivity. It should be a number within [0, 1]. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate.
  • endpoint_duration_sec float : Endpoint duration in seconds. An endpoint is a chunk of silence at the end of an utterance that marks the end of spoken command. It should be a positive number within [0.5, 5]. A lower endpoint duration reduces delay and improves responsiveness. A higher endpoint duration assures Rhino doesn't return inference pre-emptively in case the user pauses before finishing the request.
  • require_endpoint bool : If set to true, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set to false, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set to false only if operating in an environment with overlapping speech (e.g. people talking in the background).
  • inference_callback void (*)(pv_inference_t *) : User-defined callback invoked upon completion of intent inference. The callback accepts a single input argument of type pv_inference_t.
  • object pv_picovoice_t * * : Constructed instance of Picovoice.

Returns

  • pv_status_t : Returned status code.

pv_picovoice_delete()

void pv_picovoice_delete(pv_picovoice_t *object);

Releases resources acquired by Picovoice.

Parameters

  • object pv_picovoice_t * : Picovoice object.

pv_picovoice_process()

pv_status_t pv_picovoice_process(pv_picovoice_t *object, const int16_t *pcm);

Processes a frame of the incoming audio stream. Upon detection of wake word and completion of follow-on command inference invokes user-defined callbacks. The number of samples per frame can be attained by calling pv_picovoice_frame_length(). The incoming audio needs to have a sample rate equal to pv_sample_rate() and be 16-bit linearly-encoded. Picovoice operates on single-channel audio.

Parameters

  • object pv_picovoice_t * : Picovoice object.
  • pcm int16_t : A frame of audio samples.

Returns

  • pv_status_t : Returned status code.

pv_picovoice_version()

const char *pv_picovoice_version(void);

Getter for version.

Returns

  • char * : Picovoice version.

pv_picovoice_frame_length()

int32_t pv_picovoice_frame_length(void);

Getter for number of audio samples per frame.

Returns

  • int32_t : Frame length.

pv_picovoice_context_info()

pv_status_t pv_picovoice_context_info(const pv_picovoice_t *object, const char **context);

Getter for context information.

Parameters

  • object pv_picovoice_t * : Picovoice object.
  • context char * * : A frame of audio samples.

Returns

  • pv_status_t : Returned status code.

pv_sample_rate()

int32_t pv_sample_rate(void);

Audio sample rate accepted by Picovoice.

Returns

  • int32_t : Sample rate.

pv_status_t

typedef enum {
PV_STATUS_SUCCESS = 0,
PV_STATUS_OUT_OF_MEMORY,
PV_STATUS_IO_ERROR,
PV_STATUS_INVALID_ARGUMENT,
PV_STATUS_STOP_ITERATION,
PV_STATUS_KEY_ERROR,
PV_STATUS_INVALID_STATE,
PV_STATUS_RUNTIME_ERROR,
PV_STATUS_ACTIVATION_ERROR,
PV_STATUS_ACTIVATION_LIMIT_REACHED,
PV_STATUS_ACTIVATION_THROTTLED,
PV_STATUS_ACTIVATION_REFUSED
} pv_status_t;

Status code enum.


pv_status_to_string()

const char *pv_status_to_string(pv_status_t status);

Parameters

  • int32_t : Returned status code.

Returns

  • char * : String representation.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Picovoice Platform — C API
  • pv_picovoice_t
  • pv_inference_t
  • pv_inference_delete()
  • pv_picovoice_init()
  • pv_picovoice_delete()
  • pv_picovoice_process()
  • pv_picovoice_version()
  • pv_picovoice_frame_length()
  • pv_picovoice_context_info()
  • pv_sample_rate()
  • pv_status_t
  • pv_status_to_string()
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Resources
  • Docs
  • Console
  • Blog
  • Demos
Sales
  • Pricing
  • Starter Tier
  • Enterprise
Company
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.