Created
February 4, 2022 00:55
-
-
Save Narigo/08bae596e8e99d9828c407ea6c64ea3c to your computer and use it in GitHub Desktop.
Poor man's recorder - to be used in browsers dev tools; start with recorder.record(); and stop with recorder.stop();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let recorder = await navigator.mediaDevices | |
.getUserMedia({ audio: true }) | |
.then((mediaSourceObject) => { | |
document.createElement("audio").srcObject = mediaSourceObject; | |
const recorder = new MediaRecorder(mediaSourceObject); | |
let data = []; | |
recorder.ondataavailable = (e) => data.push(e.data); | |
recorder.onstop = () => { | |
const blob = new Blob(data, { type: "audio/ogg" }); | |
data = []; | |
console.log(window.URL.createObjectURL(blob)); | |
}; | |
return { | |
record() { | |
recorder.start(); | |
}, | |
stop() { | |
recorder.stop(); | |
}, | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment