4.9.0 • Published 5 years ago

mic-recorder v4.9.0

Weekly downloads
118
License
MIT
Repository
github
Last release
5 years ago

Microphone Recorder to Mp3/Wav

Record your microphone audio input and get an audio/mp3 or audio/wav file in the end.

Written in TypeScript

Install

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').default;

// or
// import MicRecorder from 'mic-recorder';

// New instance
const recorder = new MicRecorder({
  bitRate: 128,
  encoder: 'mp3', // default is mp3, can be wav as well
  sampleRate: 44100, // default is 44100, it can also be set to 16000 and 8000.
});

// 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()
  .getAudio()
  .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);
  });

Lamejs Notice

This library uses lamejs as a direct dependency. We build our releases with lamejs built-in, so you don't need to add another dependency.

Thanks to @zhuker for writing the lamejs library.

License

MIT

4.9.0

5 years ago

4.8.1

5 years ago

4.8.0

5 years ago

4.8.3

5 years ago

4.8.2

5 years ago

4.5.0

5 years ago

4.4.0

5 years ago

4.7.0

5 years ago

4.6.0

5 years ago

4.1.0

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

4.3.0

5 years ago

4.2.0

5 years ago

4.0.2

5 years ago