Coder Social home page Coder Social logo

mic-recorder-to-mp3's Introduction

Microphone Recorder to Mp3

Forked from mic-recorder-to-mp3 in order to provide more config options. Record your microphone audio input and get an audio/mp3 file in the end.

Install

Yarn

yarn add @tscole/mic-recorder-to-mp3

npm

npm install @tscole/mic-recorder-to-mp3

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,
  audio: {
    sampleRate: 44100,
    channelCount: 2,
    echoCancellation: false,
    volume: 1.0,
  },
});

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

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

mic-recorder-to-mp3's People

Contributors

djalmaaraujo avatar buzinas avatar philfreo avatar nikolabalaban avatar benmackerras avatar etienne-lelouet avatar tscole avatar

Stargazers

Daniel Nass avatar PlatformKit avatar

Forkers

platform-kit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.