I have create an Azure Batch Transcription Service which will take audio file from Azure blob storage as input and share the Speech to Text with me.
I am able to achieve the above using the https://eastus.cris.ai/swagger/ui/index#/ website, the curl command which ran successfully was:
curl -X POST "https://eastus.cris.ai/api/speechtotext/v2.0/transcriptions" -H "accept: application/json" -H "Ocp-Apim-Subscription-Key: <my subscription key>" -H "Authorization: <my access token>" -H "Content-Type: application/json" -d "{ \"recordingsUrl\": \"<my azure blob audio file url>\", \"models\": [], \"locale\": \"en-US\", \"name\": \"<Some Name>\", \"description\": \"<Some Description>\", \"properties\": { \"ProfanityFilterMode\": \"Masked\", \"PunctuationMode\": \"DictatedAndAutomatic\" }}"
However if I try to achieve the same programmatically through Python, I get the error as below:
Response [400] {"code":"InvalidPayload","message":"No valid object could be found."}
Here is my code:
import requests
url="https://eastus.cris.ai/api/speechtotext/v2.0/transcriptions"
headers={'accept' : 'application/json','Ocp-Apim-Subscription-Key ':'<my subscription key', 'Authorization' : '<my access token>','Content-Type': 'application/json'}
data={'recordingsUrl' : '<my azure blob audio file url>' ,"models": [], 'locale' : 'en-US', 'name' : '<Some Name>','description' : '<Some Description>','properties' : {'ProfanityFilterMode': 'Masked','PunctuationMode': 'DictatedAndAutomatic'}}
r =requests.post(url,headers=headers,data=data, verify=False)
print(r)
print(r.text)
Let me know if there is some mistake I am making in requests.post