Skip to content

DeathReaper0965/kata-number-convert-french

Repository files navigation

Kata: Number to French Converter

This repo presents an adventure of approaches for converting a number to french format strings(words).

Made using Gradio for two main reasons:

  1. Gradio provides an excellet UI for easily accessing the application with required parameters.
  2. For integrating the Speech Recognition(Whisper-Base) and Text-To-Speech(Google TTS) models for converting the spoken numbers to their french audio representations.

Features

This application has TWO core functionalities. Their details are as follows:

First Tab - Accepts the input numbers as a string and returns their french form as outputs

  1. Input List of numbers: [MANDATORY] This is a comma separated string that is splitted internally to process one number at a time.
  2. French Style: [OPTIONAL] Currently two French Styles are followed, select from either of France-French or Belgium-french. Defaults to France-French.
  3. Output Type: [OPTIONAL] Either of JSON or LIST. Defaults to JSON.
    • if JSON is selected, a Dictionary of values corresponding to each input number is displayed.
    • if LIST is selected, a List of values are displayed in the given order of the input.

Second Tab - Accepts the input numbers as Speech and returns the French Form of them as a Speech

  1. Record: [MANDATORY] Speak through your microphone in the form of "Convert the numbers << Some Numbers here >> to their French Form"
    • Example: "Convert the numbers 45 and 999 to their French Forms"
  2. French Style: [OPTIONAL] Currently two French Styles are followed, select from either of France-French or Belgium-french. Defaults to France-French.

Installation

Follow the below steps to run the application in your local machine:

  1. Clone the repo: git clone https://github.com/DeathReaper0965/kata-number-convert-french.git
  2. Navigate to the repo: cd kata-number-convert-french
  3. Create a new python 3.11 environment using: conda create -n kata python=3.11 (This is helpful for separating the application's dependencies from system dependencies)
  4. Activate the environment: conda activate kata
  5. Install all required dependencies: pip install -r requirements.txt
  6. For supporting Speech, we have to install just one more dependency of ffmpeg as it helps us in captuning audio from Microphone. Install it from this page: https://www.ffmpeg.org/download.html

TIP: All the steps from 3-5 can also be done by just executing sh install.sh from terminal. However, you still have to download ffmeg separately.

That's it, we're all done with the installation and all that's left is to start the app.

Start the Application

To start the Gradio app, just execute the below command from the root folder of the repo.
python app.py

Once started, just head over to http://localhost:7860/ in any browser of your choice to see the application in action 😄

NOTE: For the very first call, it may take time for the output as Gradio initializes some necessary cache, downloades the HuggingFace Models, etc. However, all the subsequent calls will be very fast (often within fraction of seconds).

Executing Tests

UnitTest cases are added under the folder tests/. From root folder, execute the test cases using the following command:
python -m unittest discover tests "*.py" -v

Demo Images Using Text

  1. An example with a choice of French-Style as "France" and Output type as "Json" Example-france-french-json

  2. An example showcasing large numbers (upto Milliards/Billions) Example-Milliards

  3. An example with a choice of French-Style as "Belgium" and Output type as "Json" Example-belgium-french-json

  4. An example with a choice of French-Style as "France" and Output type as "List" Example-france-french-list

  5. An example showcasing long inputs (large number of numbers to be converted) Example-Long-Inputs

Demo Videos Using Speech

  1. An example with only a Single Input Number in Spoken Input Audio https://github.com/DeathReaper0965/kata-number-convert-french/assets/11135080/9b76cd47-f4eb-40db-a7d9-48d2d1a45281

  2. An example with Multiple Input Numbers in Spoken Input Audio https://github.com/DeathReaper0965/kata-number-convert-french/assets/11135080/a8998752-90ce-4177-b815-f8a6dd44957f

  3. An example with NO Numbers in Spoken Input Audio https://github.com/DeathReaper0965/kata-number-convert-french/assets/11135080/fef1dff8-4a49-423c-850e-96a32e49910c

Current Limitations and Next Steps

  1. Currently supports only the numerical part conversion.
  2. Decimal part and Fractional numbers conversion to be added.

About

This repo presents an adventure of approaches with run configurations for converting a list of numbers to french format strings(words)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published