So I have this HTML5 project I'm working on, where I'm converting an iOS app to a web-based one. Accompanying part of the content creation of the app is an audio recording, which I'm trying to replicate in JavaScript without the use of plugins; so far, I've been able to record audio from getUserMedia(), and turn it into a WAV thanks to Recorder.js.
Now, however, I'm a bit lost. I currently have two separate views, one for recording content and one for playing it back, but I don't know how to get the audio exported form Recorder.js into my JSON payload for playback (I'd like to avoid forcing a server upload or client download).
So I guess my specific question is, how do I take the blob object (something I know almost nothing about) made by Recorder.js and turn it into either raw data, or somehow send the File through JSON?
UPDATE: I've decided to try and use the speex.js tool (https://github.com/jpemartins/speex.js) to encode a .OGG (much smaller than a .WAV). However, I'm not really sure how to use it; the demo page didn't seem to work for me, and trying to call the .encode()
function of a Speex object doesn't seem to actually encode the data, I only get zeros in the object fields. Does anyone know of any resources where I can learn how to use this type of tool?
<audio>
tag, that you want to play the recorded audio? If so, I think you don't need recorder.js, you should be able to just "somehow" pass the stream to the<audio>
tag. And what do you mean by raw data? – Spankingundefined
. I think you can read the Blob and access theresult
property of theFileReader
object afterwards.FileReader.readAsText(blob); var text = FileReader.result
– Spankingreader.result
is null (not undefined, my mistake). They don't seem to be reading them in - maybe I need to wait some time before it happens? – FendleyreadyState
. When it is2
, you can accessresult
. UnfortunatelyreadAsText
doesn't have a callback so you probably need to set an interval or a timeout. – Spankingreader.onload = function(data) { console.log(reader.result) }
Next, I simply calledreader.readAsBinaryString(blob)
, which spit a bunch of binary starting with WAVE into my console. – Fendleyonload
event...that makes sense. And yes, this is how wave files start. Looks good to me. – Spanking