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 http://translator.microsoft.com 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
Using Azure Notebooks (Jupyter)
Translate text using C#, dotnet core and Translation API
Using a simple dotnet core application and the command line tools. Visual Studio code and the command line (but the code would by sure also work in a .net 4.x Console Application in VS2017):
Copy and paste the following C# console sample to the Program.cs and replace the APIKEY with the one that you got from the Azure portal:
Save it and then we can run the application via:
Microsoft Cognitive Services http://aka.ms/cognitive
Visual Studio Code – command line options: https://code.visualstudio.com/docs/editor/command-line