How to do it...

In this recipe, similar to the previous one, we'll extract some data from Twitter using the Twitter API. When the tweets are received as a stream, the Translation API is called to identify the language of the tweet. If the tweet is not in our target language, we will invoke the Translation API to perform the translation:

  1. Navigate to the Chapter20/translateTweets folder.
  2. To execute the program in an isolated environment, create a virtualenv and install the dependent packages:
$ virtualenv ENV$ source ENV/bin/activate$ pip install -r requirements.txt

The following is the contents of the requirements.txt file:

google-cloud-translate==1.3.0tweepy==3.6.0
  1. The Python code extracts data from Twitter and invokes the Translation ...

Get Building Google Cloud Platform Solutions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.