Var ws = new WebSocket("ws://127.0.0.1:9999") Ĭonsole.log("Openened connection to websocket") Matt created a recorder that can record the output from Web Audio nodes, and that’s exactly what I needed.Īll I needed to do now was connect the stream we just created to the recorder library: Before I started my own work on this I searched around a bit and came across the recoder.js project from here.
With the JavaScriptAudioNode we can create a custom node, which we can use to access the raw data (which is PCM encoded). Luckily, though, we can use a feature from the Web Audio API to get access to the raw data. In future versions this will probably be possible directly from the webrtc API, at this time, however, this isn’t possible yet. With this mediaStreamSource we can do all the nice Web Audio tricks you can see here.īut we don’t want that, we want to record the stream and send it to a backend server for further processing. In this callback we use the Web Audio specification to create a mediaStreamSource from our microphone. If this is successful our callback gets called with the audio stream as its parameter.
#Html5 audio recording example code#
Web developers can use the below HTML5 code to create audio controls and play sound on a web page.