iosRhino - iOS API

API Reference for the iOS Rhino SDK (Cocoapod)


Rhino

public class Rhino { }

Class for the Rhino Speech-to-Intent engine. Rhino can be initialized either using the High-level RhinoManager() Class or directly using the class constructor. Resources should be cleaned when you are done using the delete() function.


Rhino.init()

init methods for the Rhino Speech-to-Intent engine.

public init(accessKey: String, contextPath: String, modelPath:String? = nil, sensitivity:Float32 = 0.5, requireEndpoint: Bool = true) throws

Parameters

  • accessKey String : The AccessKey obtained from Picovoice Console.
  • contextPath String : Absolute path to file containing context parameters (.rhn). A context represents the set of expressions (spoken commands), intents, and intent arguments (slots) within a domain of interest.
  • modelPath String? : Absolute path to file containing model parameters (.pv).
  • sensitivity Float32 : Inference sensitivity. Each value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.
  • requireEndpoint Bool : If set to true, Rhino requires an endpoint (chunk of silence) before finishing inference.

Throws

  • RhinoError: If an error occurs while creating an instance of Rhino Speech-to-Intent engine.

Rhino.delete()

Releases resources acquired by the Rhino engine.

public func delete()

Rhino.process()

Process a frame of audio with the inference engine.

public func process(pcm:[Int16]) throws -> Bool

Parameters

  • pcm [Int16] : An array of 16-bit pcm samples.

Returns

  • Bool : A boolean indicating whether Rhino has a result ready or not.

Throws

  • RhinoError: If there is an error while processing the audio frame.

Rhino.getInference()

Get inference result from Rhino.

public func getInference() throws -> Inference

Returns

Throws

  • RhinoError: If there is an error while getting the inference.

Rhino.frameLength

Rhino.frameLength: UInt32

The number of audio samples per frame.


Rhino.sampleRate

Rhino.sampleRate: UInt32

Audio sample rate accepted by Rhino engine.


Rhino.version

Rhino.version: String

Current Rhino version.


Inference

Class for the Rhino's inference.

public struct Inference { }

Inference.isUnderstood

Inference.isUnderstood: Bool

If true, Rhino understood the inference.


Inference.intent

Inference.intent: String

Inference intent name.


Inference.slots

Inference.slots: Dictionary<String, String>

Dictionary for inference slots and values.


RhinoManager

A High-level iOS binding for Rhino that handles recording audio from microphone, processes it in real-time using Rhino, and notifies the client when an intent is inferred from the spoken command.

public class RhinoManager { }

RhinoManager.init()

public init(
accessKey: String,
contextPath: String,
modelPath: String? = nil,
sensitivity: Float32 = 0.5,
requireEndpoint: Bool = true,
onInferenceCallback: ((Inference) -> Void)?,
processErrorCallback: ((Error) -> Void)? = nil) throws

Parameters

  • accessKey String : The AccessKey obtained from Picovoice Console.
  • contextPath String : Absolute path to file containing context parameters (.rhn). A context represents the set of expressions (spoken commands), intents, and intent arguments (slots) within a domain of interest.
  • modelPath String? : Absolute path to file containing model parameters (.pv).
  • sensitivity Float32 : Inference sensitivity. Each value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.
  • requireEndpoint Bool : If set to true, Rhino requires an endpoint (chunk of silence) before finishing inference.
  • onInferenceCallback ((Inference) -> Void)? : It is invoked upon completion of intent inference.
  • errorCallback ((Error) -> Void)? = nil) : Invoked if an error occurs while processing frames. If missing, error will be printed to console.

Throws

  • RhinoError : If an error occurs while creating an instance of Rhino engine.

RhinoManager.delete()

public func delete()

Stops recording and releases Rhino resources.


RhinoManager.process()

public func process() throws

Start recording audio from the microphone and infers the user's intent from the spoken command. Once the inference is finalized it will invoke the user provided callback and terminates recording audio.

Throws

  • RhinoError : if microphone permission is not granted or Rhino has been disposed.

RhinoManagerError

public enum RhinoManagerError: Error {}

Enums for RhinoManager error values:

  • case recordingDenied
  • case objectDisposed

RhinoError

public class RhinoError : LocalizedError { }

Error thrown if an error occurs within Rhino engine.

public class RhinoMemoryError : RhinoError {}
public class RhinoIOError : RhinoError {}
public class RhinoInvalidArgumentError : RhinoError {}
public class RhinoStopIterationError : RhinoError {}
public class RhinoKeyError : RhinoError {}
public class RhinoInvalidStateError : RhinoError {}
public class RhinoRuntimeError : RhinoError {}
public class RhinoActivationError : RhinoError {}
public class RhinoActivationLimitError : RhinoError {}
public class RhinoActivationThrottledError : RhinoError {}
public class RhinoActivationRefusedError : RhinoError {}

Issue with this doc? Please let us know.