Reputation: 81
I record audio with my browser and then send a blob file to my server via ajax. I can open it with player and hear my voice. However it is corrupted, despite having a couple of seconds of recording, the player shows the audio is 435 hours long. I want to send it in binary to transcription service and it does not recognize the file in this form. What are my options? Can i somehow fix it with python or set the metadata correctly with js.
mediaRecorder.onstop = function() {
var blob = new Blob(chunks, {'type': 'audio/wav'});
var formData = new FormData();
formData.append('audio', blob, 'audio.wav');
$.ajax({
type: 'POST',
url: 'http://localhost:5000/ajax/get_file/',
data: formData,
processData: false,
contentType: false,
success: function(response) {
console.log(response)
}
});
Upvotes: 0
Views: 1492
Reputation: 42430
Tell the recorder what format to use:
const recorder = new MediaRecorder(stream, {mimeType: 'audio/wav'});
Then don't lie about the format in the blob constructor:
const blob = new Blob(chunks, {type: chunks[0].type});
Upvotes: 1
Reputation: 81
Nevermind, i used Recorder.js instead it has built in wav export. The metadata is set properly now
Upvotes: 0