Translation APIs — Google, Microsoft, Yandex
I have been trying to learn Spanish since almost 2 years now without making any real progress. Not that I am a very slow learner, I am just not focusing into it. I completed few lessons in Duolingo then took a huge break, started again, then took a break again. Eventually I realized I need to do something so that learning Spanish becomes just a part of something I do every day. That’s how I came up with Hello Hola — Learn as you type!.
What if everything I communicated could be translated in real-time. Not possible as I talk in real world, but surely possible in digital world. What if everything I type on Mobile gets translated. So I sat down a weekend building this app on Android. My first preference for Translation API was obviously Google Translate API.
Google Translate API (Cloud Translation API)
Google Translate has a library for Android but I couldn't find the exact piece of code or sample for Android in documentation. After some searching around in StackOverflow I was able to get it to work.
It worked beautifully. The best thing was it would also understand Hindi words in English text. I played around for couple of days before I checked my Google API Console. I realized Google Translate API wasn’t free at all. I mean most Google APIs have some amount free calls but not Google Translate.
So I moved on to look for a translation API that offered free Translations up to some amount of characters. I came across Microsoft Translation API which gave 2 Million Free character Translation per month, followed by $10 per Million Character.
Microsoft Translation API
Most of the examples that you would find online are for older API which depended on Client Id and Client Secret and that no longer works. Microsoft Translation APIs are now based on key that you can get by signing up on Azure Portal in Cognitive Services section.
This time I implemented the translation on server side, so I have control over which translation API. The translation got a bit delayed since I introduce my server too for every call, but it was still working great. Sadly, Microsoft Translation API does not pick up Hindi in English text.
I uploaded the app on play-store and 2 days later it stopped working. I realized with handful of downloads, 2 Million characters were already used up. I moved my package to S1 Standard Tier. I had free $200 Azure credits, so it was manageable for this month. But I had to find an alternative again.
Yandex Translation API
I came across Yandex Translation API, it offered free 1 Million Character per day and a max of 10 Million Characters per month followed by $10 for every million character.
Yandex also requires you to add “Powered by Yandex.Translate” above or below the translated text with link to their website. So I will have to update my apk before I start using Yandex API.
Yandex was the simplest API to implement. Though it too couldn’t pick up Hindi in English text.
Spanish Translation for all three seemed good. I kept cross checking lot of phrases, every one gave similar results. Google Translates supports 104 languages, Yandex around 90 and Microsoft 60. Google does a great job in understanding Hindi in English text which the other 2 doesn’t. Yandex has the best pricing to begin with. I have read great thing about Microsoft’s Speech Translation API which I have yet to try.
One of the problem with all 3 APIs was that translated text was only returned in that native language script. I wanted to also show user it’s transliteration in a script that the user understand. So “How are you” would be translated as “
क्या हाल है” in Hindi but I also wanted to show user “Kya haal hai”. Not sure if I missed something in documentation or this feature is not available through API.