1

I am trying to create a TTS using Fastapi. I am using https://github.com/mattdiamond/Recorderjs/blob/master/src/recorder.js to record the audio and capture it as a blob.

This is my FastAPI enpoints:

@app.post("/secondtry")
async def create_file(file: bytes = File()):
    print("file_size", len(file))
    return {"file_size": len(file)}

@app.post("/thirdtry")
async def create_upload_file(file: UploadFile):
    print("filename", file.filename)
    return {"filename": file.filename}

this is how i am making the call

    rec.exportWAV(function(audio) {

        console.log(audio)
        var xhr = new XMLHttpRequest();
        xhr.open("POST", "https://api.uneduashqiperine.com/secondtry", true);
        xhr.setRequestHeader("content-type", "multipart/form-data" );
        xhr.onload = function(e) {
            // Handle the response.
        }
        xhr.send(audio);
    });

    //create the wav blob and pass it on to createDownloadLink
    rec.exportWAV(createDownloadLink);

The error I get:

{"detail":"Missing boundary in multipart."}

Anybody Can help?

Chris
  • 18,724
  • 6
  • 46
  • 80
  • 1
    Please have a look [here](https://stackoverflow.com/a/74507628/17865804), [here](https://stackoverflow.com/a/70641755/17865804) and [here](https://stackoverflow.com/a/73264904/17865804). – Chris Feb 14 '23 at 13:12

0 Answers0