Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Stop Recording on silence

I want to stop record audio from microphone when silence is detected after 2 seconds,
there is a only function to stop record on event. But how can I detect a silence for 2 seconds and stop recording?

const downloadLink = document.getElementById('download');
const stopButton = document.getElementById('stop');


const handleSuccess = function (stream) {
    const options = {mimeType: 'audio/webm'};
    const recordedChunks = [];
    const mediaRecorder = new MediaRecorder(stream, options);

    mediaRecorder.addEventListener('dataavailable', function (e) {
        if (e.data.size > 0) recordedChunks.push(e.data);
    });

    // Deve stoppare il record quando c'è silenzio
    mediaRecorder.addEventListener('stop', function () {
        $('#microfono-img').removeClass('mic_active');
        downloadLink.href = URL.createObjectURL(new Blob(recordedChunks));
        downloadLink.download = 'acetest.wav';
    });

    stopButton.addEventListener('click', function () {
        mediaRecorder.stop();
    });

    mediaRecorder.start();
};

navigator.mediaDevices.getUserMedia({audio: true, video: false})
    .then(handleSuccess);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!