Porcupine Wake Word — C API
API Reference for the Porcupine C SDK .
pv_porcupine_t
Container representing the Porcupine wake word engine.
pv_porcupine_init()
Creates a Porcupine instance. Resources should be cleaned when you are done using the pv_porcupine_delete() function.
Parameters
access_key
const char * : AccessKey obtained from Picovoice Console .model_path
const char * : Absolute path to the file containing model parameters (.pv
).num_keywords
int32_t : Number of keywords to monitor.keyword_paths
const char *const * : Absolute paths to keyword model files (.ppn
).sensitivities
float * : Sensitivities for detecting keywords. Each value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.object
pv_porcupine_t * * : Constructed instance of Porcupine.
Returns
- pv_status_t : Returned status code.
pv_porcupine_delete()
Releases resources acquired by Porcupine.
Parameters
object
pv_porcupine_t * : Picovoice object.
pv_porcupine_process()
Processes a frame of the incoming audio stream and emits the detection result. The number of samples per frame can be
attained by calling pv_porcupine_frame_length()
. The incoming audio needs to have a
sample rate equal to pv_sample_rate()
and be 16-bit linearly-encoded. Porcupine operates on
single-channel audio.
Parameters
object
pv_porcupine_t * : Porcupine object.pcm
int16_t : A frame of audio samples.keyword_index
int32_t * : Index of observed keyword at the end of the current frame. Indexing is 0-based and matches the ordering of keyword models provided to pv_porcupine_init(). If no keyword is detected then it is set to -1.
Returns
- pv_status_t : Returned status code.
pv_porcupine_version()
Getter for version.
Returns
- char * : Porcupine version.
pv_porcupine_frame_length()
Getter for number of audio samples per frame.
Returns
- int32_t : Frame length.
pv_sample_rate()
Audio sample rate accepted by Porcupine.
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.