Hello guys, welcome to the 51st session of using Microsoft Word framework Luis and cognitive services tutorial for beginners. In this session, we will learn how to translate text using Azure cognitive service. And now we have used cognitive service packages or project Oxford. But for translation, there is no standardized package, we need to manually send a request to its API and return the response from XML. Here, I have created a new dialog and return tax settings or type and pass it to translate text method. for sending requests, we must need to pass Translation API.
So let us create new Translation API. Fill required details. I have already created it. So let us open it octane, it's key face to Translation API is available globally. So we do not need to care about regenerate endpoint. We need to use these domain names to send a request.
Here translate is the name of the method. The text represents string to be translated from and to represent respecting language code. First of all, we need to generate the URL on which will send a request. Here I want to translate text from English to German. So write it statically. You can also prompt it to a user or store this data in conversation data.
Create using block for HTTP line, we need to pass our key in the request headers. Note that we need to use this parameter name for specifying the key. send a request using data sync method. If we need to pass the URL let us return XML string from the response. create an instance of XML document. Load XML in this returning inner text.
That's it. That is testing Got a new conversation right Hello, we got Hello. Let us try our new code translated text off. Now let us see what we have learned in this session. To translate text required to Translation API is URL pattern for translating text. This APA includes various other methods I have added a link to its documentation.
Even we can perform an operation for all cognitive services in a similar way, because all packages perform this operation in the background. Here I have created an instance of st Repeat lines and send a request and obtain a response in XML. Thanks for watching this video. If you have any doubts, please feel free to contact me. Have a nice day.