goPicovoice Platform — Go API

API Reference for the Picovoice Go SDK (pkg.go.dev).


picovoice.FrameLength

var FrameLength int

Number of audio samples per frame.


picovoice.SampleRate

var SampleRate int

Audio sample rate accepted by Picovoice.


picovoice.PorcupineVersion

var PorcupineVersion string

Version of Porcupine being used by the Picovoice SDK.


picovoice.RhinoVersion

var RhinoVersion string

Version of Rhino being used by the Picovoice SDK.


picovoice.Version

var Version string

Picovoice version.


picovoice.InferenceCallbackType

type InferenceCallbackType func(RhinoInference)

Callback for when Rhino has made an inference. Receives a RhinoInference object.


picovoice.NewPicovoice()

func NewPicovoice(
accessKey string,
keywordPath string,
wakewordCallback WakeWordCallbackType,
contextPath string,
inferenceCallback InferenceCallbackType) Picovoice

Creates a Picovoice struct with default parameters, and the given keyword and context files.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console (https://console.picovoice.ai/).
  • keywordPath string : Absolute path to Porcupine keyword file (.ppn).
  • wakewordCallback WakeWordCallbackType : Function to be called once the wake word has been detected.
  • contextPath string : Absolute path to the Rhino context file (.rhn).
  • inferenceCallback InferenceCallbackType : Function to be called once Rhino has an inference ready.

Returns


picovoice.Picovoice

type Picovoice struct

Struct for the Picovoice End-to-End Voice Platform.


picovoice.Picovoice.AccessKey

var AccessKey string

AccessKey obtained from Picovoice Console (https://console.picovoice.ai/).


picovoice.Picovoice.ContextInfo

var ContextInfo string

Once initialized, stores the source of the Rhino context in YAML format. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.


picovoice.Picovoice.ContextPath

var ContextPath string

Absolute path to the Rhino context file (.rhn).


picovoice.Picovoice.InferenceCallback

var InferenceCallback InferenceCallbackType

Function to be called once Rhino has an inference ready.


picovoice.Picovoice.KeywordPath

var KeywordPath string

Path to Porcupine keyword file (.ppn).


picovoice.Picovoice.PorcupineModelPath

var PorcupineModelPath string

Path to Porcupine model file (.pv).


picovoice.Picovoice.PorcupineSensitivity

var PorcupineSensitivity float32

Sensitivity value for detecting keyword. The value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.


picovoice.Picovoice.RequireEndpoint

var RequireEndpoint bool

If set to false, Rhino does not require an endpoint (chunk of silence) before finishing inference.


picovoice.Picovoice.RhinoModelPath

var RhinoModelPath string

Path to Rhino model file (.pv).


picovoice.Picovoice.RhinoSensitivity

var RhinoSensitivity float32

Inference sensitivity. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate. Sensitivity should be a floating-point number within 0 and 1.


picovoice.Picovoice.WakeWordCallback

var WakeWordCallback WakeWordCallbackType

Function to be called once the wake word has been detected.


picovoice.Picovoice.Delete()

func (picovoice *Picovoice) Delete() error

Releases resources acquired by Picovoice.

Returns

  • error : Error produced by the Picovoice SDK. nil if no error was encountered.

picovoice.Picovoice.Init()

func (picovoice *Picovoice) Init() error

Init function for Picovoice. Must be called before attempting Process.

Returns

  • error : Error produced by the Picovoice SDK. nil if no error was encountered.

picovoice.Picovoice.Process()

func (picovoice *Picovoice) Process(pcm []int16) error

Process a frame of pcm audio with the Picovoice platform. Invokes user-defined callbacks upon detection of wake word and completion of follow-on command inference.

Parameters

  • pcm []int16 : A frame of audio samples.

Returns

  • error : Error produced by the Picovoice SDK. nil if no error was encountered.

picovoice.PicovoiceError

type PicovoiceError struct

Custom error type for errors produced from the Picovoice Go SDK.


picovoice.PicovoiceError.Error()

func (e *PicovoiceError) Error() string

Formats the PicovoiceError into a string.

Returns

  • string : Formatted error string.

picovoice.PvStatus

type PvStatus struct

Status return codes from the Picovoice libraries. Possible values are:

const (
SUCCESS PvStatus = 0
OUT_OF_MEMORY PvStatus = 1
IO_ERROR PvStatus = 2
INVALID_ARGUMENT PvStatus = 3
STOP_ITERATION PvStatus = 4
KEY_ERROR PvStatus = 5
INVALID_STATE PvStatus = 6
RUNTIME_ERROR PvStatus = 7
ACTIVATION_ERROR PvStatus = 8
ACTIVATION_LIMIT_REACHED PvStatus = 9
ACTIVATION_THROTTLED PvStatus = 10
ACTIVATION_REFUSED PvStatus = 11
)

picovoice.WakeWordCallbackType

type WakeWordCallbackType func()

Callback for when a wake word has been detected.


Issue with this doc? Please let us know.