goPicovoice Platform — Go Quick Start

  • End-to-End Voice Platform
  • Offline Voice Recognition
  • Local Speech Recognition
  • Speech-to-Intent
  • Domain-Specific NLU
  • Wake Word Detection
  • Linux
  • macOS
  • Windows
  • Go

Requirements

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

Compatibility

  • Linux (x86_64)
  • macOS (x86_64)
  • Windows (x86_64)

Cloning the Repository

If using SSH, clone the repository with:

git clone --recurse-submodules [email protected]:Picovoice/picovoice.git

If using HTTPS, then type:

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

Installation

The microphone demo uses malgo for cross-platform audio capture. It requires cgo, which on Windows may mean that you need to install a gcc compiler like Mingw to build it properly.

Usage

NOTE: The working directory for the following go commands is:

cd picovoice/demo/go

File Demo

The file demo allows testing Picovoice on a corpus of audio files. The demo is mainly useful for quantitative performance benchmarking. The following processes a file looking for instances of the wake phrase defined in the file passed to the -keyword_path argument and then infers the follow-on spoken command using the context defined by the file passed to the -context_path argument:

go run filedemo/picovoice_file_demo.go \
-input_audio_path "path/to/input.wav" \
-keyword_path "/path/to/keyword.ppn" \
-context_path "/path/to/context.rhn"

To see all available arguments, use the -h flag:

go run filedemo/picovoice_file_demo.go

Microphone Demo

The microphone demo opens an audio stream from a microphone and detects utterances of a give wake word(s). The following processes incoming audio from the microphone for instances of the wake phrase defined in the file passed to the -keyword_path argument and then infers the follow-on spoken command using the context defined by the file passed to the -context_path argument. Upon completion of the spoken command inference it resumes wake word detection.

go run micdemo/picovoice_mic_demo.go \
-keyword_path "/path/to/keyword.ppn" \
-context_path "/path/to/context.rhn"

To see all available arguments, use the -h flag:

go run micdemo/picovoice_mic_demo.go

It is possible that the default audio input device is not the one you wish to use. There are a couple of debugging facilities baked into the demo application to solve this. First, type the following into the console:

go run micdemo/picovoice_mic_demo.go -show_audio_devices

It provides information about various audio input devices on the box. On a is an example output from a Windows machine:

Capture Devices
0: Microphone Array (Realtek(R) Audio)
1: Microphone (USB Audio Device)

You can use the device index to specify which microphone to use for the demo. For instance, if you want to use the USB microphone in the above example, you can invoke the demo application as below:

go run micdemo/picovoice_mic_demo.go \
-keyword_path "/path/to/keyword.ppn" \
-context_path "/path/to/context.rhn" \
-audio_device_index 1

If the problem persists we suggest storing the recorded audio into a file for inspection. This can be achieved with:

go run micdemo/picovoice_mic_demo.go \
-context_path "/path/to/context.rhn" \
-keyword_path "/path/to/keyword.ppn" \
-audio_device_index 1 \
-output_path ./test.wav

If after listening to stored file there is no apparent problem detected please open an issue.

Create Custom Wake Words & Contexts

You can create custom Porcupine wake word and Rhino context models using Picovoice Console


Issue with this doc? Please let us know.