3

I'm working on an app to record audio from a user's microphone and then save the recorded audio server-side. I have seen a few ideas for how to do this, but I haven't gotten any of them to work. The most sense-making attempt is copied below:

javascript (abridged):

var mic = new MediaRecorder(stream,{mimeType: 'audio/webm'});
mic.ondataavailable = sendData;
//recording happens
mic.requestData();
mic.pause();

function sendData(e){
    audioBlob = e.data;
    f = new FormData();
    f.append("file",audioBlob,"audio_filename");
    $.ajax({
         url: "/uploadAudio",
         type: "POST",
         data: f,
         processData: false,
         contentData: false });

Python:

@app.route("/uploadAudo",methods=["POST"])
def uploadAudio():
     f = request.files["file"]

This is as far as I can get because request.files turns up empty. request.form has the content in it, but this is not accessible through the usual means (request.form['file'] doesn't exist).

I appreciate any advice!

Jo S
  • 31
  • 1

0 Answers0