I want to receive live audio from a microphone using a web browser and send it to the Node.js server via websockets. I am using the BinaryJS library to send binary data to the server. I am having trouble getting sound samples from a microphone. Here is what I have:
window.AudioContext = window.AudioContext || window.webkitAudioContext; var context = new AudioContext(); var audio = document.querySelector('audio'); navigator.webkitGetUserMedia({audio: true}, function(micstream){ audio.src = window.URL.createObjectURL(micstream); }, errorCallback); }); var errorCallback = function(e){ console.log("Rejected!", e); };
I want some way to get an audio sample every 10 ms so that I can write it to the websocket stream. I am looking for something like this:
function getSample(){
Can someone tell me how to do this? Or is there another way to do this? Thanks!
source share