Rhino Speech-to-Intent
Python API
API Reference for the Python Rhino SDK (PyPI).
pvrhino.create()
Factory method for Rhino Speech-to-Intent engine.
Parameters
access_keystr : AccessKey obtained from Picovoice Console.context_pathstr : Absolute path to file containing context model(file with.rhnextension). A context represents the set of expressions (spoken commands), intents, and intent arguments (slots) within a domain of interest.library_pathOptional[str] : Absolute path to Rhino's dynamic library. If not set it will be set to the default location.model_pathOptional[str] : Absolute path to the file containing model parameters. If not set it will be set to the default location.sensitivityOptional[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_secOptional[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.requireEndpointOptional[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.
Returns
Rhino: An instance of Rhino Speech-to-Intent engine.
Throws
pvrhino.Rhino
Class for the Rhino Speech-to-Intent engine.
Rhino can be initialized either using the module level create() function
or directly using the class __init__() method.
Resources should be cleaned when you are done using the delete() method.
pvrhino.Rhino.context_info
The context information of the Rhino instance.
pvrhino.Rhino.version
The version string of the Rhino library.
pvrhino.Rhino.frame_length
The number of audio samples per frame that Rhino accepts.
pvrhino.Rhino.sample_rate
The audio sample rate the Rhino accepts.
pvrhino.Rhino.__init__()
__init__ method for Rhino Speech-to-Intent engine.
Parameters
access_keystr : AccessKey obtained from Picovoice Console.library_pathstr : Absolute path to Rhino's dynamic library.model_pathstr : Absolute path to the file containing model parameters.context_pathstr : Absolute path to the file containing model parameters.sensitivityOptional[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.requireEndpointOptional[bool] : If set toFalse, Rhino does not require an endpoint (chunk of silence) before finishing inference.
Returns
Rhino: An instance of Rhino Speech-to-Intent engine.
Throws
pvrhino.Rhino.delete()
Releases resources acquired by Rhino.
pvrhino.Rhino.get_inference()
Gets inference results from Rhino. If the spoken command was understood, it includes the specific intent name that was inferred, and (if applicable) slot keys and specific slot values. Should only be called after the process function returns true, otherwise Rhino has not yet reached an inference conclusion.
Returns
Inference: An immutable object with.is_understood,.intent, and.slotsgetters.
Throws
pvrhino.Rhino.process()
Processes a frame of audio and emits a flag indicating if the inference is finalized. When finalized, .get_inference() should be called to retrieve the intent and slots, if the spoken command is considered valid.
The number of samples per frame can be attained by calling .frame_length.
The incoming audio needs to have a sample rate equal to .sample_rate and be 16-bit linearly-encoded.
Rhino operates on single-channel audio.
Parameters
pcmList[int] : A frame of audio samples.
Returns
bool: Flag indicating if the inference is finalized.
Throws
pvrhino.Rhino.reset()
Resets the internal state of Rhino. It should be called before the engine can be used to infer intent from a new stream of audio.
Throws
pvrhino.Rhino.Inference
Immutable object containing Rhino inference information.
Getters
is_understoodbool : whether Rhino understood what it heard based on the contextintentstr : name of intent that was inferredslotsdict : dictionary of slot keys and values that were inferred
pvrhino.RhinoError
Error thrown if an error occurs within Rhino Speech-To-Intent engine.
Exceptions