Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio signal drops in audio recording using webaudioapi and recorder.js #214

Open
VijayDhake opened this issue Feb 24, 2023 · 0 comments
Open

Comments

@VijayDhake
Copy link

I am recording audio using web audio API and recorder.js but when I download the audio and checked this audio spectrogram. I have found signals dropped for some milliseconds. Not getting any solution. Can somebody tell me what changes I should make in the code? Any help will be appreciated.

    let gumStream = null;
    let recorder = null;
    let audioContext = null;

  let recordButton = document.getElementById("recordButton");
  let stopButton = document.getElementById("stopButton");
  let pauseButton = document.getElementById("pauseButton");

    const startRecording = () => {
      let constraints = {
        audio: true,
        video: false,
      };
      timer.style.color = "#78CF4D"
      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
          timer.style.color = "#7C7F85"
          recordButton.disabled = false;
          stopButton.disabled = true;
          pauseButton.disabled = true;
        });
   
  };

audiodrops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant