Want to downgrade quality of audio(Overall Bit rate) from 512kbps to 256 kbps in .wav format

171 views Asked by At

Using the below code I am recoding audio in the browser but when I download the audio, I am getting sampleRate : 16000khz SampleBits: 16 Bitrate: 512kb/s. I want to downgrade the bitrate from 512kb/s to 256kb/s. Any help will be appreciated.

const startRecording = () => {
regenerateImageButton.disabled = true;
let constraints = {
  audio: true,
  video: false,
};

recordButton.disabled = true;
stopButton.disabled = false;
pauseButton.disabled = false;

audioContext = new window.AudioContext({
  sampleRate: 16000,
  //bufferLen: 4096
});
console.log("sample rate: " + audioContext.sampleRate);

navigator.mediaDevices
  .getUserMedia(constraints)
  .then(function (stream) {
    console.log("initializing Recorder.js ...");

    gumStream = stream;

    let input = audioContext.createMediaStreamSource(stream);

    recorder = new window.Recorder(input, {
      numChannels: 1,
      sampleBits: 16, // 8 or 16
      //bufferLen: 4096,
      mimeType: "audio/wav",
    });

    recorder.record();
   
    if (stoptime == true) {
      stoptime = false;
      timerCycle();
    }
  })
  .catch(function (err) {
    //enable the record button if getUserMedia() fails
    recordButton.disabled = false;
    stopButton.disabled = true;
    pauseButton.disabled = true;
  });

};

0

There are 0 answers