As per latest updates what is proper way to capture microphone and speaker audio for real time audio processing in background js. I am stuck at this I have tried all media recorder api,record js api and chrome desktop capture but all of them are returning microphone audio. None of them will be able to capture the speaker audio. Please suggest a way to implement this scenario
below is sample code which capture microphone but not speakers:
var audioChunks;
startRecord.onclick = e => {
startRecord.disabled = true;
stopRecord.disabled=false;
// This will prompt for permission if not allowed earlier
navigator.mediaDevices.getUserMedia({audio:true})
.then(stream => {
audioChunks = [];
rec = new MediaRecorder(stream);
rec.ondataavailable = e => {
audioChunks.push(e.data);
if (rec.state == "inactive"){
let blob = new Blob(audioChunks,{type:'audio/x-mpeg-3'});
recordedAudio.src = URL.createObjectURL(blob);
recordedAudio.controls=true;
recordedAudio.autoplay=true;
audioDownload.href = recordedAudio.src;
audioDownload.download = 'mp3';
audioDownload.innerHTML = 'download';
}
}
rec.start();
})
.catch(e=>console.log(e));
}
stopRecord.onclick = e => {
startRecord.disabled = false;
stopRecord.disabled=true;
rec.stop();
}