goRhino — Go Quick Start

Platforms

  • Linux (x86_64)
  • macOS (x86_64, arm64)
  • Windows (x86_64)
  • BeagleBone
  • NVIDIA Jetson Nano
  • Raspberry Pi (2, 3, 4)

Requirements

Picovoice Account & AccessKey

  1. Login or signup for a free account on the Picovoice Console.
  2. Go to the AccessKey tab to create one or use an existing AccessKey. Be sure to keep your AccessKey secret.

Quick Start

Setup

  1. Download and install Go.

  2. Install the Rhino Go Package using the Go CLI:

go get github.com/Picovoice/rhino/binding/go/v2

Usage

Create an instance of Rhino using either a pre-built context file (.rhn) from the Rhino GitHub Repository or a custom context created with the Picovoice Console:

import . "github.com/Picovoice/rhino/binding/go/v2"
rhino := NewRhino(
"${ACCESS_KEY}",
"${CONTEXT_FILE_PATH}")
err := rhino.Init()

Pass in frames of audio to the .Process function:

func getNextAudioFrame() []int16 {
// ..
}
for {
audioFrame := getNextAudioFrame()
isFinalized, err := rhino.Process(audioFrame)
if isFinalized {
inference, err := rhino.GetInference()
if inference.IsUnderstood {
intent := inference.Intent
slots := inference.Slots
// take action based on inferred intent and slot values
} else {
// handle unsupported commands
}
}
}

Release resources explicitly when done with Rhino:

rhino.Delete()

Custom Contexts

Create custom context files using the Picovoice Console. Download the custom context file (.rhn) and pass it into the NewRhino constructor.

Non-English Languages

Use the corresponding model file (.pv) to process non-English contexts. The model files for all supported languages are available on the Rhino GitHub repository.

Pass in the model file using the ModelPath parameter to change the detection language:

rhino := NewRhino(
"${ACCESS_KEY}",
"${CONTEXT_FILE_PATH}")
rhino.ModelPath = "${MODEL_FILE_PATH}"
err := rhino.Init()

Demo

For the Rhino Go SDK, we offer demo applications that demonstrate how to use the Speech-to-Intent engine on real-time audio streams (i.e. microphone input) and audio files.

Setup

Clone the Rhino GitHub Repository:

git clone --recurse-submodules https://github.com/Picovoice/rhino.git

Usage

Use the -h flag to see the usage options for the demo:

cd rhino/demo/go
go run micdemo/rhino_mic_demo.go -h

Ensure you have a working microphone connected to your system and run the following command to make inferences based on the given context file:

go run micdemo/rhino_mic_demo.go -access_key "${ACCESS_KEY}" -context_path "${CONTEXT_FILE_PATH}"

For more information on our Rhino demos for Go, head over to our GitHub repository.

Resources

Packages

API

GitHub

Benchmark


Issue with this doc? Please let us know.