Picovoice Platform
C API
API Reference for the Picovoice C SDK.
pv_picovoice_t
Container representing the Picovoice platform.
pv_inference_t
Container representing inferred user intent. pv_inference_t
exposes the following immutable fields:
is_understood
is a flag indicating if the spoken command is understood.intent
is the inferred intent from the voice command. If the command is not understood then it's set toNULL
.num_slots
is the number of slots.slots
is a list of slot keys.values
is the corresponding slot values.
pv_inference_delete()
Destructor for pv_inference_t
. Should be called after completion of intent inference.
Parameters
inference
pv_inference_t * : Inference container.
pv_picovoice_init()
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 totrue
, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set tofalse
, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set tofalse
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 typepv_inference_t
.object
pv_picovoice_t * * : Constructed instance of Picovoice.
Returns
- pv_status_t : Returned status code.
pv_picovoice_delete()
Releases resources acquired by Picovoice.
Parameters
object
pv_picovoice_t * : Picovoice object.
pv_picovoice_process()
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()
Getter for version.
Returns
- char * : Picovoice version.
pv_picovoice_frame_length()
Getter for number of audio samples per frame.
Returns
- int32_t : Frame length.
pv_picovoice_context_info()
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()
Audio sample rate accepted by Picovoice.
Returns
- int32_t : Sample rate.
pv_status_t
Status code enum.
pv_status_to_string()
Parameters
- int32_t : Returned status code.
Returns
- char * : String representation.
pv_get_error_stack()
If a function returns a failure (any pv_status_t other than PV_STATUS_SUCCESS
), this function can be
called to get a series of error messages related to the failure. This function can only be called only once per
failure status on another function. The memory for message_stack
must be freed using pv_free_error_stack
.
Regardless of the return status of this function, if message_stack
is not NULL
, then message_stack
contains valid memory. However, a failure status on this function indicates that future error messages
may not be reported.
Parameters
message_stack
const char * * * : Array of messages relating to the failure. Messages are NULL terminated strings. The array and messages must be freed usingpv_free_error_stack()
.message_stack_depth
int32_t * : The number of messages in themessage_stack
array.
Returns
- pv_status_t : Returned status code.
pv_free_error_stack()
This function frees the memory used by error messages allocated by pv_get_error_stack()
.
Parameters
message_stack
const char * * * : Array of messages relating to the failure.