How to send an audio file to an API with Axios?
I'm programming in JavaScript - React Native and I'm stuck on that part.
I want to know how I do this through a script running with node, not html.
var audioFile = fs.createReadStream("./Welcome.wav")
var form = new FormData();
form.append("file", audioFile);
axios.post('https://speech2text-vitor.herokuapp.com/name',
form,
{
headers: {
"Content-Type": "multipart/form-data"
}
}
)
.then(result => {
console.log(result.data)
})
Note: I'm running with nodejs
API in Python:
app = FastAPI()
@app.post("/name", )
async def post_name(file: UploadFile=File(...)):
return file.filename