Translate French to English with Deep Learning AI in Python
Parlez-vous français? I certainly don’t, but luckily there’s an API for that. The /nlp-v2/translate/language/fra/to/eng may not teach you French, but it can help you understand French text quickly using Deep Learning and Neural NLP to automatically translate it into English. It’s simple & easy to use. Let’s walk through how to leverage this in Python.
As a first step, you can copy the below code snippet to install the Python SDK for this API:
pip install cloudmersive-nlp-api-clientfrom __future__ import print_function
import time
import cloudmersive_nlp_api_client
from cloudmersive_nlp_api_client.rest import ApiException
from pprint import pprint
After that you’ll need to copy the below code to authorize your Cloudmersive API Key:
# Configure API key authorization: Apikey
configuration = cloudmersive_nlp_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
Finally, all that’s left is to copy & paste the callback function code snippet:
# create an instance of the API class
api_instance = cloudmersive_nlp_api_client.LanguageTranslationApi(cloudmersive_nlp_api_client.ApiClient(configuration))
input = cloudmersive_nlp_api_client.LanguageTranslationRequest() # LanguageTranslationRequest | Input translation requesttry:
# Translate French to English text with Deep Learning AI
api_response = api_instance.language_translation_translate_fra_to_eng(input)
pprint(api_response)
except ApiException as e:
print("Exception when calling LanguageTranslationApi->language_translation_translate_fra_to_eng: %s\n" % e)