If you want to programmatically translate text from one language to another, then the Translation service (translation api) is the right one for you. The Microsoft Translation Service just requires an authentication via a Microsoft Cognitive Services API Key and then you can easily translate text from one language to another. By leveraging the scale and power of Microsoft’s AI supercomputer, specifically the Microsoft Cognitive Toolkit, Microsoft Translator now offers neural network (LSTM) based translation that enables a new decade of translation quality improvement. These neural network models are available for all speech languages through the Microsoft Translator Speech API on the try and compare site
and through the text API by using the ‘generalnn’ category ID.
How do it work?
In this blog post, I’ll quickly describe how to create the translation service and how to use it with Python, Jupyter Notebook, C#, Powershell and Node.js.
Create the translation service in Azure
The translation service is part of the cognitive services and can therefore be found as cognitive service in the Azure portal: For this demo the F0 Free Services is more than capable of supporting the example with over 2Million character being supported.
The creation of the service just takes a few seconds. After the creation, we can check the service and see, that it is globally deployed and it also shows us the endpoint url. The keys can be accessed via the keys link in menu.
Navigate to it and copy one of the keys that are shown there.
Now we are ready to implement a simple python, script that reads text and translates it to another language
Translate text using Python
#install additional libraries to add coloured text to output
!pip install termcolor
!pip install bs4
from termcolor import colored
from bs4 import BeautifulSoup
#Using Python for Text Translation with Microsoft Cognitive Services
# Specify the subscription Key
subscriptionKey = "ENTER YOUR COGNITIVE API KEY"
#Specify URLs for Cognitive Services - Translator Text API
text = "Créez des applications intelligentes et stratégiques avec une plateforme de base de données évolutive et hybride qui intègre tout ce qu'il vous faut : performances in-memory et sécurité avancée pour les analyses au sein de la base de données."