I am trying out a use case where am sending a blob(.wav) (short audio recorded via Angular) to a FastAPI end point for further processing. I am trying with the UploadFile option on FastApi and it is giving me a 422 (Unprocessable Entity) error.
Angular code
processRecording(blob:any) {
const formData = new FormData();
console.log("Form Data with audio file:",formData);
formData.append('recording',blob);
this.httpClient.post<any>("http://127.0.0.1:8000/postAudio",formData).subscribe(
(response) => {
console.log("Response received :", response);
},
(error) => {
console.log("Error received :", error)
}
Python code
@app.post("/postAudio")
async def postAudio(file:UploadFile = File(...)):
print("Audio received!");
return {'filename':file.filename}
I tried directly providing the blob as a post parameter and that also gave me the same error.
May I please get direction on where I might be going wrong? Thank you