goLeopard - Go API

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


leopard.SampleRate

var SampleRate int

Audio sample rate accepted by Leopard.


leopard.Version

var Version string

Leopard version.


leopard.Leopard

type Leopard struct

Struct for the Leopard Speech-to-Text engine.


leopard.Leopard.AccessKey

var AccessKey string

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

leopard.Leopard.ModelPath

var ModelPath string

Absolute path to the file containing model parameters.

leopard.Leopard.Delete()

func (leopard *Leopard) Delete() error

Releases resources acquired by Leopard.

Returns

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

leopard.Leopard.Init()

func (leopard *Leopard) Init() error

Init function for Leopard. Must be called before attempting process.

Returns

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

leopard.Leopard.Process()

func (leopard *Leopard) Process(pcm []int16) (string, error)

Processes a given audio data and returns its transcription. The audio needs to have a sample rate equal to .SampleRate and be 16-bit linearly-encoded. This function operates on single-channel audio. If you wish to process data in a different sample rate or format consider using ProcessFile. Returns the inferred transcription.

Returns

  • string : Transcription for the given audio.
  • error : Error produced by the Leopard SDK. nil if no error was encountered.

leopard.Leopard.ProcessFile()

func (leopard *Leopard) ProcessFile(audioPath string) (string, error)

Processes a given audio file and returns its transcription. The file needs to have a sample rate equal to or greater than .SampleRate. The supported formats are: FLAC, MP3, Ogg, Opus, Vorbis, WAV, and WebM. Returns the inferred transcription.

Returns

  • string : Transcription for the given audio file.
  • error : Error produced by the Leopard SDK. nil if no error was encountered.

leopard.LeopardError

type LeopardError struct

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


leopard.LeopardError.Error()

func (e *LeopardError) Error() string

Formats the Leopard error into a string.

Returns

  • string : Formatted error string.

leopard.PvStatus

type PvStatus struct

Status return codes from the Leopard library. 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
)

Issue with this doc? Please let us know.