This project is a mobile application that predicts a person's gender and age range based on their voice. It consists of a Flutter application for the frontend and a Python-based backend with machine learning models.
This project was developed as part of the curriculum for the Flutter subject during the fifth semester. It demonstrates the integration of a Flutter mobile frontend with a Python machine learning backend.
The project is organized into two main parts:
frontend/: Contains the Flutter application code, which provides the user interface for recording or uploading an audio file.backend/: Contains the Python Flask server, which handles the audio processing and prediction using pre-trained machine learning models.
- Cross-Platform: Built with Flutter, allowing it to run on both Android and iOS.
- Voice Analysis: Analyzes voice recordings to predict gender and age.
- Simple UI: Easy-to-use interface for selecting and uploading audio files.
- Machine Learning Backend: Utilizes scikit-learn models for prediction.
To run this project, you need to set up both the backend server and the frontend application.
- Flutter SDK
- Python 3.x
- Pip
- Navigate to the
backenddirectory:cd backend - It is recommended to create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install the required Python packages using the provided
requirements.txtfile:pip install -r requirements.txt
- Start the Flask server:
The server will start on
python server.py
http://0.0.0.0:5000.
- Navigate to the
frontenddirectory:cd frontend - Install the Flutter dependencies:
flutter pub get
- Run the application on your connected device or emulator:
flutter run
- The user opens the Flutter app and selects a
.wavor.mp3audio file. - The app sends the audio file to the
/predictendpoint of the backend Flask server. - The Flask server saves the audio file temporarily.
- It uses the
librosalibrary to extract Mel-frequency cepstral coefficients (MFCCs) from the audio. - The extracted features are fed into two pre-trained scikit-learn models (
gender_model.pklandage_model.pkl) to predict the gender and age category. - The predictions are returned to the Flutter app as a JSON response.
- The app parses the response and displays the predicted gender and age to the user.
The machine learning models used in this project were trained in the F_Project.ipynb Jupyter Notebook. The notebook covers the following steps:
- Data Loading and Preprocessing: Loading the dataset and cleaning it for training.
- Feature Extraction: Using
librosato extract MFCCs from the audio files. - Model Training: Training
RandomForestClassifiermodels for both age and gender prediction. - Model Evaluation: Evaluating the models using accuracy scores and cross-validation.
- Model Saving: Saving the trained models to
.pklfiles usingpickle.
Note on the Dataset: The F_Project.ipynb notebook uses the Mozilla Common Voice dataset (cv-corpus-19.0-delta-2024-09-13-en). This dataset is not included in the repository due to its size. To run the notebook, you will need to download the dataset separately and update the file paths in the notebook accordingly.
- Frontend: Flutter, Dart
- Backend: Python, Flask
- Machine Learning: Scikit-learn, Librosa, Numpy, Pandas, Jupyter Notebook
This project is open-sourced under the MIT License. See the LICENSE file for details.