折腾:
【已解决】调用语言识别接口传递wav录音尝试翻译识别出的英文的效果
期间,需要去在Flask服务器端支持
How to Chunked Transfer Audio Stream | Microsoft Docs
提到的:
chunked transfer encoding
关于:Transfer-Encoding: chunked
去看:
How to Chunked Transfer Audio Stream | Microsoft Docs
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.
》
Chunked transfer encoding – Wikipedia
flask rest post
Quickstart — Flask-RESTful 0.2.1 documentation
快速入门 — Flask-RESTful 0.3.1 documentation
flask-restful接收post传参 – CSDN博客
flask rest post binary chunk data
Streaming input and output in Flask · blog
How to upload binary file using PUT? · Issue #1266 · requests/requests
Uploading Files — Flask 1.0.2 documentation
rest – Python POST binary data – Stack Overflow
python – ReSTfully upload file in Flask without multipart/form-data – Stack Overflow
Python Requests库:HTTP for Humans – 再见紫罗兰 – 博客园
Working with Multipart — aiohttp 3.3.2 documentation
flask post receive binary data
[译] 使用 Flask 实现 RESTful API – 阅读 – 掘金
使用 Python & Flask 实现 RESTful Web API – 简书
writing python request using “post” to flask server as binary file – Stack Overflow
python – How to get data received in Flask request – Stack Overflow
->
http://flask.pocoo.org/docs/1.0/api/#flask.Flask.test_request_context
<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.”
->
http://flask.pocoo.org/docs/1.0/api/#flask.Request.files
“files
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.”
一般不建议用这个get_data
且如果form data已经被解析了,此处get_data就返回空了
而且即使用,调用之前,也最好要检查一下length,以防错误访问了不是自己的内存
或许:
<code>len = request.headers["Content-Length"] data=request.stream.read() </code>
可以?
python – How to get the request body bytes in Flask? – Stack Overflow
flask post transfer-encoding chunked
support for HTTP/1.1 Transfer-Encoding: chunked · Issue #367 · pallets/flask
Stream Proxy with Requests | Flask (A Python Microframework)
好像还和gunicorn有关?
反正看起来是和:uWSGI 有关
Document which servers support wsgi.input_terminated · Issue #2547 · pallets/flask
Chunked uploads missing body data. · Issue #2229 · pallets/flask
python – Flask and Transfer-Encoding: chunked – Stack Overflow
Get raw POST body in Python Flask regardless of Content-Type header – Stack Overflow
用:request.get_data()
或:request.stream.read()
python – Getting Flask to accept chunked encoding – Stack Overflow
Python and Chunked transfer encoding – David Jetelina – Medium
“ flask.request.data was empty, because the content-type wasn’t known to it”
-》
HTTP1.1 chunked transfer not supported · Issue #1428 · unbit/uwsgi
flask 源码解析:响应 – cizixs 技术笔记 – SegmentFault 思否
Flask Tutorial – Step By Step > First Steps > Introduction to HTTP
去写代码试试
不过好像还要搞清楚: