Rhino Speech-to-Intent
Microcontroller API
This document outlines how to use the Rhino Speech-to-Intent engine on a microcontroller.
pv_rhino_t
Container representing the Rhino Speech-to-Intent engine.
pv_rhino_init()
Create a Rhino instance. Resources should be cleaned when you are done using
the pv_rhino_delete() function.
Parameters
access_keychar * : AccessKey obtained from Picovoice Console.memory_buffervoid * : Memory; needs to be 8-byte aligned.memory_sizeint32_t : Memory size in bytes. The optimal size for given context models can be computed usingpv_rhino_get_min_memory_buffer_size()contextconst void * : Context parameters. A context represents the set of expressions (spoken commands), intents, and intent arguments (slots) within a domain of interest.context_sizeint32_t : Size of the context in bytes.sensitivityfloat : 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_secfloat : 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_endpointbool : 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 tofalseonly if operating in an environment with overlapping speech (e.g. people talking in the background).objectpv_rhino_t * * : Constructed instance of Rhino.
Returns
- pv_status_t : Returned status code.
pv_rhino_get_min_memory_buffer_size()
Computes the minimum required memory buffer size, in bytes, for the given context model. A relatively large value for preliminary_memory_buffer is suggested (e.g., 30 kilobytes). Then, pv_rhino_init() can be called optimally passing a memory buffer with the size of min_memory_buffer_size.
Parameters
preliminary_memory_sizeint32_t : Memory size in bytes.preliminary_memory_buffervoid * : Memory; needs to be 8-byte aligned.context_modelvoid * : Context parameters.context_model_sizeint32_t : Size of the context in bytes.min_memory_buffer_sizeint32_t * : minimum required memory buffer size in bytes.
Returns
- pv_status_t : Returned status code.
pv_rhino_delete()
Releases resources acquired by Rhino.
Parameters
objectpv_rhino_t * : Rhino object.
pv_rhino_process()
Processes a frame of the incoming audio stream and emits a flag indicating if the inference is finalized.
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.
Rhino operates on single-channel audio.
When finalized, pv_rhino_is_understood() should be called to check if the spoken command is considered valid.
Parameters
objectpv_rhino_t * : Rhino object.pcmint16_t : A frame of audio samples.is_finalizedbool * : 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
objectpv_rhino_t * : Rhino object.is_understoodbool * : 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
objectpv_rhino_t * : Rhino object.intentconst char ** : Inferred intent.num_slotsint32_t * : Number of slots.slotsconst char *** : Array of inferred slots. Its memory needs to be freed by callingpv_rhino_free_slots_and_values().valuesconst char *** : Array of inferred slot values. Its memory needs to be freed by callingpv_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 shouldn't free these resources via standard C library free().
Parameters
objectpv_rhino_t * : Rhino object.slotsconst char ** : Slots.valuesconst 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
objectpv_rhino_t * : Rhino object.
Returns
- pv_status_t : Returned status code.
pv_rhino_context_info()
Getter for context information.
Parameters
objectpv_rhino_t * : Rhino object.context_infoconst char ** : Context information.
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 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_stackconst 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_depthint32_t * : The number of messages in themessage_stackarray.
pv_free_error_stack()
This function frees the memory used by error messages allocated by pv_get_error_stack().
Parameters
message_stackconst char * * * : Array of messages relating to the failure.