Crates.io | pv_recorder |
lib.rs | pv_recorder |
version | 1.2.3 |
source | src |
created_at | 2021-09-07 18:22:15.569416 |
updated_at | 2024-09-13 19:59:12.430043 |
description | Rust recorder library for Picovoice |
homepage | |
repository | https://github.com/Picovoice/pvrecorder |
max_upload_size | |
id | 448173 |
size | 8,670,604 |
PvRecorder is an easy-to-use, cross-platform audio recorder designed for real-time speech audio processing. It allows developers access to an audio device's input stream, broken up into data frames of a given size.
To add the pvrecorder library into your app, add pv_recorder
to your app's Cargo.toml
manifest:
[dependencies]
pv_recorder = "*"
Getting the list of input devices does not require an instance:
use pv_recorder::PvRecorderBuilder
let audio_devices = PvRecorderBuilder::default().get_audio_devices()?;
To start recording, initialize an instance using the builder and call start()
:
use pv_recorder::PvRecorderBuilder;
let frame_length = 512;
let recorder = PvRecorderBuilder::new(frame_length).init()?;
recorder.start()?
Read frames of audio:
while recorder.is_recording() {
let frame = recorder.read()?;
// process audio frame
}
To stop recording, call stop()
on the instance:
recorder.stop()?;
The PvRecorder Rust demo is a Rust command-line application that demonstrates how to use PvRecorder to record audio to a file.