Sentiment-Analysis / README.md
Osama-Ahmed-27's picture
Update README.md
e841a30 verified
metadata
title: Sentiment Analysis
emoji: 🏒
colorFrom: red
colorTo: blue
sdk: docker
pinned: false
license: mit
short_description: 'This project is a Sentiment, Emotion, and Tone Analysis API '

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

🎯 Overview

This project is a Sentiment, Emotion, and Tone Analysis API powered by NLP + Speech Recognition. It provides a simple way to analyze any text or voice input and outputs three key psychological indicators:

Sentiment β†’ Overall polarity of the text (positive/negative/neutral)

Emotion β†’ Emotional undertone detected (positive/negative/neutral)

Tone β†’ Financial/business tone detection using FinBERT (positive/negative/neutral)

The system returns a clean JSON output with numeric scores in the range -1 to +1, where:

Positive β†’ +value

Negative β†’ -value

Neutral β†’ 0

Example output:

[ { "sentiment": -0.3, "emotion": -0.62, "tone": -1.0 } ]

πŸ”‘ Features

Text Analysis

Input plain text and get instant sentiment, emotion, and tone scores.

Voice Analysis

Upload a WAV/AIFF audio file.

The system transcribes it (using speech_recognition free Google Web Speech API).

Runs the transcription through the NLP pipeline.

Unified JSON Output

Strict format for easy integration into any app, dashboard, or pipeline.

Models Used

VADER (NLTK) β†’ Sentiment scoring

tabularisai/multilingual-sentiment-analysis (Hugging Face) β†’ Emotion classification

FinBERT (yiyanghkust/finbert-tone) β†’ Business/financial tone detection

πŸ› οΈ Tech Stack

Backend: Python + FastAPI

Libraries: nltk, transformers, torch, SpeechRecognition

Deployment: Hugging Face Spaces (Docker SDK, free CPU)

πŸ“‘ Endpoints

  1. POST /analyze-text

Request:

{ "text": "I love the service but delivery was late." }

Response:

[ { "sentiment": 0.7, "emotion": -0.4, "tone": -0.9 } ]

  1. POST /analyze-voice

Request:

Form-data upload: [email protected]

Response:

[ { "sentiment": -0.2, "emotion": -0.5, "tone": 0.0 } ]

πŸš€ Use Cases

Customer support analysis (detect angry vs happy customers).

Financial news / earnings call tone monitoring.

Social media listening (track public mood & emotions).

Personal productivity apps (journal tone/sentiment analysis).

Call center or chatbot integrations.

⚑ Advantages

βœ… Free & lightweight (no paid API required).

βœ… Works on both text & voice.

βœ… Multilingual support for emotions.

βœ… JSON output with strict schema (easy to integrate).

βœ… Deployable on Hugging Face Spaces for free.