Literature Text Translation & Audio Synthesis using Microsoft Azure Cognitive Services
There are millions of literature works around the world and scholars translate it into various languages for people to read and enjoy the same. Sadly, there are still a lot of works which are yet to be translated and the fruits of the work remain untasted by the rest of the world. So, I have developed an Open-source website where literature texts are translated into various languages and the same is available in the audio format using Microsoft Azure Cognitive Services.
About the website ‘Literature Love’:
The website URL: https://bit.ly/azurites
Source Code: https://github.com/Vivek0712/lit-translate-audio
The open-source websites brings in all the literature lovers to share, contribute, read and listen the literature texts translated into various languages and also synthesised into audio format for the same.
THIRUKKURAL:
The Tirukkural, or shortly the Kural, is a classic Tamil language text consisting of 1,330 short couplets of seven words each, or kurals. The user needs to enter the chapter from 1 to 133 to receive the ten kurals of that chapter. The Kural and its Tamil explanation is available through the API. The Tamil explanation is translated into English and Hindi using Microsoft Azure Cognitive Service — Translator API. The original text and the translated texts are available in the Github repo.
The Kurals and their explanations are also available in the Audio format using Microsoft Azure Cognitive Services — Text to Speech API.
How it's done?
Its really easy to get started with this. All you need is experience working with basic HTML,CSS, Javascript and Azure Account (Sign up for a free account!)
Website Techstack: Static Website (HTML,CSS, JS)
Microsoft Azure Services:
1. Azure Static Web App Service
2. Azure Cognitive Service — Translator Python SDK
3. Azure Cognitive Service — Text to Speech API
Let’s get started….
Create Azure Cognitive Services Subscription Key
Login into your Azure Portal and Create a new resource -> Cognitive Service. Fill out the relevant details. Refer here to create the same.
Once the resource is created. Go to the cognitive service resource and under Resource Management → Access Keys & Endpoint and copy the key.
Translation of Kurals and explanation
Copy paste the key and the region in the headers as mentioned in the code.
We are using Azure Cognitive Service — Translator Python SDK. This will fetch the kurals from the API and translate the explanation from tamil to English and Hindi. The whole data is dumped in a JSON file so that it can be used by other developers for future use. The file is available in the Github Repo. This code can be run in Python Notebook in Azure or in your local Python IDE.
Creating the Audio Synthesis for the text translations.
Load the exp.json (thirukkural translation json file) in your Javascript code and add click listener to the button which will invoke the Azure Cognitive Service — Text to Speech API.
We are going to use Microsoft Azure Speech API, which requires us to include the following script file that will be imported through CDN. I have written a playaudio function which will perform Text-to-Speech using Azure Cognitive Service using Speech Synthesis Markup Language (SSML) . SSML gives us freedom to change the Standard voice, language.
Deploy the application in Azure Static Web App
Now that our whole website is ready, its time for the final step: DEPLOYMENT
MYTH: Deployment takes a lot of effort to set-up the environment. I need to buy a custom domain for my website. I need to set up CI/CD for my web app.
All this takes more efforts and time.
FACT: AZURE STATIC WEB APP SERVICE does everything for you.
Azure Static Web App Service is used only for static website (HTML, JS,CSS). If your website is built on some framework, use Azure App Service which is exactly the same.
Deployment can done in steps:
- Create a repository in Github and upload all the source files.
- Go to Azure Portal -> Azure Static Web App (Preview) -> Create
- Enter the relevant details and sign up with your Github Account for the deployment details.
- Select your repo and the branch.
- Create
You application will be deployed along with CI/CD pipelines (using GitHub Actions). You will can find the url of the website here.
Voila, We have successfully deployed our web app which can translate, perform Text-to-speech for the literature texts. You can enjoy reading, listening to Tamil, English and Hindi version of Thirukkural.
How you can contribute to this amazing initiative
As a Literature Lover
If you are a literature lover irrespective of any language, you can help us by contributing the original text of literature to us by filling up this form.
As a reader, you can also enjoy the translated texts and audio books available and share the same with your book reading community, fellow readers etc. You are always welcome to suggest the literature works you want to read by filling this form.
As an API Developer
You can help us by creating APIs for the original literature texts. You can find the original texts in the same Github repo. The APIs will help us to create Translate and Text-to-Speech services in an easier way.
As a Web Developer
You can improve the website by working on developing and maintaining the website (usage of other Web tech stack like MERN etc is welcomed). You are just an issue or pull request away from making a big change towards the initiative.
As a Python/ML Developer
You can help us perform the Translations and Text-to Speech for the literature texts and review the same. On the future run, you can help us creating own ML Models to perform the same. Wanna have a chat or need help getting started, you are always welcomed to ping me in my social media handles.
If you are a beginner in cloud/tech domain who wants to get started with Azure or a professional who is looking forward to more technical sessions and network with other experts, you are always welcome to join our Azure Developer Community but not limited to.
Azure Developer Community — Chennai
Azure Developer Community — Madurai
Azure Developer Community — Coimbatore
Microsoft Reactor — Bengaluru
Microsoft Azure Newsletter
References:
- https://azure.microsoft.com/en-in/services/cognitive-services/text-to-speech/
- https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-synthesis-markup?tabs=csharp
- https://docs.microsoft.com/en-us/azure/cognitive-services/cognitive-services-apis-create-account?tabs=multiservice%2Cwindows
- https://github.com/Azure-Samples/cognitive-services-speech-sdk
- https://en.wikipedia.org/wiki/Tirukku%E1%B9%9Fa%E1%B8%B7
- https://api-thirukkural.web.app
Footnote
If you have made to this far end of the article, clap yourself for your amazing interest in tech, literature and also for this article. Don’t forget to leave comments about this blog, website and I am all ears and that’s how we grow together as a community. Time to hop on to this awesome initiative and let's make this Readers’ world a fun and enjoyable place.
I am always open to hackathons, developer community work, tech, movies, memes :P , feel free to reach out to me in my social handles : LinkedIn, Twitter or let’s go grab a coffee or pizza! xD