Package ai.picovoice.rhino
Class Rhino
java.lang.Object
ai.picovoice.rhino.Rhino
Java binding for Rhino Speech-to-Intent engine. It directly infers the user's intent from
spoken commands in real-time. Rhino processes incoming audio in consecutive frames and indicates
if the inference is finalized. When finalized, the inferred intent can be retrieved as structured
data in the form of an intent string and pairs of slots and values. The number of samples per
frame can be attained by calling
getFrameLength() . The incoming audio needs to have a
sample rate equal to getSampleRate() and be 16-bit linearly-encoded. Rhino operates on
single-channel audio.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating an instance of Rhino with a mixture of default arguments -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete()Releases resources acquired by Rhino.Getter for context information.intGetter for number of audio samples per frame.Gets inference result from Rhino.intGetter for audio sample rate accepted by Picovoice.Getter for version.booleanprocess(short[] pcm) Processes a frame of audio and emits a flag indicating if the inference is finalized.
-
Field Details
-
LIBRARY_PATH
-
MODEL_PATH
-
-
Constructor Details
-
Rhino
public Rhino(String accessKey, String libraryPath, String modelPath, String contextPath, float sensitivity, boolean requireEndpoint) throws RhinoException Constructor.- Parameters:
accessKey- AccessKey obtained from Picovoice Console (https://picovoice.ai/console/)libraryPath- Absolute path to the native Rhino library.modelPath- Absolute path to the file containing model parameters.contextPath- 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.sensitivity- 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.requireEndpoint- If set to `true`, Rhino requires an endpoint (chunk of silence) before finishing inference.- Throws:
RhinoException- If there is an error while initializing Rhino.
-
-
Method Details
-
delete
public void delete()Releases resources acquired by Rhino. -
process
Processes a frame of audio and emits a flag indicating if the inference is finalized. When finalized,getInference()should be called to retrieve the intent and slots, if the spoken command is considered valid.- Parameters:
pcm- A frame of audio samples. The number of samples per frame can be attained by callinggetFrameLength(). The incoming audio needs to have a sample rate equal togetSampleRate()and be 16-bit linearly-encoded. Furthermore, Rhino operates on single channel audio.- Returns:
- Flag indicating whether the engine has finalized intent extraction.
- Throws:
RhinoException- if there is an error while processing the audio frame.
-
getInference
Gets inference result 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:
- The result of inference as a
RhinoInferenceobject. - Throws:
RhinoException- if inference retrieval fails.
-
getContextInformation
Getter for context information.- Returns:
- Context information.
-
getFrameLength
public int getFrameLength()Getter for number of audio samples per frame.- Returns:
- Number of audio samples per frame.
-
getSampleRate
public int getSampleRate()Getter for audio sample rate accepted by Picovoice.- Returns:
- Audio sample rate accepted by Picovoice.
-
getVersion
Getter for version.- Returns:
- Version.
-