Porcupine Wake Word
Unity API
API Reference for the Porcupine Unity SDK.
package: Pv.Unity
Porcupine
Class for the Porcupine Wake Word engine.
Porcupine.BuiltInKeyword
Keywords that are packaged with the Porcupine Unity SDK.
Porcupine.FrameLength
Gets the required number of audio samples-per-frame.
Returns
int: Required frame length.
Porcupine.SampleRate
Get the audio sample rate required by Porcupine.
Returns
int: Required sample rate in Hz.
Porcupine.Version
Gets the version number of the Porcupine library.
Returns
string: Version of Porcupine.
Porcupine.Dispose()
Explicitly releases resources acquired by Porcupine.
Porcupine.FromBuiltInKeywords()
Creates an instance of Porcupine from built-in keywords.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.keywordsIEnumerable<BuiltInKeyword> : List of built-in keywords to detect.modelPathstring : Absolute path to the file containing model parameters (.pv). If not set, default model is used.sensitivitiesIEnumerable<float> : 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. Default values are 0.5.
Returns
Porcupine: An instance of the Porcupine Wake Word engine.
Throws
PorcupineException: If an error occurs while creating an instance of Porcupine Wake Word engine.
Porcupine.FromKeywordPaths()
Creates an instance of Porcupine from custom keyword files.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.keywordPathsIEnumerable<string> : A list of absolute paths to keyword model files (.ppn).modelPathstring : Absolute path to the file containing model parameters (.pv). If not set, default model is used.sensitivitiesIEnumerable<float> : 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. Default values are 0.5.
Returns
Porcupine: An instance of the Porcupine Wake Word engine.
Throws
PorcupineException: If an error occurs while creating an instance of Porcupine Wake Word engine.
Porcupine.Process()
Processes a frame of the incoming audio stream and emits the detection result.
The number of samples-per-frame can be obtained by calling .FrameLength.
The incoming audio needs to have a sample rate equal to .SampleRate and be 16-bit linearly-encoded.
Porcupine operates on single-channel audio.
Parameters
pcmshort[] : A frame of audio samples.
Returns
int: Index of observed keyword at the end of the current frame. Indexing is 0-based and matches the ordering of keywords provided to the Porcupine instance. If no keyword is detected then it returns -1.
Throws
PorcupineException: If there is an error while processing the audio frame.
PorcupineException
Exception thrown if an error is encountered by the Porcupine engine.
Exceptions:
PorcupineManager
High-level API for the Porcupine Wake Word engine. It handles audio recording and processing in real-time,
and notifies the client upon detection of the wake word.
PorcupineManager.IsAudioDeviceAvailable
Checks whether there are any audio capture devices available.
Returns
bool: If any available audio capture device are available.
PorcupineManager.IsRecording
Checks whether PorcupineManager is capturing audio or not.
Returns
bool: If recording or not.
PorcupineManager.Delete()
Free resources that were allocated to PorcupineManager.
PorcupineManager.FromBuiltInKeywords()
Creates an instance of PorcupineManager from built-in keywords.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.keywordsIEnumerable<BuiltInKeyword> : List of built-in keywords to detect.wakeWordCallbackAction<int> : A callback that is triggered when one of the given keywords has been detected by Porcupine.modelPathstring : Absolute path to the file containing model parameters (.pv). If not set, default model is used.sensitivitiesIEnumerable<float> : 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. Default values are 0.5.processErrorCallbackAction<PorcupineException> : Callback that triggers is the engine experiences a problem while processing audio. If not set, errors will be printed to the Debug console.
Returns
PorcupineManager: An instance of thePorcupineManagerclass.
Throws
PorcupineException: If an error occurs while creating an instance of Porcupine Wake Word engine.
PorcupineManager.FromKeywordPaths()
Creates an instance of PorcupineManager from a list of Porcupine keyword file paths.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.keywordPathsIEnumerable<string> : A list of absolute paths to keyword model files (.ppn).wakeWordCallbackAction<int> : A callback that is triggered when one of the given keywords has been detected by Porcupine.modelPathstring : Absolute path to the file containing model parameters (.pv). If not set, default model is used.sensitivitiesIEnumerable<float> : 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. Default values are 0.5.processErrorCallbackAction<PorcupineException> : Callback that triggers is the engine experiences a problem while processing audio. If not set, errors will be printed to the Debug console.
Returns
PorcupineManager: An instance of thePorcupineManagerclass.
Throws
PorcupineException: If an error occurs while creating an instance of Porcupine Wake Word engine.
PorcupineManager.Start()
Starts audio capture and wake word detection.
Throws
PorcupineException: If there is an error while starting audio capture.
PorcupineManager.Stop()
Stops audio capture and wake word detection.
Throws
PorcupineException: If there is an error while stopping audio capture.