Porcupine Wake Word
Go API
API Reference for the Porcupine Go SDK (pkg.go.dev).
porcupine.BuiltInKeywords
List of available built-in wake words.
porcupine.FrameLength
Number of audio samples per frame.
porcupine.SampleRate
Audio sample rate accepted by Porcupine.
porcupine.Version
Porcupine version.
porcupine.BuiltInKeyword
Type representing a keyword that is packaged with the Porcupine SDK. Possible values are:
porcupine.BuiltInKeyword.IsValid()
Checks if a given BuiltInKeyword is valid.
porcupine.Porcupine
Struct for the Porcupine Wake Word engine.
porcupine.Porcupine.AccessKey
AccessKey obtained from Picovoice Console (https://console.picovoice.ai/).
porcupine.Porcupine.BuiltInKeywords
List of built-in keywords to use.
porcupine.Porcupine.KeywordPaths
Absolute paths to keyword model files.
porcupine.Porcupine.LibraryPath
Absolute path to the Porcupine's dynamic library.
porcupine.Porcupine.ModelPath
Absolute path to the file containing model parameters.
porcupine.Porcupine.Sensitivities
Sensitivity values 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.
porcupine.Porcupine.Delete()
Releases resources acquired by Porcupine.
Returns
error
: Error produced by the Porcupine SDK.nil
if no error was encountered.
porcupine.Porcupine.Init()
Init function for Porcupine. Must be called before attempting process.
Returns
error
: Error produced by the Porcupine SDK.nil
if no error was encountered.
porcupine.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. Returns a 0 based index if keyword was detected in frame.
Returns -1 if no detection was made.
Parameters
pcm
[]int16 : 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 struct. If no keyword is detected then it returns -1.error
: Error produced by the Porcupine SDK.nil
if no error was encountered.
porcupine.PorcupineError
Custom error type for errors produced from the Porcupine Go SDK.
porcupine.PorcupineError.Error()
Formats the Porcupine error into a string.
Returns
string
: Formatted error string.
porcupine.PvStatus
Status return codes from the Porcupine library. Possible values are: