1.0.9 • Published 11 months ago
record-audio-web v1.0.9
record-audio-web
record-audio-web is a lightweight and easy-to-use npm package that allows you to record audio directly from the microphone within a web browser. It offers basic controls for starting and stopping the recording process with minimal setup, making it ideal for projects that need quick and straightforward audio capture.
For more advanced use cases, record-audio-web includes features that enable recording to start automatically when sound is detected, based on customizable decibel levels. This smart detection system ensures that recording begins only when someone is speaking and stops when there is silence, providing a seamless and efficient recording experience.
Installation
You can install the package via npm:
npm install record-audio-web
Import
const recordAudio = requir('record-audio-web');
import recordAudio from 'record-audio-web';
Examples
const Record = new recordAudio();
// Start recording
Record.start();
// Stop recording
Record.stop();
// Start recording after detecting sound above 30 dB for more than one second, and stop recording when the sound drops below 25 dB for two seconds.
Record.auto(
start:{
millisecondsToWait: 1000,
decibels: 30
},
stop: {
millisecondsToWait: 2000,
decibels: 25
},
callback: (info) => { console.log(info)}
)
// *The callback return 'start' and 'stop' strings
// Download automatically
Record.downloadAudio("myAudio.webm");
// Get the Blob URL
Record.getDownloadBlobURL();