Rhino Speech-to-Intent — C API
API Reference for the Rhino C SDK .
pv_rhino_t
Container representing the Rhino engine.
pv_rhino_init()
Creates a Rhino instance. Resources should be cleaned when you are done using
the pv_rhino_delete()
function.
Parameters
access_key
char * : AccessKey obtained from Picovoice Console .model_path
char * : Absolute path to file containing model parameters (.pv
).context_path
char * : Absolute path to file containing context parameters. A context represents the set of expressions (spoken commands), intents, and intent arguments (slots) within a domain of interest (.rhn
).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).object
pv_rhino_t * * : Constructed instance of Rhino.
Returns
- pv_status_t : Returned status code.
pv_rhino_delete()
Releases resources acquired by Rhino.
Parameters
object
pv_rhino_t * : Rhino Speech-to-Intent object.
pv_rhino_process()
Processes a frame of audio and emits a flag indicating if the inference is finalized. When finalized,
pv_rhino_is_understood()
[#pv_rhino_is_understood] should be called to check if the spoken command is considered
valid. The number of samples per frame can be attained by
calling pv_rhino_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_rhino_t * : Rhino Speech-to-Intent object.pcm
int16_t * : A frame of audio samples.is_finalized
bool * : A flag indicating if the inference is finalized.
Returns
- pv_status_t : Returned status code.
pv_rhino_is_understood()
Indicates if the spoken command is valid, is within the domain of interest (context), and the engine understood it. Upon success pv_rhino_get_intent() may be called to retrieve inferred intent. If not understood, pv_rhino_reset() should be called.
Parameters
object
pv_rhino_t * : Rhino Speech-to-Intent object.is_understood
bool * : A flag indicating if the spoken command is understood.
Returns
- pv_status_t : Returned status code.
pv_rhino_get_intent()
Getter for the intent. The intent is stored as an intent string and pairs of slots and values. It should be called only after intent inference is finalized, and it is verified that the spoken command is understood via calling pv_rhino_is_understood().
Parameters
object
pv_rhino_t * : Rhino Speech-to-Intent object.intent
bool ** : Inferred intent.num_slots
int32_t * : Number of slots.slots
const char *** : Array of inferred slots. Its memory needs to be freed by calling pv_rhino_free_slots_and_values().values
const char *** : Array of inferred slot values. Its memory needs to be freed by calling pv_rhino_free_slots_and_values().
Returns
- pv_status_t : Returned status code.
pv_rhino_free_slots_and_values()
Frees memory resources allocated to slots and values after calling pv_rhino_get_intent(). One should not free these resources via standard C library 'free()'.
Parameters
object
pv_rhino_t * : Rhino Speech-to-Intent object.slots
const char ** : Slots.values
const char ** : Slot values.
Returns
- pv_status_t : Returned status code.
pv_rhino_reset()
Resets the internal state of the engine. It should be called before the engine can be used to infer intent from a new stream of audio.
Parameters
object
pv_rhino_t * : Rhino Speech-to-Intent object.
Returns
- pv_status_t : Returned status code.
pv_rhino_context_info()
Getter for context information.
Parameters
object
pv_rhino_t * : Rhino Speech-to-Intent object.context
char * * : A frame of audio samples.
Returns
- pv_status_t : Returned status code.
pv_rhino_version()
Getter for version.
Returns
- char * : Rhino version.
pv_rhino_frame_length()
Getter for number of audio samples per frame.
Returns
- int32_t : Frame length.
pv_sample_rate()
Audio sample rate accepted by Rhino.
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.