Azure Cognitive Services Translator API

24. October 2017 Level300 0

Sometime you want to translate text fields in your internal database. For example you get a pricelist of your best distributor, but all the descriptions are english and your staff want to read the info in spanish or german. Hey they are able to read english, but for better understanding it is better to translate it.

With Azure Cognitive Services you can acces a great number of ready to use services that can help you in that area. Your can leverage the APIs with in your internal script to compare pictures or translate description as mentioned.

Here is a quick sample of how to use the Azure Text Translator API.

clear
# Hello people out there! Today, Stefan did a great job! Isn't it?
# Hallo liebe Zuhörer! Die ExpertsLive Konferenz ist eine tolle Veranstaltung!
$lang = 1
$accountKey = "da5b9391b75247b78860cd5ae6558b68"
$uri = "https://api.cognitive.microsoft.com/sts/v1.0/issueToken?Subscription-Key=$accountKey"
$token = Invoke-RestMethod -Uri $uri -Method Post
$header = @{Authorization = "Bearer "+$token}

$text = Read-Host "Was willst Du übersetzten: "

if ($lang -eq 1) { 
$query = "?text=" + [System.Web.HttpUtility]::UrlEncode($text) + "&from=de&to=en&contentType=text/plain" } else { $query = "?text=" + [System.Web.HttpUtility]::UrlEncode($text) + "&from=en&to=de&contentType=text/plain" }
$uri = "http://api.microsofttranslator.com/v2/Http.svc/Translate" + $query
$ret = Invoke-RestMethod -Uri $uri -Method Get -Headers $header

write-host $ret.string.'#text' -ForegroundColor Red

 

The output will be like that:

clip_image002

 

Brand NEW! For every Azure Trial, this service is for free! (OK, just 2million characters Winking smile

clip_image004

For more information go tot he MSDN Blog Post!

 

I will show that demo at the Experts Live Austria Conference!! Come and join at 7th Nov 2017.

If you read until there use the Promo-Code MPR-100 for a FREE Ticket…

http://www.expertslive.at/blog/10-gruende-fuer-azure-aus-der-praxis