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?