miércoles, 13 de enero de 2016

Azure Speak Translator

Would you like to build a powerful online translator which also speaks to you? With both Microsoft Translator and Microsoft Azure services you can build one!

(You can try this application here)

First of all, download this project. You'll need Visual Studio 2015 to open it (get VS 2015 Community Edition for free here!).

Then, go to the Microsoft Azure Marketplace website and look for the Microsoft Translator service.

Sign up and register for the free offer (2 million characters per month).

Now, create and register a new application here in order to get both Client ID and Client Secret values, which you'll use to get access to the translation service from your application.

Open the project in Visul Studio and then open the SpeakTranslator class, which you can find inside the Classes folder of the project. Replace clientId and clientSecret variables with the values that you just registered in the previous step.

Another service that is used in this application is Bitly, a URL shortener service.

Create a bit.ly account here (don't forget to activate it, you'll receive an e-mail to do that). After you sign in, go to the Settings menu, then select Advanced Settings, and finally choose API support, which will allow you to get both your login id and your API Key in order to use the Bitly service in your applications. NOTE: If you don't have access to the new bit.ly portal, you can also get your API Key from here.

Open the Methods class which is inside the Classes folder and then replace the value of both userId and apiKey variables with your Bitly information.

The next step is to test the app. From Visual Studio, Build and then Debug the application. You can write the text which is going to be translated and also select the languages for translation.

For some languages, you can actually listen to your translation! (see the supported languages section).

Moreover, there are several regional languages included in the service, so for example you can listen how an English translation is pronounced the British way. What about comparing both the Mexican and Spanish pronunciations of, well, a text in Spanish?

You can also save the audio file which was generated after translating a text.

Now that we see that our app works, let's publish it to Azure. From the Solution Explorer window, right-click on the project's name and then select Publish.

Select the Microsoft Azure Web Apps option.

In the next screen, either add your Azure account in case you haven't done that or reenter your credentials in case it asks you to do that. Click on New to create a web application which will be hosted on Azure. 

Register the requested information, such as the Web App name (your service will be available in YourWebAppName.azurewebsites.net), App service plan and Resource group (you can either create new ones or select them from the list). For Region, select the one that is closer to your clients's region and select No database for Database server. Click on Create when you're ready in order for the process to start.

Finally, deploy your application to Azure. Just click on Publish and the process will start! If you want, you can change the destination URL or set the configuration (Debug/Release) to be deployed on Settings.

When it finishes, your web application will be opened in your browser.

Add /Pages/TranslationPage.aspx to the URL root and now you can access to the Translation service.

That's great, isn't it? :)

In this tutorial, you deployed an online translator which also allows the user to listen to the translation. Thanks to services such as Microsoft Azure and Microsoft Translator, it is really easy to deploy this kind of applications in minutes! You can also examine the code, particularly the SpeakTranslator class, where all the code required for requesting the Microsoft Translate service is written.

I hope this tutorial has been helpful to you.

No hay comentarios:

Publicar un comentario