Issue
I am trying to recreate a Curl command from the Gentle forced aligner:
https://github.com/lowerquality/gentle
Curl command:
curl -F "[email protected]" -F "[email protected]" "http://localhost:8765/transcriptions?async=false"
Code so far:
import requests
url = 'http://localhost:8765/transcriptions/'
files = {'audio': open('C://Users//user//Desktop//gentle//audio.mp3','rb'), 'transcript':
open('C://Users//andrey_user//Desktop//gentle//words.txt', 'rb')}
headers = {}
response = requests.post(url,
files=files,
headers=headers)
print(response.text)
But it only returns the HTML and says it is a GET request, however the curl command gives me the correct result. Thanks for your help!
Solution
Try this code :
import requests
params = (
('async', 'false'),
)
files = {
'audio': ('audio.mp3', open('audio.mp3', 'rb')),
'transcript': ('words.txt', open('words.txt', 'rb')),
}
response = requests.post('http://localhost:8765/transcriptions', params=params, files=files)
print(response.text)
Answered By - Noé Answer Checked By - Timothy Miller (WPSolving Admin)