iosPicovoice Platform — iOS API

API Reference for the iOS Picovoice SDK (Cocoapod)


Picovoice

public class Picovoice { }

Class for Picovoice. Picovoice can be initialized either using the High-level PicovoiceManager() Class or directly using the class constructor. Resources should be cleaned when you are done using the delete() function.


Picovoice.init()

init methods for Picovoice.

public init (
accessKey: String,
keywordPath: String,
onWakeWordDetection: @escaping (() -> Void),
contextPath: String,
onInference: @escaping ((Inference) -> Void),
porcupineModelPath: String? = nil,
porcupineSensitivity: Float32 = 0.5,
rhinoModelPath: String? = nil,
rhinoSensitivity: Float32 = 0.5,
requireEndpoint: Bool = true) throws

Parameters

  • accessKey String : The AccessKey obtained from Picovoice Console.
  • keywordPath String : Absolute paths to keyword model file (.ppn).
  • onWakeWordDetection (() -> Void) : A callback that is invoked upon detection of the keyword.
  • 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.
  • onInference (Inference) -> Void) : A callback that is invoked upon completion of intent inference.
  • porcupineModelPath String? : Absolute path to file containing Porcupine model parameters (.pv).
  • porcupineSensitivity Float32 : Sensitivities for detecting keywords. 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.
  • rhinoModelPath String? : Absolute path to file containing rhino model parameters (.pv).
  • rhinoSensitivity Float32 : 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 Bool : If set to true, Rhino requires an endpoint (chunk of silence) before finishing inference.

Throws

  • PicovoiceError: If an error occurs while creating an instance of Picovoice.

Picovoice.delete()

Releases resources acquired by Picovoice.

public func delete()

Picovoice.process()

Process a frame of audio with the Picovoice platform.

public func process(pcm:[Int16]) throws

Parameters

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

Throws

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

Picovoice.frameLength

Picovoice.frameLength: UInt32

The number of audio samples per frame.


Picovoice.sampleRate

Picovoice.sampleRate: UInt32

Audio sample rate accepted by Picovoice.


Picovoice.version

Picovoice.version: String

Current Picovoice version.


PicovoiceManager

A High-level iOS binding for Picovoice that handles recording audio from microphone, processes it in real-time, and notifies the client upon detection of the wake word or completion of in voice command inference.

public class PicovoiceManager { }

PicovoiceManager.init()

public init(
accessKey: String,
keywordPath: String,
onWakeWordDetection: @escaping (() -> Void),
contextPath: String,
onInference: @escaping ((Inference) -> Void),
porcupineModelPath: String? = nil,
porcupineSensitivity: Float32 = 0.5,
rhinoModelPath: String? = nil,
rhinoSensitivity: Float32 = 0.5,
requireEndpoint: Bool = true,
processErrorCallback: ((Error) -> Void)? = nil)

Parameters

  • accessKey String : The AccessKey obtained from Picovoice Console.
  • keywordPath String : Absolute paths to keyword model file (.ppn).
  • onWakeWordDetection (() -> Void) : A callback that is invoked upon detection of the keyword.
  • 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.
  • onInference ((Inference) -> Void) : A callback that is invoked upon completion of intent inference.
  • porcupineModelPath String? : Absolute path to file containing Porcupine model parameters (.pv).
  • porcupineSensitivity Float32 : Sensitivity for detecting keywords. 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.
  • rhinoModelPath String? : Absolute path to file containing rhino model parameters (.pv).
  • rhinoSensitivity Float32 : 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 Bool : If set to true, Rhino requires an endpoint (chunk of silence) before finishing inference.
  • processErrorCallback ((Error) -> Void)? = nil) : A callback that is invoked if an error occurs while processing frames. If missing, error will be printed to console.

Throws

  • PicovoiceError : If an error occurs while creating an instance of Picovoice.

PicovoiceManager.start()

public func start() throws

Starts recording audio from the microphone and Picovoice processing loop.

Throws


PicovoiceManager.stop()

public func stop()

Stop audio recording and processing loop.


PicovoiceError

public class PicovoiceError : LocalizedError { }

Error thrown if an error occurs within Picovoice.

public class PicovoiceMemoryError : PicovoiceError {}
public class PicovoiceIOError : PicovoiceError {}
public class PicovoiceInvalidArgumentError : PicovoiceError {}
public class PicovoiceStopIterationError : PicovoiceError {}
public class PicovoiceKeyError : PicovoiceError {}
public class PicovoiceInvalidStateError : PicovoiceError {}
public class PicovoiceRuntimeError : PicovoiceError {}
public class PicovoiceActivationError : PicovoiceError {}
public class PicovoiceActivationLimitError : PicovoiceError {}
public class PicovoiceActivationThrottledError : PicovoiceError {}
public class PicovoiceActivationRefusedError : PicovoiceError {}

Issue with this doc? Please let us know.