0.1.1 • Published 1 year ago
@mymusictaste/async-audiorecorder v0.1.1
@mymusictaste/async-audiorecorder
Requirements
- Node.js version 16 or later
- sox or arecord installed and available
- To install sox on macOS, run
brew install sox
- For Windows, please search the web for installation instructions.
- To install sox on macOS, run
What is @mymusictaste/async-audiorecorder?
- This package extends the
node-audiorecorder
module with an awaitable promise. - It inherits the same caveats as
node-audiorecorder
: it requiressox
,rec
, orarecord
to be installed. - It automatically injects sensible defaults for the program and audio driver based on the platform (Windows, macOS, or Linux).
- It adds a function to list available audio devices (best effort only!).
- Uses
rec
on macOS and Windows, andarecord
on Linux. - On Linux, it returns in
plughw:
format. You can replace it withhw:
on the fly if necessary.
- Uses
- Please let me know if it doesn't work on your system.
Why use @mymusictaste/async-audiorecorder?
node-audiorecorder
was good enough, but this package provides an await and TypeScript-friendly version of it.- You can easily await for
recorder.promise()
to get the audio buffer reliably.
Example usage
import AudioRecorder from "@mymusictaste/async-audiorecorder";
// ...
const list = await AudioRecorder.availableDevices(); // Returns { device: string, label: string }. Use `device`!
const buffer = await recorder.promise();