WAV format audio recorder in browser using WebAudio API
bash
npm i web-audio-recorder-wav
or
yarn add web-audio-recorder-wav
`Usage
$3
`typescript
import { createAudioRecorder } from 'audio-recorder';const recorder = createAudioRecorder();
// Request microphone permission
await recorder.requestMicPermission();
// Start recording
await recorder.startRecording({
sampleRate: 44000,
enableAnalyzeVolume: true,
});
// Stop recording and get result
recorder.stopRecording((blob) => {
const audioUrl = URL.createObjectURL(blob);
// Use the blob or URL as needed
});
`$3
`ts
await recorder.startRecording({
timeSlice: 1000, // Create chunks every 1 second
onDataAvailable: (blob) => {
// Callback called for each chunk
console.log('New chunk available:', blob);
}
});
`$3
`ts
import { createAudioRecorder } from 'audio-recorder';const recorder = createAudioRecorder();
// Request microphone permission first
await recorder.requestMicPermission();
// Start recording with volume analysis enabled
await recorder.startRecording({
enableAnalyzeVolume: true,
});
// Monitor volume in real-time
const checkVolume = () => {
const state = recorder.getState();
console.log('Current volume:', state.volume); // 0 to 1
};
// Start volume monitoring
checkVolume();
// Later: Stop recording
recorder.stopRecording();
``