Amazon AI: the Christmas post
’Tis the season to be silly^H^H^H^H^Hmerry, so here’s a light-hearted post on how to combine Amazon Rekognition, Amazon Comprehend, Amazon Translate and Amazon Polly for no other reason than to have a little bit of fun.
Surely, that’s all right with you, yeah? ;) As usual, code is available on Github.
Let’s start with a proper business problem: we want to build the capacity to automatically turn billboard text into multi-language speech. No doubt that this has to be a billion dollar business.
Let start with a data sample.

Apparently, this ad did run for a while in Las Vegas before being taken down due to a number of complaints. Complaining about alcohol abuse in Las Vegas??? Consider moving, dude ;)
Anyway, our goal today is to:
- use Rekognition to detect the text on this billboard,
- use Comprehend to detect the language of the text,
- use Translate to translate the text to different languages,
- use Polly to speak the translated text.
Let’s get to work.
Installation
As these services are quite recent, we need to make sure we have the latest AWS Python SDK aka boto3. We’ll also need Pygame to play sounds in a portable way.
pip install boto3 pygame --upgrade
Text detection
Text detection in Amazon Rekognition allows us to detect words, lines and their respective positions in the picture. Here’s, we only care about full lines of text, so we’re going to append all lines into a single string.
Language detection
Amazon Comprehend has a dedicated API for this. We’ll simply call it and return the language code.
Translation
Amazon Translate is straightforward: provide the text string, the source language (detected by Comprehend) and the destination language. We’re returning a text string holding the translation.
Text to speech
Last but not least, let’s use Amazon Polly (combined to Pygame) to speak the translated text.
Putting it all together
OK, here’s our test program. Super simple.
It works great. Here’s the output:
Alcohol: It's cheaper than therapy.
en
Alcohol: Es más barato que la terapia.
É mais barato que terapia.
Alcool : C'est moins cher que la thérapie.
Alkohol: Es ist billiger als Therapie.
We have solved our business problem. No doubt the Executive Committee will be pleased :D
Conclusion
Joking aside (for a minute), I find it pretty amazing that we’re able to build this kind of application with so little code and without knowing anything about AI. Amazon AI rocks!
That’s it for today. Have a great Christmas, everybody. Party like a wild animal if that’s your thing but please stay safe, ok?
Thanks for reading.
The soundtrack to this post? Obvious choice :)