Rhino Speech-to-Intent
Rust API
API Reference for the Rhino Rust SDK (crates.io).
rhino::Rhino
Struct for the Rhino Speech-to-Intent engine.
rhino::Rhino.process()
Process a frame of pcm audio with the Speech-to-Intent engine.
Parameters
pcm
&[i16] : A frame of audio samples.
Returns
Result<bool, RhinoError>
: IfOk
, indicates whether Rhino has an inference ready or not. IfErr
, aRhinoError
object describing the error that was encountered.
rhino::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.
Returns
Result<(), RhinoError>
: IfOk
, nothing is returned. IfErr
, aRhinoError
object describing the error that was encountered.
rhino::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
Result<RhinoInference, RhinoError>
: IfOk
, aRhinoInference
containing the inference result data. IfErr
, aRhinoError
object describing the error that was encountered.
rhino::Rhino.context_info()
Gets the context information.
Returns
String
: Once initialized, stores the source of the Rhino context in YAML format. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.
rhino::Rhino.frame_length()
Gets the frame length.
Returns
u32
: Number of audio samples per frame.
rhino::Rhino.sample_rate()
Gets the sample rate.
Returns
u32
: Audio sample rate accepted by Rhino.
rhino::Rhino.version()
Gets the Rhino version.
Returns
String
: Rhino version string.
rhino::RhinoBuilder
Builder struct for creating an instance of Rhino
.
rhino::RhinoBuilder::new()
Creates a new RhinoBuilder
from required arguments.
Parameters
access_key
S : AccessKey obtained from Picovoice Console.context_path
P : Absolute path to the Rhino context file (.rhn).
Returns
RhinoBuilder
: A new Builder object.
rhino::RhinoBuilder.access_key()
Modifies the access_key
of a RhinoBuilder
object.
Parameters
access_key
S : AccessKey obtained from Picovoice Console.
Returns
RhinoBuilder
: The modified Builder object.
rhino::RhinoBuilder.library_path()
Overrides the default library_path
of a RhinoBuilder
object.
Parameters
library_path
P : Path to the Rhino library file.
Returns
RhinoBuilder
: The modified Builder object.
rhino::RhinoBuilder.model_path()
Overrides the default model_path
of a RhinoBuilder
object.
Parameters
model_path
P : Path to the file containing model parameters (.pv
).
Returns
RhinoBuilder
: The modified Builder object.
rhino::RhinoBuilder.context_path()
Modifies the context_path
of a RhinoBuilder
object.
Parameters
context_path
P : Absolute path to the Rhino context file (.rhn
).
Returns
RhinoBuilder
: The modified Builder object.
rhino::RhinoBuilder.sensitivity()
Overrides the default sensitivity
of a RhinoBuilder
object.
Parameters
sensitivity
f32 : Inference sensitivity. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate. Sensitivity should be a floating-point number within 0 and 1.
Returns
RhinoBuilder
: The modified Builder object.
rhino::RhinoBuilder.endpoint_duration_sec()
Overrides the default endpoint_duration_sec
of a RhinoBuilder
object.
Parameters
endpoint_duration_sec
f32 : 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.
Returns
RhinoBuilder
: The modified Builder object.
rhino::RhinoBuilder.require_endpoint()
Overrides the default value of require_endpoint
for a RhinoBuilder
object.
Parameters
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).
Returns
RhinoBuilder
: The modified Builder object.
rhino::RhinoBuilder.init()
Creates an instance of Rhino
from the RhinoBuilder
object.
Returns
Result<Rhino, RhinoError>
: IfOk
, an initialized instance ofRhino
. IfErr
, and instance ofRhinoError
detailing the error that was encountered.
rhino::RhinoInference
Represents an inference result returned from the Speech-to-Intent engine.
rhino::RhinoInference.is_understood
Indicates whether Rhino understood what it processed based on the context.
rhino::RhinoInference.intent
If is_understood
, name of intent that was inferred.
rhino::RhinoInference.slots
If is_understood
, dictionary of slot keys and values that were inferred.
rhino::RhinoError
An error type describing any errors encountered by the Rhino SDK.
rhino::RhinoError.status
Type of error encountered.
rhino::RhinoError.message
Message detailing the cause of the error.
rhino::RhinoError.new()
Creates a new instance of RhinoError
.
Parameters
status
RhinoErrorStatus
: Type of error encountered.message
&str : Message detailing the cause of the error.
rhino::RhinoErrorStatus
Enum describing possible error types returned from the Rhino Rust SDK.
rhino::PvStatus
Error codes returned from the Rhino library.