Picovoice Wordmark
Start Building
Introduction
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNVIDIA JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNVIDIA JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonWebWindows
AndroidCiOSPythonWeb
SummaryOctopus Speech-to-IndexGoogle Speech-to-TextMozilla DeepSpeech
FAQ
Introduction
AndroidAngularArduinoBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNVIDIA JetsonLinuxmacOSMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaMicrocontrollerNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidAngularBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNVIDIA JetsonLinuxmacOSNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidBeagleboneCiOSNVIDIA JetsonLinuxmacOSPythonRaspberry PiRustWebWindows
AndroidCiOSPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidCiOSNVIDIA JetsonLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidCiOSNVIDIA JetsonLinuxmacOSPythonRaspberry PiWebWindows
AndroidCPythoniOSWeb
Introduction
AndroidAngularArduinoBeagleBoneC.NETFlutterlink to GoiOSJavaNVIDIA JetsonMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustUnityVueWeb
AndroidAngularCMicrocontroller.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
Picovoice SDK - FAQ
IntroductionSTM32F407G-DISC1 (Arm Cortex-M4)STM32F411E-DISCO (Arm Cortex-M4)STM32F769I-DISCO (Arm Cortex-M7)IMXRT1050-EVKB (Arm Cortex-M7)
Introduction
AndroidC.NETFlutterlink to GoiOSNodejsPythonReact NativeRustUnityWeb
AndroidC.NETFlutterlink to GoiOSNodejsPythonReact NativeRustUnityWeb
FAQGlossary

Audio Recording
Go Quick Start

Platforms

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

Requirements

  • Go 1.16+
  • Windows only: a gcc compiler like Mingw in $PATH

Quick Start

Setup

  1. Download and install Go language .

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

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

Usage

Initialize and begin recording:

import . "github.com/Picovoice/pvrecorder/sdk/go"
recorder = NewPvRecorder(512)
recorder.Init()
if err != nil {
// handle init error
}
defer recorder.Delete()
err = recorder.Start()
if err != nil {
// handle start error
}

Read a frame of audio:

for {
frame, err := recorder.Read()
if err != nil {
// handle error
}
// do something with frame
}

To stop recording:

recorder.Stop()

Once you are done, free the used resources. You do not have to call Stop() before Delete():

recorder.Delete()

Selecting an Audio Device

To get a list of available audio devices:

devices = GetAvailableDevices() // select index of device

The index of the device in the returned list can be used in Init() to select that device for audio capture:

frameLength := 512
recorder := NewPvRecorder(frameLength)
recorder.DeviceIndex = 0
recorder.Init()
if err != nil {
// handle init error
}
defer recorder.Delete()

Demo

For the PvRecorder Go SDK, we offer a demo application that demonstrates how use PvRecorder to record audio to an output audio file.

Setup

Clone the Porcupine GitHub Repository :

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

Usage

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

cd pvrecorder/demo/go
go run demo.go -h

Run the following to see what devices are available for audio capture:

go run demo.go --show_audio_devices

Run the demo with the desired audio device (or -1 for the default one) and an output file path:

go run demo.go --audio_device_index ${DEVICE_INDEX} --output_wav_path ${OUTPUT_WAV_PATH}

For more information about our PvRecorder demo for Go, head over to our GitHub repository .

Resources

Package

  • pvrecorder on pkg.go.dev

API

  • Go API Docs

GitHub

  • PvRecorder Go SDK on GitHub
  • PvRecorder Go Demos on GitHub

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Audio Recording Go Quick Start
  • Platforms
  • Requirements
  • Quick Start
  • Setup
  • Usage
  • Selecting an Audio Device
  • Demo
  • Setup
  • Usage
  • Resources
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Koala Noise Suppression
  • Eagle Speaker RecognitionBETA
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
  • Orca Text-to-SpeechWAITLIST
  • Falcon Speaker DiarizationWAITLIST
Resources
  • Docs
  • Console
  • Blog
  • Use Cases
Sales & Services
  • Consulting
  • Developer Plan
  • Enterprise Plan
  • Support Add-on
Company
  • About us
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.