Using Oxford TTS Service with Python 2.7 and Requests

This is a follow up to a recent post I made about using Project Oxford with Python. If you haven’t used Project Oxford before visit that post and complete the first three steps to acquire a token.

The previous example used Python 3 and urllib which is cool. But I’m more familiar with the requests library and python 2 so I spent some time re-writing the app with requests, and in the process learned what’s actually going on.

The source code can be found here:

And the example from the Project Oxford Official Repo for python 3 can be found here:

The meat of the program is which provides the methods we use in the app to provide an access token and use it to hit the API with our words to digitize.

Here’s a link to it if you’d like to follow along:

Then we take that token and send a POST request with our access Token and specific headers “TTS_HEADERS” and “body” which includes the text to be translated.

After we POST we receive a JSON object that we encode into base 64 and inject into our HTML Template (index.html) using

To run this project:

clone the project
create a virtual env
pip install requirements.txt
visit http://localhost:5555/

This project is ready to be deployed to Azure as a Web App! If you don’t know/care about that you can simply delete all the other files besides and the contents of FlaskWebProject

Let me know if you have any questions or would like to contribute to the next iteration!

What's underneath the Man suit?
What’s underneath the Man suit?

Leave a Reply

Your email address will not be published. Required fields are marked *