The Microsoft Azure AI Translator Service is an automatic translation tool that offers both single and batch text translation capabilities. Using this service, users can perform real-time translation of text and documents in more than 60 languages. It supports both Neural Machine Translation (NMT) and Statistical Machine Translation (SMT) models.
Understanding the Translator Service
Azure’s AI Translator Service uses Microsoft’s sophisticated AI technologies, which are continuously trained on a variety of texts from the web to provide high-quality translations. It is suitable for applications or services requiring text translation capabilities like multilingual customer support, e-learning platforms, or content localization.
To utilize the Translator service, you need to create a resource in Azure Portal. With the resource, you get an endpoint and a subscription key, both of which you will use to call the Translator service API. Make sure your data conforms to the service input requirements and consider the following:
- The length of the text must not exceed 5,000 characters.
- The content must be plain text. For documents, you are required to extract the plain text first.
Here is an example of how to use the Translator Service API with Python:
import requests
import uuid
import json
subscription_key = 'your_subscription_key'
endpoint = 'https://api.cognitive.microsofttranslator.com/'
path = '/translate'
params = '?api-version=3.0'
params = params + '&from=en'
params = params + '&to=fr'
full_url = endpoint + path + params
headers = {
'Ocp-Apim-Subscription-Key': subscription_key,
'Ocp-Apim-Subscription-Region': 'region',
'Content-type': 'application/json',
'X-ClientTraceId': str(uuid.uuid4())
}
body = [{'text': 'Hello World'}]
request = requests.post(full_url, headers=headers, json=body)
response = request.json()
print(json.dumps(response, sort_keys=True, indent=4, ensure_ascii=False, separators=(',', ': ')))
In this example, we send a POST request to the Translator service to translate ‘Hello World’ from English to French.
Translating Documents
Azure also offers Document Translation, which is a part of the Translator Service, to translate multiple documents at once while preserving the original formatting. You use a translation operation to submit a batch of documents and monitor the operation’s progress and results.
The steps involved in translating documents include:
- Document Input Configuration: Define the source and target languages and the SAS URL of the source documents.
- Start Translation: Submit the configured inputs to start translation and capture the operation ID for tracking.
- Monitor Progress and Retrieve Results: Use the operation ID to periodically check the status until completed.
Here’s a Python example summarizing these steps:
headers = {
'Ocp-Apim-Subscription-Key': subscription_key,
'Content-Type': 'application/json'
}
body = [
{
'source': { 'sourceUrl': 'source_SAS_URL' },
'targets': [
{'targetUrl': 'target_SAS_URL', 'language': 'fr'},
{'targetUrl': 'second_target_SAS_URL', 'language': 'de'}
]
}
]
response = requests.post('https://api.cognitive.microsofttranslator.com/translation/v1.0/batches',
headers=headers, json=body).json()
operation_id = response['id']
status_response = requests.get('https://api.cognitive.microsofttranslator.com/translation/v1.0/batches/{}'.format(operation_id),
headers=headers).json()
print(json.dumps(status_response, sort_keys=True, indent=4, ensure_ascii=False, separators=(',', ': ')))
In this code snippet, source_SAS_URL
, target_SAS_URL
, and second_target_SAS_URL
carry references to the locations of the documents in Azure Blob Storage.
Conclusion
Microsoft Azure AI Translator Service is a powerful tool that offers seamless translation of text and documents across multiple applications. It is an essential part of many applications or services that require multilingual capabilities to foster better communication and improve user experiences. As an AI engineer preparing for the AI-102 exam, understanding this service will greatly boost your knowledge and practical skills in implementing Azure AI solutions.
Practice Test
True or False: Microsoft Azure’s Translator service can translate text into more than 60 languages in real time.
- True
- False
Answer: True
Explanation: Azure’s Translator service indeed can translate text in more than 60 languages in real time, making it a highly effective tool for global communications.
Which of the following is NOT a feature of Azure’s Translator service?
- a) Real-time translations
- b) Batch translations
- c) Text-to-speech conversions
- d) Automatic language detection
Answer: c) Text-to-speech conversions
Explanation: Azure’s Translator service specializes in translating text. Text-to-speech functionality is provided by another Azure service known as Speech Service.
True or False: Azure’s Translator service cannot recognize and translate text within images.
- True
- False
Answer: False
Explanation: Azure’s Translator service can indeed translate text in images, thanks to the Optical Character Recognition (OCR) functionality.
What is needed to use the Microsoft Azure’s Translator service?
- a) Azure account
- b) Translator Text API key
- c) Valid payment method tied to Azure account
- d) All of the above
Answer: d) All of the above
Explanation: All mentioned components are needed to use the Translator service. You need an Azure account, which should have a valid payment method tied to it, and a Translator Text API key.
True or False: The Translator service from Microsoft Azure enables customization of translation models.
- True
- False
Answer: True
Explanation: Azure’s Translator service does allow for customization of translation models to cater to specific requirements of terminology and style.
Which Azure AI service helps to speech enable your applications, tools, and devices?
- a) Translator service
- b) Text Analytics service
- c) Speech service
- d) None of the above
Answer: c) Speech service
Explanation: Azure’s Speech service is used to speech enable your applications, tools, and devices, not the Translator service.
True or False: Azure’s Translator service provides an automatic language detection feature.
- True
- False
Answer: True
Explanation: Azure’s Translator service indeed supports automatic language detection which allows it to identify input language without explicit specifications.
Single select: What is the purpose of the Translator Text Batch API?
- a) Real-time translation
- b) Speech translation
- c) Document translation
- d) None of the above
Answer: c) Document translation
Explanation: Translator Text Batch API is used by Azure’s Translation service for document translation which can handle multiple requests at once.
True or False: The ‘translate’ function in Azure’s Translator service can translate more than one text at once.
- True
- False
Answer: True
Explanation: The ‘translate’ function is designed to be able to translate multiple texts at once, boosting efficiency.
Which of the following is NOT a possible input to the Azure’s Translator service?
- a) Text
- b) HTML
- c) Plain text files
- d) Music files
Answer: d) Music files
Explanation: Azure Translator service accepts text, HTML and plain text files as inputs for translation. It does not support music files.
Interview Questions
What types of files can you use with the Microsoft Azure Translator Text API?
The Microsoft Azure Translator Text API supports several types of files including plain text files (.txt), Word documents (.docx), PowerPoint presentations (.pptx), and Excel workbooks (.xlsx).
What are some of the possible use-cases for the Microsoft Azure Translator service?
The Microsoft Azure Translator service can aid in global communication. It can benefit businesses in translating web pages or business documents, travelers in understanding foreign language content, and developers in building multilingual applications among other possible use cases.
Can the Azure Translator service detect the source language of a given text automatically?
Yes, the Azure Translator service can automatically detect the source language of the text if the ‘from’ parameter is not specified in the Translate API request.
Is it possible to customize the Microsoft Translator service to better suit the needs of a specific business or industry?
Yes, Custom Translator, a feature of the Microsoft Translator service, can be used to build translation models that acknowledge the terminology used in specific industry or business.
How many languages are currently supported by the Azure Translator Text API?
As of the current release, the Azure Translator Text API supports text translation between more than 60 languages.
Can the Translator Text API translate multiple texts in a single request?
Yes, it allows translating multiple texts in a single request. Up to 100 texts or 50,000 total characters can be translated in a single request.
What feature of the Azure Translator service can be used to transliterate text from one script to another?
Azure Translator provides a feature known as Transliteration. It changes text from one script to another, often within the same language.
What response format is returned by the Azure Translator API?
The Translate API returns a JSON array containing a translation object for each text element found in the request.
Can the Translator service be used to recognize and translate printed text in images?
No, the Translator service works only with text. For recognizing and translating printed text in images, other Azure AI services like Computer Vision and Optical Character Recognition (OCR) can be utilized.
What method of translation is used by the Microsoft Translator Text API?
The Microsoft Translator Text API uses neural machine translation (NMT) – an advanced, statistical machine translation method.
How is the billing for the Azure Translator service determined?
Azure Translator service is billed based on the number of characters sent to the service for translation, including whitespaces.
Do you need any special permissions to use the Translator Text API?
Yes, you need the “Translator Text API User” role to use the API.
How can you ensure that your translations comply with your privacy requirements?
To ensure compliance with your privacy requirements, Azure provides a “no-trace” option where your text is not logged on the Translator service side.
Can you get both translations and transliterations in a single Translate API request?
Yes, you can request both translations and transliterations in a single Translate API request by setting “includeTransliteration” to true in your request.
Can the translations provided by the Azure Translator service be used in real-time communication scenarios?
Yes, the Microsoft Azure Translator service can be used in real-time communication scenarios as it provides instantaneous translation of texts.