Picovoice Wordmark
Start Free
Introduction
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryPicovoice picoLLMGPTQ
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-TextWhisper Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeWeb
SummaryPicovoice CheetahAzure Real-Time Speech-to-TextAmazon Transcribe StreamingGoogle Streaming ASRMoonshine StreamingVosk StreamingWhisper.cpp Streaming
FAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryAmazon PollyAzure TTSElevenLabsOpenAI TTSPicovoice OrcaChatterbox-TTS-TurboKokoro-TTSKitten-TTS-Nano-0.8-INT8Pocket-TTSNeu-TTS-Nano-Q4-GGUFPiper-TTSSoprano-TTSSupertonic-TTS-2ESpeak-NG
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidCiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidCNode.jsPythoniOSWeb
SummaryPicovoice EaglepyannoteSpeechBrain
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice FalconAmazon TranscribeAzure Speech-to-TextGoogle Speech-to-Textpyannote
Introduction
AndroidArduinoCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiReactReact NativeSafariWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeWeb
SummaryPicovoice PorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidArduinoCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiReactReact NativeSafariWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidArduinoC.NETiOSLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSMicrocontrollerNode.jsPythonWeb
SummaryPicovoice CobraWebRTC VADSilero VAD
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
Introduction
AndroidC.NETFlutteriOSNode.jsPythonReact NativeWeb
AndroidC.NETFlutteriOSNode.jsPythonReact NativeWeb
Introduction
C.NETNode.jsPython
C.NETNode.jsPython
FAQGlossary

Audio Recording
C Quick Start

Platforms

  • Linux (x86_64)
  • macOS (x86_64, arm64)
  • Windows (x86_64, arm64)
  • Raspberry Pi (Zero, 3, 4, 5)

Requirements

  • CMake 3.10+.
  • C99 compatible compiler.
  • Windows: MinGW.

Quick Start

Setup

Include the public header files (pv_recorder.h and pv_circular_buffer.h).

Usage

  1. Create a PvRecorder object:
#include "pv_recorder.h"
const int32_t frame_length = 512;
const int32_t device_index = -1; // -1 == default device
const int32_t buffered_frame_count = 10;
pv_recorder_t *recorder = NULL;
pv_recorder_status_t status = pv_recorder_init(
frame_length,
device_index,
buffered_frame_count,
&recorder);
if (status != PV_RECORDER_STATUS_SUCCESS) {
// handle PvRecorder init error
}
  1. Start recording audio:
pv_recorder_status_t status = pv_recorder_start(recorder);
if (status != PV_RECORDER_STATUS_SUCCESS) {
// handle PvRecorder start error
}
  1. Read frames of audio from the recorder:
// must have length equal to `frame_length` that was given to `pv_recorder_init()`
int16_t *frame = malloc(frame_length * sizeof(int16_t));
while (true) {
pv_recorder_status_t status = pv_recorder_read(recorder, frame);
if (status != PV_RECORDER_STATUS_SUCCESS) {
// handle PvRecorder read error
}
// use frame of audio data
// ...
}
  1. Stop recording:
pv_recorder_status_t status = pv_recorder_stop(recorder);
if (status != PV_RECORDER_STATUS_SUCCESS) {
// handle PvRecorder stop error
}
  1. Release resources used by PvRecorder:
pv_recorder_delete(recorder);
free(frame);

Selecting an Audio Device

To print a list of available audio devices:

char **device_list = NULL;
int32_t device_list_length = 0;
pv_recorder_status_t status = pv_recorder_get_available_devices(
&device_list_length,
&device_list);
if (status != PV_RECORDER_STATUS_SUCCESS) {
// handle PvRecorder get audio devices error
}
fprintf(stdout, "Printing devices...\n");
for (int32_t i = 0; i < device_list_length; i++) {
fprintf(stdout, "index: %d, name: %s\n", i, device_list[i]);
}
pv_recorder_free_available_devices(device_list_length, device_list);

The index of the device in the returned list can be used in pv_recorder_init() to select that device for recording.

Demo

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

Setup

  1. Clone the repository:
git clone --recurse-submodules https://github.com/Picovoice/pvrecorder.git
  1. Build the project:
cd demo/c
cmake -S . -B build -DPV_RECORDER_PLATFORM={PV_RECORDER_PLATFORM}
cmake --build build

The {PV_RECORDER_PLATFORM} variable will set the compilation flags for the given platform. Exclude this variable to get a list of possible values.

Usage

To see the usage options for the demo:

./pv_recorder_demo

Get a list of available audio recording devices:

./pv_recorder_demo --show_audio_devices

Record to a file with a given audio device index:

./pv_recorder_demo -o test.wav -d 2

Hit Ctrl+C to stop recording. If no audio device index (-d) is provided, the demo will use the system's default recording device.

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

Resources

API

  • PvRecorder C API Docs

GitHub

  • PvRecorder C SDK on GitHub
  • PvRecorder C Demos on GitHub

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Audio Recording C Quick Start
  • Platforms
  • Requirements
  • Quick Start
  • Setup
  • Usage
  • Selecting an Audio Device
  • Demo
  • Setup
  • Usage
  • Resources
© 2019-2026 Picovoice Inc.PrivacyTerms