Porcupine Wake Word
.NET API
API Reference for the .NET Porcupine SDK (NuGet)
namespace: Pv
Porcupine
Class for the Porcupine Wake Word engine.
Porcupine.FromBuiltInKeywords()
Porcupine constructor when using built-in keywords.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.keywordsIEnumerable<BuiltInKeyword> : List of built-in keywords for detection.modelPathstring : Absolute path to the file containing model parameters (.pv).devicestring : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.sensitivitiesIEnumerable<float> : Sensitivities for detecting keywords. Each value should be a number within [0, 1].
Returns
Porcupine: An instance of Porcupine Wake Word engine.
Throws
PorcupineException: If an error occurs while creating an instance of Porcupine Wake Word engine.
Porcupine.FromKeywordPaths()
Porcupine constructor when using keyword paths.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.keywordPathsIEnumerable<string> : List of absolute paths to keyword model files.modelPathstring : Absolute path to the file containing model parameters (.pv).devicestring : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.sensitivitiesIEnumerable<float> : Sensitivities for detecting keywords. Each value should be a number within [0, 1].
Returns
Porcupine: An instance of Porcupine Wake Word engine.
Throws
PorcupineException: If an error occurs while creating an instance of Porcupine Wake Word engine.
Porcupine.GetAvailableDevices()
Retrieves a list of hardware devices that can be specified when constructing Porcupine.
Returns
string[]: An array of available hardware devices.
Throws
PorcupineException: If an error occurs while retrieving the hardware devices.
Porcupine.Process()
Processes a frame of the incoming audio stream and emits the detection result. The number of samples per frame can be attained 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 keyword models provided to the constructor. If no keyword is detected then it returns -1.
Throws
PorcupineException: If there is an error while processing the audio frame.
Porcupine.FrameLength
Getter for number of audio samples per frame.
Returns
int: Number of audio samples per frame.
Porcupine.SampleRate
Getter for audio sample rate accepted by Picovoice.
Returns
int: Audio sample rate accepted by Picovoice.
Porcupine.Version
Getter for version.
Returns
String: CurrentPorcupineversion.
BuiltInKeyword
List of available built-in wake words.
PorcupineException
Exception thrown if an error occurs within Porcupine Wake Word engine.
Exceptions: