Home  >  Article  >  Web Front-end  >  Create a pronunciation assessment App (Part 1)

Create a pronunciation assessment App (Part 1)

PHPz
PHPzOriginal
2024-08-18 07:01:02969browse

The purpose of this tutorial is to create an application to control the user's pronunciation.

To follow it, you must have knowledge of javascript and more ideally Vue.js 3.

The idea

I recently decided to get back to German. The main difficulty I encounter in this language is pronouncing it correctly. Usually I listen to an example, record myself repeating it and listen to myself again. It's a complicated process and I must admit I don't have a very good ear.

Based on this observation, I wondered if there was an App or an API that could tell me if I was pronouncing a word or a sentence correctly in German! After some investigations and great discoveries, I wanted to code my own App to solve my problem.

Here's how I did it!

Available APIs

After some research, I was able to find Apps that solved my problem. But overall, pronunciation validation was often just an additional function of a paid application (or one that worked with a subscription). I then decided to look for APIs.

Here is the list of APIs that do the job :

  • Google Cloud Speech-to-Text API
  • Microsoft Azure Speech Service
  • iSpeech Pronunciation
  • Speechmatics
  • Speechace
  • Elsa Now
  • SpeechSuper

These APIs are paid but generally allow you to get 2 weeks of access to test and experiment.

Since I wanted to check my pronunciation of German, I chose to test with the SpeechSuper API because it supports several languages ​​including German. Later in the tutorial we will try the Speechace API to demonstrate how easy it is to switch from one API to another depending on your needs.

Definition of the application's ergonomics

The goal is to implement a simple App that allows you to enter a word, record your voice, send the audio recording to the API and display your score.

This is what the application will look like:

Create a pronunciation assessment App (Part 1)

So we will create an application that will present a text field allowing the entry of a word or a sentence. A button will allow you to listen to it.
We then have a button to record our voice, this one will change style when it is in recording mode. Just click on it to stop and send to the API to obtain a pronunciation score.
Once the score is obtained, it is displayed as a tile with a color representing our score, from red to green to orange.

Initialization of the application

The ideal would be to be able to deploy the App as a webapp, but also as a native Android application. For this reason we will use Quasar.

The Quasar framework

Quasar is an open-source Vue.js framework for developing applications with a single codebase. They can be deployed on the web (SPA, PWA, SSR), as a mobile application (Android, iOS) or as a Desktop application (MacOs, Windows, Linux).

Preparation

If this is not already the case, you need to install NodeJS. The better is to use volta as it will allow you to use differents versions of NodeJs depending on your projects.

We will start by initializing our project with the Quasar scaffolding tool.

npm i -g @quasar/cli
npm init quasar

The cli will ask us several questions, choose the following options :

Options List
  • App with Quasar CLI
  • Project folder : learn2speak
  • Quasar v2
  • Javascript
  • Quasar App with Vite
  • Package name : learn2speak
  • Project product name : Learn to speak
  • Project description : Assess your pronounciation
  • Author : yourself
  • CSS preprocessor : Sass with SCSS syntax
  • Features needed :
    • ESLint
    • Axios
  • ESLint preset : Standard
  • Install project dependencies : Yes, use npm

Once the command is executed, you can enter the directory and serve the application locally:

cd learn2speak
npm run dev

Your default browser should open the page at the following address http://localhost:9000

Create a pronunciation assessment App (Part 1)

Modification of the proposed skeleton to obtain the targeted ergonomics

The example application is available, we will remove the elements we do not need. To do this we will open the source code in VSCode (you can of course use another editor)

code .

Layout modification

Quasar provides us with the notion of Layout and then of page included in the latter. The pages and the layout are chosen via the router. For this tutorial, we do not need to know these notions, but you can learn them here: Quasar layout

We do not need drawer, at least not for now so we will delete it from the src/layouts/MainLayout.vue file. To do this, delete the section of the