Picovoice Platform
iOS API
API Reference for the iOS Picovoice SDK (Cocoapod)
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.
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keywordPath
String : Absolute path 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.endpointDurationSec
Float32 : 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.requireEndpoint
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).
Throws
PicovoiceError
: If an error occurs while creating an instance of Picovoice.
Picovoice.delete()
Releases resources acquired by Picovoice.
Picovoice.process()
Process a frame of audio with the Picovoice platform.
Parameters
pcm
[Int16] : An array of 16-bit pcm samples.
Throws
PicovoiceError
: If there is an error while processing the audio frame.
Picovoice.reset()
Resets the internal state of Picovoice. It should be called before processing a new stream of audio or when Picovoice was stopped while processing a stream of audio.
Throws
PicovoiceError
: If there is an error while resetting.
Picovoice.contextInfo
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.
Picovoice.frameLength
The number of audio samples per frame.
Picovoice.sampleRate
Audio sample rate accepted by Picovoice.
Picovoice.picovoiceVersion
Current Picovoice version.
Picovoice.porcupineVersion
Current Porcupine version.
Picovoice.rhinoVersion
Current Rhino 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.
PicovoiceManager.init()
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keywordPath
String : Absolute path 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.endpointDurationSec
Float32 : 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.requireEndpoint
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).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()
Starts recording audio from the microphone and Picovoice processing loop.
Throws
PicovoiceError
: If an error is encountered while starting audio processing.
PicovoiceManager.stop()
Stop audio recording and processing loop.
Throws
PicovoiceError
: If an error is encountered while stopping audio processing.
PicovoiceManager.reset()
Resets the internal state of PicovoiceManager. It can be called to return to the wake word detection state before an inference has completed.
Throws
PicovoiceError
: If an error is encountered while resetting.
PicovoiceManager.delete()
Releases native resources that were allocated to PicovoiceManager
PicovoiceError
Error thrown if an error occurs within Picovoice.