I need to POST a .wav file in MULTIPART/FORM-DATA.
my script so far is :
import requests
import json
import wave
def get_binwave(filename):
w = wave.open(filename, "rb")
binary_data = w.readframes(w.getnframes())
w.close()
return binary_data
payload = {
"operating_mode":"accurate",
"model":{
"name":"code"
},
"channels":{
"first":{
"format": "audio_format",
"result_format": "lattice"
}
}
}
multiple_files = [
("json","application/json",json.dumps(payload)),
("first","audio/wave",str(get_binwave("c.wav")))]
r = requests.post("http://localhost:8080", files=multiple_files)
I'm facing two problems:
The .wav file binary is too big, so I'm guessing I need to stream it?
The the server expects the boundary to be = "xxx---------------xxx". How do I set it ?
How do I do all of this properly?