How should I convert the following http.client request in Requests library form ? [Python] -


i want convert following http.client request code requests library form.

i tried doing this, stuck thinking body , header both passed in requests.post(url, data=none, json=none, **kwargs). need use requests library, because want make asynchronous.

headers = {"content-type": "application/ssml+xml",            "x-microsoft-outputformat": "audio-16khz-128kbitrate-mono-mp3",            "authorization": "bearer " + access_token,            "x-search-appid": "__id__",            "x-search-clientid": "__id__",            "user-agent": "ttsforpython"} body = "<speak version='1.0' xml:lang='en-us'><voice xml:lang='en-ca' xml:gender='female' name='microsoft server speech text speech voice (en-ca, heatherrus)'>" + text + "</voice></speak>" conn = http.client.httpsconnection("speech.platform.bing.com") conn.request("post", "/synthesize", body, headers) response = conn.getresponse() 

thanks!!

your body, payload, passed data parameter.

headers passed as, um, headers.

r = requests.post(url='http:/speech.platform.bing.com/synthesize',                   data=body,                   headers=headers) 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -