node-audiorecorder with async/await & typescript support
- 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.
- This package extends the node-audiorecorder module with an awaitable promise.
- It inherits the same caveats as node-audiorecorder: it requires sox, rec, or arecord 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, and arecord on Linux.
- On Linux, it returns in plughw: format. You can replace it with hw: on the fly if necessary.
- Please let me know if it doesn't work on your system.
- 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.
``ts
import AudioRecorder from "@mymusictaste/async-audiorecorder";
// ...
const list = await AudioRecorder.availableDevices(); // Returns { device: string, label: string }. Use device!``
const buffer = await recorder.promise();