recorder-mp3
v1.0.0
Published
Aplicacao que permite gravar o audio de browsers diretamente no formato audio/mpeg
Downloads
1
Readme
Microphone Recorder to Mp3
Record your microphone audio input and get an audio/mpeg
file in the end.
Install
Yarn
yarn add mic-recorder
npm
npm install mic-recorder
Development
- Watch for changes:
npm run watch
- Regular build:
npm run build
How to use
const MicRecorder = require('mic-recorder-to-mp3');
// New instance
const recorder = new MicRecorder({
bitRate: 128
});
// Start recording. Browser will request permission to use your microphone.
recorder.start().then(() => {
// something else
}).catch((e) => {
console.error(e);
});
// Once you are done singing your best song, stop and get the mp3.
recorder
.stop()
.getMp3().then(([buffer, blob]) => {
// do what ever you want with buffer and blob
// Example: Create a mp3 file and play
const file = new File(buffer, 'me-at-thevoice.mp3', {
type: blob.type,
lastModified: Date.now()
});
const player = new Audio(URL.createObjectURL(file));
player.play();
}).catch((e) => {
alert('We could not retrieve your message');
console.log(e);
});