Eden AI Docs
Search…
Machine Translation
Machine translation refers to the translation of a text into another language using rules, statics or ml technics.
post
https://api.edenai.run/v1/pretrained
/translation/automatic_translation
Machine Translation
Supported languages:
Name
Type
Value
Afrikaans
string
af-AF
Albanian
string
sq-SQ
Amharic
string
am-AM
Arabic
string
ar-XA
Armenian
string
hy-HY
Azerbaijani
string
az-AZ
Basque
string
eu-BA
Belarusian
string
be-BE
Bengali
string
bn-BN
Bosnian
string
bs-BS
Bulgarian
string
bg-BG
Catalan
string
ca-ES
Cebuano
string
ceb-CB
Chinese-Simplified
string
zh-CN
Chinese-Traditional
string
zh-TW
Corsican
string
co-CO
Croatian
string
hr-HR
Czech
string
cz-CZ
Danish
string
da-DK
Dutch
string
nl-NL
Here is the list of available providers, the associated parameter values and engines version:
Name
Value
Version
Microsoft Azure
microsoft
v3.0
Amazon Web Services
amazon
boto3 (v1.15.18)
Google Cloud
google
v3
If you want to use Eden AI SDK for Machine Translation, you can just copy paste this code:
Python
PHP
JavaScript
C#
1
# pip install edenai
2
3
from edenai import Translation
4
5
# Get your API key here: https://app.edenai.run/admin/account
6
translation_apis = Translation("Your_API_key")
7
8
result = translation_apis.translation(
9
# Available providers and languages here: https://api.edenai.run/v1/redoc/#operation/Automatic%20Translation
10
text_to_translate= "The text you want to translate",
11
providers=["amazon", "ibm"],
12
source_language="en-US",
13
target_language="fr-FR")
14
15
print(result)
Copied!
1
<?php
2
require_once(__DIR__ . '/vendor/autoload.php');
3
// Configure API key authorization: Bearer
4
$config = edenai\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY');
5
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
6
// $config = edenai\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'Bearer');
7
8
$apiInstance = new edenai\Api\TranslationApi(
9
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
10
// This is optional, `GuzzleHttp\Client` will be used as default.
11
new GuzzleHttp\Client(),
12
$config
13
);
14
$text2 = "text_example"; // string |
15
$source_language2 = "source_language_example"; // string |
16
$target_language2 = "target_language_example"; // string |
17
$providers2 = "providers_example"; // string |
18
$text = "text_example"; // string |
19
$source_language = "source_language_example"; // string |
20
$target_language = "target_language_example"; // string |
21
$providers = "providers_example"; // string |
22
23
try {
24
$result = $apiInstance->automaticTranslation($text2, $source_language2, $target_language2, $providers2, $text, $source_language, $target_language, $providers);
25
print_r($result);
26
} catch (Exception $e) {
27
echo 'Exception when calling TranslationApi->automaticTranslation: ', $e->getMessage(), PHP_EOL;
28
}
29
?>
Copied!
1
import {EdenAiApiDocumentation} from 'eden_ai_api_documentation';
2
let defaultClient = EdenAiApiDocumentation.ApiClient.instance;
3
4
// Configure API key authorization: Bearer
5
let Bearer = defaultClient.authentications['Bearer'];
6
Bearer.apiKey = 'YOUR API KEY';
7
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
8
//Bearer.apiKeyPrefix = 'Token';
9
10
let apiInstance = new EdenAiApiDocumentation.TranslationApi();
11
let text = "text_example"; // String |
12
let sourceLanguage = "sourceLanguage_example"; // String |
13
let targetLanguage = "targetLanguage_example"; // String |
14
let providers = "providers_example"; // String |
15
let text = "text_example"; // String |
16
let sourceLanguage = "sourceLanguage_example"; // String |
17
let targetLanguage = "targetLanguage_example"; // String |
18
let providers = "providers_example"; // String |
19
20
apiInstance.automaticTranslation(text, sourceLanguage, targetLanguage, providers, text, sourceLanguage, targetLanguage, providers, (error, data, response) => {
21
if (error) {
22
console.error(error);
23
} else {
24
console.log('API called successfully. Returned data: ' + data);
25
}
26
});
Copied!
1
using System;
2
using System.Diagnostics;
3
using EdenAI.Api;
4
using EdenAI.Client;
5
using EdenAI.Model;
6
7
namespace Example
8
{
9
public class AutomaticTranslationExample
10
{
11
public void main()
12
{
13
// Configure API key authorization: Bearer
14
Configuration.Default.AddApiKey("Authorization", "YOUR_API_KEY");
15
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
16
Configuration.Default.AddApiKeyPrefix("Authorization", "Bearer");
17
18
var apiInstance = new TranslationApi();
19
var text = text_example; // string | Text to translate
20
var sourceLanguage = sourceLanguage_example; // string | Language code of text (ex: fr (French), en (English), es (Spanish))
21
var targetLanguage = targetLanguage_example; // string | Language code of text (ex: fr (French), en (English), es (Spanish))
22
var providers = providers_example; // string | Provider to compare (ex: [ 'amazon', 'microsoft', 'ibm', 'google'])
23
24
try
25
{
26
InlineResponse2007 result = apiInstance.AutomaticTranslation(text, sourceLanguage, targetLanguage, providers);
27
Debug.WriteLine(result);
28
}
29
catch (Exception e)
30
{
31
Debug.Print("Exception when calling TranslationApi.AutomaticTranslation: " + e.Message );
32
}
33
}
34
}
35
}
Copied!
Copy link