chunked transfer encoding
send the audio as one whole chunk or to chop the audio into small chunks
For efficient audio streaming and reducing transcription latency, it is recommended that you use chunked transfer encoding to stream the audio to the service.
flask rest post
flask rest post binary chunk data
flask post receive binary data
<code>* data – The request body, either as a string or a dict of form keys and values. </code>
“* request.files: the files in the body, which Flask keeps separate from form. HTML forms must use enctype=multipart/form-data or files will not be uploaded.”
MultiDict object containing all uploaded files. Each key in files is the name from the <input type=”file”name=””>. Each value in files is a Werkzeug FileStorage object.
It basically behaves like a standard file object you know from Python, with the difference that it also has a save()function that can store the file on the filesystem.
Note that files will only contain data if the request method was POST, PUT or PATCH and the <form> that posted to the request had enctype=”multipart/form-data”. It will be empty otherwise.
See the MultiDict / FileStorage documentation for more details about the used data structure.
“get_data(cache=True, as_text=False, parse_form_data=False)
This reads the buffered incoming data from the client into one bytestring. By default this is cached but that behavior can be changed by setting cache to False.
Usually it’s a bad idea to call this method without checking the content length first as a client could send dozens of megabytes or more to cause memory problems on the server.
Note that if the form data was already parsed this method will not return anything as form data parsing does not cache the data like this method does. To implicitly invoke form data parsing function set parse_form_data to True. When this is done the return value of this method will be an empty string if the form parser handles the data. This generally is not necessary as if the whole data is cached (which is the default) the form parser will used the cached data to parse the form data. Please be generally aware of checking the content length first in any case before calling this method to avoid exhausting server memory.
If as_text is set to True the return value will be a decoded unicode string.”
<code>len = request.headers["Content-Length"] data=request.stream.read() </code>
flask post transfer-encoding chunked
“ flask.request.data was empty, because the content-type wasn’t known to it”