https://github.com/nickklos10/AI-emotion-analyzer
An AI web app for detecting emotions in text using OpenAI's GPT-4o-mini model, built with Flask
https://github.com/nickklos10/AI-emotion-analyzer
ai flask javascript python
Last synced: 9 months ago
JSON representation
An AI web app for detecting emotions in text using OpenAI's GPT-4o-mini model, built with Flask
- Host: GitHub
- URL: https://github.com/nickklos10/AI-emotion-analyzer
- Owner: nickklos10
- License: apache-2.0
- Created: 2024-08-09T17:17:04.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-30T14:31:58.000Z (almost 2 years ago)
- Last Synced: 2024-11-17T07:16:05.565Z (over 1 year ago)
- Topics: ai, flask, javascript, python
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AI Emotion Analyzer
This is a web application that detects emotions in text using OpenAI's GPT-4o-mini model. The app is built with Flask for the backend and HTML/CSS/JavaScript for the frontend. It allows users to input text, analyzes the sentiment, and returns the likelihood of each emotion as a percentage.
### Table of Contents
- [`Installation`](#installation)
- [`Usage`](#usage)
- [`API Endpoints`](#api-endpoints)
- [`Deployment`](#deployment)
- [`Contributing`](#contributing)
### Installation
**Prerequisites**
- Python 3.7 or higher
- pip
- Git
**Requirements**
```
pip install flask flask-cors openai
```
**Steps**
1. Clone the repository:
```
git clone https://github.com/nickklos10/NLP-emotion-detecion.git
cd NLP-emotion-detecion
```
2. Create a virtual environment (optional but recommended):
```
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
```
3. Export your API key as an environment variable:
For macOS:
```
export OPENAI_API_KEY='your-api-key-here'
```
For Windows:
```
set OPENAI_API_KEY=your-api-key-here
```
4. Run the Flask application:
```
python server.py
```
5. Access the web app:
Open your browser and go to http://127.0.0.1:4000 to start using the app.
### Usage
- Enter the text you want to analyze in the input field.
- Click the "Run Sentiment Analysis" button.
- The app will display the likelihood of each emotion (anger, disgust, fear, joy, sadness) and highlight the dominant emotion.
### API Endpoints
- GET /: Renders the main HTML page for the application.
- POST /emotionDetector: Accepts text input and returns the likelihood of each emotion and the dominant emotion in a human-readable format.
### Deployment
The application is deployed on `Railway`. You can access it at: [AI Emotion Analyzer](https://nlp-emotion-detection-production.up.railway.app/)
### Contributing
**Contributions are welcome!** Please fork the repository and submit a pull request for any improvements, bug fixes, or new features.