Introduction to Microsoft Translator
Microsoft Translator is a cloud-based machine translation service that provides advanced translation capabilities for text and speech. It's part of the Azure AI services, offering robust, scalable, and secure translation solutions for various applications and scenarios.
Leverage Translator to:
- Translate text between over 100 languages.
- Translate entire documents while preserving formatting.
- Enable real-time speech translation for conversations.
- Customize translation models for specific domains and styles.
Getting Started with Azure Translator
Create Translator Resource
To use the Translator service, you first need to create a Translator resource in your Azure subscription. This resource provides you with an endpoint and subscription key for authentication.
Follow these steps:
- Go to the Azure portal.
- Search for "Translator" and select the service.
- Click "Create".
- Fill in the required details, including subscription, resource group, region, and pricing tier.
- Click "Review + create", then "Create".
Once created, navigate to the resource and find your Key and Endpoint. You will need these for API calls.
Authentication
Translator uses subscription keys for authentication. You can obtain your subscription key from the Azure portal. It's recommended to secure your keys and avoid exposing them directly in client-side code.
When making API requests, include your subscription key in the request header:
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
Quickstart
Here's a simple example using `curl` to translate text:
curl -X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=fr" \
-H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
-H "Content-Type: application/json; charset=UTF-8" \
-d "[{'Text': 'Hello, world!'}]"
This request will return the French translation of "Hello, world!".
Key Features
Text Translation
Translate text seamlessly between numerous languages. The service supports multiple parameters to control the translation process, such as source and target languages, and context.
Endpoint:
https://api.cognitive.microsofttranslator.com/translate
Method:
POST
Parameters:
api-version(required): e.g.,3.0from(optional): Source language code (e.g.,en). If omitted, auto-detection is used.to(required): Target language code (e.g.,es).
Request Body:
[
{"Text": "The quick brown fox jumps over the lazy dog."}
]
Document Translation
Translate entire documents with their formatting preserved. This feature is ideal for translating large volumes of content like reports, articles, or web pages.
The Document Translation API offers asynchronous operations for handling large files efficiently.
Speech Translation
Integrate real-time speech translation into your applications. Convert spoken language into text and then translate it to another language, or directly translate spoken audio.
Customization
Adapt the translation models to your specific needs using the Custom Translator feature. Train custom models with your own data to improve accuracy for specific domains, terminology, and writing styles.
Learn more about Custom Translator.
API Reference
The Microsoft Translator service provides a comprehensive set of REST APIs for all its functionalities.
Languages API
Get a list of all languages supported by the Translator service, along with their display names and locale codes.
Endpoint:
https://api.cognitive.microsofttranslator.com/languages?api-version=3.0&scope=translation
Method:
GET
Translate API
Translate text from one language to another. This is the primary API for text translation.
Endpoint:
https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from={source_language}&to={target_language}
Method:
POST
Transliterate API
Convert text from one script to another (e.g., converting Latin script to Cyrillic script).
Endpoint:
https://api.cognitive.microsofttranslator.com/transliterate?api-version=3.0&language={language}&fromScript={from_script}&toScript={to_script}
Method:
POST
Detect API
Detect the language of a given piece of text.
Endpoint:
https://api.cognitive.microsofttranslator.com/detect?api-version=3.0
Method:
POST
Request Body:
[
{"Text": "Este es un ejemplo."}
]
SDKs
Microsoft provides SDKs for various programming languages to simplify integration with the Translator service.
Using an SDK can abstract away the complexities of direct HTTP requests and provide a more object-oriented interface.
Pricing
Azure Translator pricing is based on the number of text translation characters processed and the number of audio translation minutes. Various pricing tiers are available, including a free tier for testing and low-usage scenarios.
Visit the official Azure Translator pricing page for the most up-to-date information.