@picovoice/pvrecorder-node
v1.2.4
Published
Audio recorder sdk for Nodejs.
Downloads
993
Keywords
Readme
PvRecorder Binding for Node.js
PvRecorder
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.
Compatibility
- Node.js 14+
- Runs on Linux (x86_64), macOS (x86_64 and arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5).
Installation
yarn add @picovoice/pvrecorder-node
Usage
Initialize and begin recording:
const { PvRecorder } = require("@picovoice/pvrecorder-node");
const recorder = new PvRecorder(/*frameLength*/ 512);
recorder.start()
(or)
Use get_available_devices()
to get a list of available devices and then initialize the instance based on the index of a device:
const { PvRecorder } = require("@picovoice/pvrecorder-node");
const devices = PvRecorder.getAvailableDevices()
const recorder = new PvRecorder(512, /*device index*/0);
recorder.start()
Read frames of audio:
while (recorder.isRecording) {
// const frame = recorder.readSync(), for synchronous calls
const frame = await recorder.read();
// process audio frame
}
To stop recording, call stop()
on the instance:
recorder.stop();
Once you are done, free the resources acquired by PvRecorder. You do not have to call stop()
before release()
:
recorder.release();
Demos
@picovoice/pvrecorder-demo provides command-line utilities for recording audio to a file.