https://github.com/nickklos10/nlp-emotion-detection
An AI web app for detecting emotions in text using OpenAI's GPT-4o-mini model, built with Flask
https://github.com/nickklos10/nlp-emotion-detection
ai flask javascript python
Last synced: 4 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/nlp-emotion-detection
- Owner: nickklos10
- License: apache-2.0
- Created: 2024-08-09T17:17:04.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-08-30T14:31:58.000Z (9 months ago)
- Last Synced: 2024-11-17T07:16:05.565Z (6 months 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
# NLP Emotion Detection Web App
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
- Usage
- API Endpoints
- Contributing
- License### Installation
**Prerequisites**
* Python 3.7 or higher
* pip (Python package installer)
* 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.### Contributing
Contributions are welcome! Please fork the repository and submit a pull request for any improvements, bug fixes, or new features.
### License
This project is licensed under the MIT License. See the LICENSE file for details.