This repo presents an adventure of approaches for converting a number to french format strings(words).
Made using Gradio for two main reasons:
- Gradio provides an excellet UI for easily accessing the application with required parameters.
- For integrating the Speech Recognition(Whisper-Base) and Text-To-Speech(Google TTS) models for converting the spoken numbers to their french audio representations.
This application has TWO core functionalities. Their details are as follows:
- Input List of numbers: [MANDATORY] This is a comma separated string that is splitted internally to process one number at a time.
- French Style: [OPTIONAL] Currently two French Styles are followed, select from either of
France-French
orBelgium-french
. Defaults toFrance-French
. - Output Type: [OPTIONAL] Either of
JSON
orLIST
. Defaults toJSON
.- 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.
- if
- 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"
- French Style: [OPTIONAL] Currently two French Styles are followed, select from either of
France-French
orBelgium-french
. Defaults toFrance-French
.
Follow the below steps to run the application in your local machine:
- Clone the repo:
git clone https://github.com/DeathReaper0965/kata-number-convert-french.git
- Navigate to the repo:
cd kata-number-convert-french
- 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) - Activate the environment:
conda activate kata
- Install all required dependencies:
pip install -r requirements.txt
- 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.
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).
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
-
An example with a choice of French-Style as "France" and Output type as "Json"
-
An example showcasing large numbers (upto Milliards/Billions)
-
An example with a choice of French-Style as "Belgium" and Output type as "Json"
-
An example with a choice of French-Style as "France" and Output type as "List"
-
An example showcasing long inputs (large number of numbers to be converted)
-
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
-
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
-
An example with NO Numbers in Spoken Input Audio https://github.com/DeathReaper0965/kata-number-convert-french/assets/11135080/fef1dff8-4a49-423c-850e-96a32e49910c
- Currently supports only the numerical part conversion.
- Decimal part and Fractional numbers conversion to be added.