goPorcupine - Go API

  • Wake Word Detection
  • Local Voice Commands
  • Offline Keyword Spotting
  • Always Listening
  • Voice Activation
  • Linux
  • macOS
  • Windows
  • Go

This document outlines how to integrate the Porcupine wake word engine within an application using its Go API.


  • Go SDK 1.16+
  • On Windows you need to have a gcc (like Mingw) in your path


  • Runs on Linux (x86_64), macOS (x86_64) and Windows (x86_64)
  • Go 1.16+


You can install the latest version of Porcupine into your Go module by running:

go get


To create an instance of the engine you first create a Porcupine struct with the configuration parameters for the wake word engine and then make a call to .Init().

import . ""
porcupine := Porcupine{BuiltInKeywords: []BuiltInKeyword{PICOVOICE}}
err := porcupine.Init()
if err != nil {
// handle init fail

In the above example, we've initialized the engine to detect the built-in wake word "Picovoice". Built-in keywords are constants in the package with the BuiltInKeyword type.

Porcupine can detect multiple keywords concurrently

porcupine := Porcupine{BuiltInKeywords: []BuiltInKeyword{PICOVOICE, BUMBLEBEE}}
err := porcupine.Init()

To detect non-default keywords, use KeywordPaths parameter instead

porcupine := Porcupine{KeywordPaths: []string{"/path/to/keyword.ppn"}}
err := porcupine.Init()

The sensitivity of the engine can be tuned per keyword using the sensitivities parameter

porcupine := Porcupine{
BuiltInKeywords: []BuiltInKeyword{PICOVOICE, BUMBLEBEE}
Sensitivities: []float32{0.4, 0.9}}
err := porcupine.Init()

Sensitivity is the parameter that enables trading miss rate for the false alarm rate. It is a floating point number within [0, 1]. A higher sensitivity reduces the miss rate at the cost of increased false alarm rate.

When initialized, the valid sample rate is given by SampleRate. Expected frame length (number of audio samples in an input array) is given by FrameLength.

To feed audio into Porcupine, use the Process function in your capture loop. You must call Init() before calling Process.

func getNextFrameAudio() []int16{
// get audio frame
for {
keywordIndex, err := porcupine.Process(getNextFrameAudio())
if keywordIndex >= 0 {
// wake word detected!

When done resources have to be released explicitly.


Using a defer call to Delete() after Init() is also a good way to ensure cleanup.

Custom Wake Word

You can create custom Porcupine wake word models using Picovoice Console.

Non-English Wake Words

In order to detect non-English wake words you need to use the corresponding model file. The model files for all supported languages are available here.

Issue with this doc? Please let us know.