A multimodal AI chatbot for emotion detection. EmpathAI is an AI-powered chatbot designed to detect and interpret human emotions through audio and textual inputs. By combining natural language processing (NLP) andspeech signal analysis, the system aims to provide emotionally intelligent interactions.
The project uses:
- Speech analysis to detect pitch, prosody, and emotion.
- Text processing to understand sentiment, intent, and ambiguity.
- Future extensions include facial expression analysis via video input, enabling full multimodal emotion detection.
- This project is a FastAPI microservice for text sentiment analysis using classic machine learning (TF-IDF + Logistic Regression + SVM).
- It can be trained on datasets like GoEmotions.
- Train your own sentiment classifier from a CSV dataset (
text,labelformat). - Predict fine-grained emotions like joyful, angry, hopeful, disappointed.
- Predict top 'k' emotions corresponding to a particular text.
- Lightweight and resource-friendly (no heavy LLMs required).
- Deployable as a Docker container.
git clone https://github.com/rshaurya/Empath-AI.git
cd Empath-AIMake sure you have Python 3.11 installed. To verify installation:
python3.11 --versionIf a version appears, then Python3.11 is installed.
Create a virtual environment:
python3.11 -m venv .venvActivate the environment(Linux/Mac)
source .venv/bin/activateActivate the environement (Windows PowerShell)
.venv\Scripts\activateNavigate to the Empath-AI directory and run the following command to install the requirements:
pip install -r requirements.txtBy now, you must have created a virutal environment, activated it and installed all the dependencies. Follow further steps to run the application.
There are 3 files under train/. Run the following command to merge the 3 .csv files into one:
cat train/goemotions_*.csv > train/goemotions_full.csvThis will create a new file inside train/
The train/goemotions_full.csv has a lot of columns like text, id, author_id, date etc. out of which only text and label are necessary for training our model.
- Run the
bin/re-format-goemotions.pyfile using any code editor or run the following command:
python3.11 bin/re-format-goemotions.pyThis will create a new file, train/goemotions_text_label.csv having only 2 columns i.e. text and label.
To run and test the application run the following command from the project root:
uvicorn app.main:app --reload --port 8000Now open your browser at: http://localhost:8000/docs
This gives you an interactive Swagger UI where you can try training and prediction endpoints.
This is where you can test your API endpoints, just click on a particular end point and click the "Try it out" button. Swagger tells you a lot about your API. It tells you:
- The type of method (GET, POST etc.).
- The parameters required (if any) with its type.
- the response you can expect from the API.
- And the response type in detail.
- In the Swagger UI, select the
/trainendpoint (POST) and click onTry it out. - Keep the default parameter
use_logregasfalse. - Under the
request_bodyupload thegoemotions_text_label.csvfile from your system. - Then click execute. And let it do its magic. The model is being trained!
- This step will create the model
model.joblibin theapp/directory.
- Now, select the
predict/endpoint (POST) and click onTry it out. - Under the
request_bodyedit the values in json:
{
"text": "string",
"top_k": 1
}- Here,
textcontains the sentence for which we have to detect the emotion. Andtop_kmeans the top 1 or 2 or 3 emotions corresponding to the particular text. It controls how many top labels are returned
Response:
{
"text": "I am so happy today!",
"prediction": "joyful"
}Yay! The text sentiment analysis is completed! More features coming soon...