Porcupine Wake Word
iOS API
API Reference for the iOS Porcupine SDK (Cocoapod)
Porcupine
Class for the Porcupine Wake Word engine. Porcupine can be initialized either using the
High-level PorcupineManager() Class or directly using the class constructor.
Resources should be cleaned when you are done using the delete()
function.
Porcupine.init()
init
methods for Porcupine Wake Word engine with a mixture of arguments.
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keywordPaths
[String] : Absolute paths to keyword model files (.ppn
).modelPath
String? : Absolute path to file containing model parameters (.pv
).sensitivities
[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.
Throws
PorcupineError
: If an error occurs while creating an instance of Porcupine Wake Word engine.
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keywordPath
String : Absolute path to a keyword model file (.ppn
).modelPath
String? : Absolute path to file containing model parameters (.pv
).sensitivity
Float32? : Sensitivity for detecting keyword, which should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.
Throws
PorcupineError
: If an error occurs while creating an instance of Porcupine Wake Word engine.
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keywords
[Porcupine.BuiltInKeyword] : An array of built-in keywords from the Porcupine.BuiltInKeyword enum.modelPath
String? : Absolute path to file containing model parameters (.pv
).sensitivities
[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.
Throws
PorcupineError
: If an error occurs while creating an instance of Porcupine Wake Word engine.
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keyword
Porcupine.BuiltInKeyword : A built-in keyword from the Porcupine.BuiltInKeyword enum.modelPath
String? : Absolute path to file containing model parameters (.pv
).sensitivity
Float32? : Sensitivity for detecting keyword, which should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.
Throws
PorcupineError
: If an error occurs while creating an instance of Porcupine Wake Word engine.
Porcupine.delete()
Releases resources acquired by the Porcupine engine.
Porcupine.process()
Process a frame of audio with the Porcupine Wake Word engine.
Parameters
pcm
[Int16] : An array of 16-bit pcm samples.
Returns
- Int32 : Index of keyword detected or -1 if no keyword was detected.
Throws
PorcupineError
: If there is an error while processing the audio frame.
Porcupine.frameLength
The number of audio samples per frame.
Porcupine.sampleRate
Audio sample rate accepted by Porcupine.
Porcupine.version
Current Porcupine version.
Porcupine.BuiltInKeyword
Enum of available built-in keywords for Porcupine Wake Word engine.
PorcupineManager
A High-level iOS binding for Porcupine
that handles recording audio from microphone, processes it in
real-time using Porcupine, and notifies the client when any of the given keywords are detected.
PorcupineManager.init()
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keywordPaths
[String] : Absolute paths to keyword model files (.ppn
).modelPath
String? : Absolute path to file containing model parameters (.pv
).sensitivities
[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.onDetection
((Int32) -> Void)? : A callback that is invoked upon detection of the keyword.errorCallback
((Error) -> Void)? = nil) : A callback that is invoked if an error occurs while processing frames. If missing, error will be printed to console.
Throws
PorcupineManagerError
: If an error occurs while creating an instance of Porcupine Wake Word engine.
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keywordPath
String : Absolute path to a keyword model file (.ppn
).modelPath
String? : Absolute path to file containing model parameters (.pv
).sensitivity
Float32? : Sensitivity for detecting keyword, which should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.onDetection
((Int32) -> Void)? : A callback that is invoked upon detection of the keyword.errorCallback
((Error) -> Void)? = nil) : A callback that is invoked if an error occurs while processing frames. If missing, error will be printed to console.
Throws
PorcupineManagerError
: If an error occurs while creating an instance of Porcupine Wake Word engine.
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keywords
[Porcupine.BuiltInKeyword] : An array of built-in keywords from the Porcupine.BuiltInKeyword enum.modelPath
String? : Absolute path to file containing model parameters (.pv
).sensitivities
[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.onDetection
((Int32) -> Void)? : A callback that is invoked upon detection of the keyword.errorCallback
((Error) -> Void)? = nil) : A callback that is invoked if an error occurs while processing frames. If missing, error will be printed to console.
Throws
PorcupineManagerError
: If an error occurs while creating an instance of Porcupine Wake Word engine.
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.keyword
Porcupine.BuiltInKeyword : A built-in keyword from the Porcupine.BuiltInKeyword enum.modelPath
String? : Absolute path to file containing model parameters (.pv
).sensitivity
Float32? : Sensitivity for detecting keyword, which should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.onDetection
((Int32) -> Void)? : A callback that is invoked upon detection of the keyword.errorCallback
((Error) -> Void)? = nil) : A callback that is invoked if an error occurs while processing frames. If missing, error will be printed to console.
Throws
PorcupineManagerError
: If an error occurs while creating an instance of Porcupine Wake Word engine.
PorcupineManager.delete()
Stops recording and releases Porcupine resources.
PorcupineManager.start()
Starts recording audio from the microphone and monitors it for the utterances of the given set of keywords.
Throws
PorcupineError
: If microphone permission is not granted or Porcupine has been disposed.
PorcupineManager.stop()
Stop listening for wake words.
PorcupineManagerError
Enums for PorcupineManager error values:
case recordingDenied
case objectDisposed
PorcupineError
Error thrown if an error occurs within Porcupine Wake Word engine.