Reputation: 15548
Premise: I noticed there a other similar questions but looks like the interesting ones have no answers. e.g. Have a blob for a wav file on client side, how do I send it as a wav file to the server?
I'm using RecordRTC to get a WAV file on user voice input.
What I get is a Blob (binary file) printed (on console) as:
Blob {}
size: 131116
type: "audio/wav"
__proto__
I understand that the Blob contains a WAV audio stream but the WAV is contained by a Blob, rather than a WAV container (i.e. a WAV file). right?
So, how do I extract the WAV stream, e.g. to send it to a server through an ajax/http call?
I don't mind using a HTTP or NodeJS script if it's needed.
EDIT I will try what's been proposed in one answer. Since I'm doing this in AngularJS (I'm still a beginner at it) I'd like to do something like...
services.sendAudioMessage(recordedAudio)
.then(function (data) {
}
where services is defined by a factory:
.factory('services', function($http,$q) {
return {
sendAudioMessage: function (audioMessage) {
return $http.jsonp('http://.../api.php?callback=JSON_CALLBACK', {
params: {
audio: audioMessage
}
})
.then(function (response) {
if (typeof response.data === 'object') {
return response.data;
} else {
return $q.reject(response.data);
}
}, function (response) {
return $q.reject(response.data);
});
}
};
});
rather than using an Ajax call as proposed in: How can javascript upload a blob?
Upvotes: 2
Views: 11556
Reputation: 163232
A Blob is just a binary object in-memory. RecordRTC actually stores a full WAV file with the WAV headers in the Blob for you. It's not just PCM samples, it's a regular WAV file.
You can do something with that data directly or upload to your server like any other blob. See also: https://stackoverflow.com/a/13333478/362536
Upvotes: 2