We have completed the testing phase. And Google api has given the most accurate results in testings. So we will be using that in our project. Here are all the Tested Examples.

Using BaniDB locally

I thought of running the BaniDB locally on my device. For this, I cloned the GitHub repo:

https://github.com/KhalisFoundation/banidb-api

Installing openSSL

But npm install was not working as intended. It kept showing me errors that I frankly did not understand. It was related to OpenSSL. Then I started downloading openSSL on my device. I have a windows device. I could not find a direct source from where I can download openSSL for windows. Then i found a post on stackoverflow from where I found a link to download openSSL on windows. There, first two steps were to install PERL and NASM. Then I added them to path. Long story short, it didn't work.

Planning Phase

Me and Simarjot Singh did several online meets where we discussed about the demo project. The layout, flow and tech stack was decided after discussion in these meets. Simarjot Singh, with the help of our mentor Inder Veerji, bought the paid plan of google cloud. So we could use the google-speech-to-text api. Now we have to implement the voice search feature in the Sikhi To The Max app. We can only make changes to the frontend since the app uses BaniDB api as the backend. Obviously we can not put the google-speech-to-text api key in the frontend. So we decided that we will make an intermediate backend. This backend will be made using express. This express app will take audio input and send request to google cloud and return transcript in punjabi. So the frontend will first record audio and send a request to express app that we will develop and after getting the transcript, it will send another request to banidb api to search gurbani. The tech stack that we are using right now is React with TS for frontend and nodeJS for backend.

Making Demo Project

For testing purposes, I also decided to make a simple template in express app. The only error I encountered during the development was in calling google api. I was not using the correct request format. Finally I used the following format and it worked:

Request Body and Request Format
Request Body
const apiKey = process.env.GOOGLE_API_KEY;
const apiEndPoint = `https://speech.googleapis.com/v1/speech:recognize?key=${apiKey}`;

// Set up the request payload for the Google Cloud Speech-to-Text API
const requestBody = {
    audio: {
    content: audioData, // The base64-encoded audio data
    },
    config: {
    encoding: "WEBM_OPUS",
    sampleRateHertz: 48000,
    languageCode: "pa-IN", // Punjabi language code
    },
};
                                
Request Format
const fetchModule = await fetch();
const response = await fetchModule(apiEndPoint, {
    method: "POST",
    headers: {
    "Content-Type": "application/json",
    },
    body: JSON.stringify(requestBody),
});
                                
This code takes one parameter called "audioData" that contains the audio data in base64 form and returns a variable called "transcript" which contains the transcript.

On the frontend side we read the documentation of BaniDB. We are sending requests using search type 2 (Full Word Gurmukhi). After that we are displaying the Name of bani and ang number.

Here is the github repo for the project Khalis Demo.

Hosting Demo Project

Finally I tried to deploy the express app but there seems to be some kind of error on vercel server side. I will resolve it tomorrow.

I was trying to host the express backend on vercel. In the process I even created some new errors in my project. The express router seemed to have stopped working randomly without any reason. It lead to me creating the entire project from scratch again in a new directory. Thankfully it was working fine this time. After all this the thing that I learnt about hosting on Vercel is that Vercel only supports serverless projects.. Although there is official documentation available on how to host express apps on vercel. You can read that documentation by clicking here. But hosting express on vercel only leads to errors.

I hosted my express backend on Render. Here is the Render's Pricing Plans. I used the free plan which allocates 512 MB of RAM and only 0.1 CPU. It also deallocates the resources when we do not send requests to the hosted web service. It is quite inconvinient and slow but it works for the demo for mid term evaluation. Here is the link to the Hosted Demo Backend is here: https://gurbani-search.onrender.com/