cheetah

package module
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

README

Cheetah Speech-to-Text Engine

Made in Vancouver, Canada by Picovoice

Cheetah is an on-device streaming speech-to-text engine. Cheetah is:

  • Private; All voice processing runs locally.
  • Accurate [1]
  • Compact and Computationally-Efficient [2]
  • Cross-Platform:
    • Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64)
    • Android and iOS
    • Chrome, Safari, Firefox, and Edge
    • Raspberry Pi (4, 3) and NVIDIA Jetson Nano

Compatibility

  • go 1.16+
  • Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), Raspberry Pi (4, 3), and NVIDIA Jetson Nano.

Installation

go get github.com/Picovoice/cheetah/binding/go

AccessKey

Cheetah requires a valid Picovoice AccessKey at initialization. AccessKey acts as your credentials when using Cheetah SDKs. You can get your AccessKey for free. Make sure to keep your AccessKey secret. Signup or Login to Picovoice Console to get your AccessKey.

Usage

Create an instance of the engine and transcribe audio:

import . "github.com/Picovoice/cheetah/binding/go"

cheetah = NewCheetah{AccessKey: "${ACCESS_KEY}"}
err := cheetah.Init()
if err != nil {
    // handle err init
}
defer cheetah.Delete()

func getNextFrameAudio() []int16{
    // get audio frame
}

for {
  partialTranscript, isEndpoint, err = cheetah.Process(getNextFrameAudio())
  if isEndpoint {
    finalTranscript, err = cheetah.Flush()
  }
}

Replace ${ACCESS_KEY} with yours obtained from Picovoice Console. When done be sure to explicitly release the resources using cheetah.Delete().

Demos

Check out the Cheetah Go demos here.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FrameLength Number of audio samples per frame.
	FrameLength int

	// SampleRate Audio sample rate accepted by Picovoice.
	SampleRate int

	// Version Cheetah version
	Version string
)

Functions

This section is empty.

Types

type Cheetah

type Cheetah struct {

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

	// Absolute path to the file containing model parameters.
	ModelPath string

	// Absolute path to Cheetah's dynamic library.
	LibraryPath string

	// Duration of endpoint in seconds. A speech endpoint is detected when there is a
	// chunk of audio (with a duration specified herein) after an utterance without any speech in it. Set to 0
	// to disable endpoint detection.
	EndpointDuration float32

	// Flag to enable automatic punctuation insertion.
	EnableAutomaticPunctuation bool
	// contains filtered or unexported fields
}

Cheetah struct

func NewCheetah

func NewCheetah(accessKey string) Cheetah

NewCheetah returns a Cheetah struct with default parameters

func (*Cheetah) Delete

func (cheetah *Cheetah) Delete() error

Delete releases resources acquired by Cheetah.

func (*Cheetah) Flush

func (cheetah *Cheetah) Flush() (string, error)

Flush marks the end of the audio stream, flushes internal state of the object, and returns any remaining transcribed text. Return any remaining transcribed text. If none is available then an empty string is returned.

func (*Cheetah) Init

func (cheetah *Cheetah) Init() error

Init function for Cheetah. Must be called before attempting process

func (*Cheetah) Process

func (cheetah *Cheetah) Process(pcm []int16) (string, bool, error)

Processes a frame of audio and returns newly-transcribed text and a flag indicating if an endpoint has been detected. Upon detection of an endpoint, the client may invoke `.Flush()` to retrieve any remaining transcription. Returns Any newly-transcribed speech (if none is available then an empty string is returned) and a flag indicating if an endpoint has been detected.

type CheetahError

type CheetahError struct {
	StatusCode PvStatus
	Message    string
}

func (*CheetahError) Error

func (e *CheetahError) Error() string

type PvStatus

type PvStatus int

PvStatus type

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
)

Possible status return codes from the Cheetah library

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL