rustRhino - Rust API

API Reference for the Rhino Rust SDK (crates.io).


rhino::Rhino

pub struct Rhino

Struct for the Rhino Speech-to-Intent engine.


rhino::Rhino.process()

pub fn process(&self, pcm: &[i16]) -> Result<bool, RhinoError>

Process a frame of pcm audio with the Speech-to-Intent engine.

Parameters

  • pcm &[i16] : A frame of audio samples.

Returns

  • Result<bool, RhinoError> : If Ok, indicates whether Rhino has an inference ready or not. If Err, a RhinoError object describing the error that was encountered.

rhino::Rhino.get_inference()

pub fn get_inference(&self) -> Result<RhinoInference, RhinoError>

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> : If Ok, a RhinoInference containing the inference result data. If Err, a RhinoError object describing the error that was encountered.

rhino::Rhino.context_info()

pub fn context_info(&self) -> String

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()

pub fn frame_length(&self) -> u32

Gets the frame length.

Returns

  • u32 : Number of audio samples per frame.

rhino::Rhino.sample_rate()

pub fn sample_rate(&self) -> u32

Gets the sample rate.

Returns

  • u32 : Audio sample rate accepted by Rhino.

rhino::Rhino.version()

pub fn version(&self) -> String

Gets the Rhino version.

Returns

  • String : Rhino version string.

rhino::RhinoBuilder

pub struct RhinoBuilder

Builder struct for creating an instance of Rhino.


rhino::RhinoBuilder::new()

pub fn new<S: Into<String>, P: Into<PathBuf>>(
access_key: S,
context_path: P
) -> Self

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


rhino::RhinoBuilder.access_key()

pub fn access_key<'a, S: Into<String>>(
&'a mut self,
access_key: S
) -> &'a mut Self

Modifies the access_key of a RhinoBuilder object.

Parameters

Returns


rhino::RhinoBuilder.library_path()

pub fn library_path<'a, P: Into<PathBuf>>(
&'a mut self,
library_path: P
) -> &'a mut Self

Overrides the default library_path of a RhinoBuilder object.

Parameters

  • library_path P : Path to the Rhino library file.

Returns


rhino::RhinoBuilder.model_path()

pub fn model_path<'a, P: Into<PathBuf>>(
&'a mut self,
model_path: P
) -> &'a mut Self

Overrides the default model_path of a RhinoBuilder object.

Parameters

  • model_path P : Path to the file containing model parameters (.pv).

Returns


rhino::RhinoBuilder.context_path()

pub fn context_path<'a, P: Into<PathBuf>>(
&'a mut self,
context_path: P
) -> &'a mut Self

Modifies the context_path of a RhinoBuilder object.

Parameters

  • context_path P : Absolute path to the Rhino context file (.rhn).

Returns


rhino::RhinoBuilder.sensitivity()

pub fn sensitivity<'a>(&'a mut self, sensitivity: f32) -> &'a mut Self

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


rhino::RhinoBuilder.require_endpoint()

pub fn require_endpoint<'a>(
&'a mut self,
require_endpoint: bool
) -> &'a mut Self

Overrides the default value of require_endpoint for a RhinoBuilder object.

Parameters

  • require_endpoint bool : If set to false, Rhino does not require an endpoint (chunk of silence) before finishing inference.

Returns


rhino::RhinoBuilder.init()

pub fn init(&self) -> Result<Rhino, RhinoError>

Creates an instance of Rhino from the RhinoBuilder object.

Returns

  • Result<Rhino, RhinoError> : If Ok, an initialized instance of Rhino. If Err, and instance of RhinoError detailing the error that was encountered.

rhino::RhinoInference

pub struct RhinoInference

Represents an inference result returned from the Speech-to-Intent engine.


rhino::RhinoInference.is_understood

pub is_understood: bool

Indicates whether Rhino understood what it processed based on the context.

rhino::RhinoInference.intent

pub intent: Option<String>

If is_understood, name of intent that was inferred.

rhino::RhinoInference.slots

pub slots: HashMap<String, String>

If is_understood, dictionary of slot keys and values that were inferred.


rhino::RhinoError

pub struct RhinoError

An error type describing any errors encountered by the Rhino SDK.


rhino::RhinoError.status

pub status: RhinoErrorStatus

Type of error encountered.


rhino::RhinoError.message

pub status: Option<String>

Message detailing the cause of the error.


rhino::RhinoError.new()

pub fn new(status: RhinoErrorStatus, message: &str) -> Self

Creates a new instance of RhinoError.

Parameters

  • status RhinoErrorStatus : Type of error encountered.
  • message &str : Message detailing the cause of the error.

rhino::RhinoErrorStatus

pub enum RhinoErrorStatus {
LibraryError(PvStatus),
LibraryLoadError,
FrameLengthError,
ArgumentError,
}

Enum describing possible error types returned from the Rhino Rust SDK.


rhino::PvStatus

pub enum PvStatus {
SUCCESS,
OUT_OF_MEMORY,
IO_ERROR,
INVALID_ARGUMENT,
STOP_ITERATION,
KEY_ERROR,
INVALID_STATE,
RUNTIME_ERROR,
ACTIVATION_ERROR,
ACTIVATION_LIMIT_REACHED,
ACTIVATION_THROTTLED,
ACTIVATION_REFUSED,
}

Error codes returned from the Rhino library.


Issue with this doc? Please let us know.