I've recently been trying to create a some software that will record some speech, change the speech to text, and translate that text to another language. So far, I have accomplished the first two objectives, but I have been really struggling with translation.
I have been trying to use the Microsoft Translator API, and have followed all of the instructions in setting my environment up. I set up a Microsoft Azure Marketplace account, set up a project, enabled the API, and I have been able to use a simple bash command to get my access token:
curl --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken?Subscription-Key=mySubscriptionKey'
I have written a small python script using the requests and argparse libraries that sends the request:
request = {
'appid': ('Bearer ' + token),
'text' : txt,
'from' : 'en',
'to' : 'fr'
}
response = requests.get('https://api.microsofttranslator.com/v2/http.svc', params = request)
Everything seems to go smoothly, and I get a 200 response (which I gather means success), yet when I try to look at the text in the response, hundreds of lines of obscure html are printed out. After looking through a few hundred of the lines (which were, for the most part, listing the dozens of languages I chose NOT to translate my text into) I couldn't find any actually translated text. All of the examples that Microsoft has on their github use the outdated DataMarket website that Microsoft is in the process of discontinuing as the authorization link. Moreover, I couldn't find any examples of the API actually being used - they were all just authorization examples. Using the token with their 'Try it Out' example gives me the correct result (though as an xml file?), so this is definitely a python problem.
So, has anyone used this service before and mind shedding some light on how to interpret or unwrap this response?
Thank you!