Computers have always struggled with providing polished translations of foreign text, that is until the advent of Deep Learning. Utilizing this technology, the accuracy and quality of translations has improved dramatically. The only problem is that making proper use of this technology can be difficult and time consuming. Most people do not have access to an industrial-grade graphics card or weeks to spare to run the proper AI training. Thankfully, this process only needs to be performed once, and I have already taken care of that for you. Today I am going to demonstrate how to instantly access this AI for Russian to English translations using an API.
So let’s begin by installing this API’s client using pip install.
pip install git+https://github.com/Cloudmersive/Cloudmersive.APIClient.Python.NLP.git
And the next step is to call the function language_translation_translate_rus_to_eng. This will take an input object containing our text string to be translated.
from __future__ import print_functionimport timeimport cloudmersive_nlp_api_clientfrom cloudmersive_nlp_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_nlp_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_nlp_api_client.LanguageTranslationApi(cloudmersive_nlp_api_client.ApiClient(configuration))input = cloudmersive_nlp_api_client.LanguageTranslationRequest() # LanguageTranslationRequest | Input translation requesttry:# Translate Russian to English text with Deep Learning AIapi_response = api_instance.language_translation_translate_rus_to_eng(input)pprint(api_response)except ApiException as e:print("Exception when calling LanguageTranslationApi->language_translation_translate_rus_to_eng: %s\n" % e)
Now run it and you’ll get your translation. How easy was that! So much faster and easier than trying to deal with Deep Learning yourself. Within this same library you will also find functions for translating English back to Russian, as well as other languages.