Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
title: Sentiment Analysis
|
3 |
emoji: π’
|
@@ -8,5 +124,4 @@ pinned: false
|
|
8 |
license: mit
|
9 |
short_description: 'This project is a Sentiment, Emotion, and Tone Analysis API '
|
10 |
---
|
11 |
-
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
π― Overview
|
2 |
+
|
3 |
+
This project is a Sentiment, Emotion, and Tone Analysis API powered by NLP + Speech Recognition.
|
4 |
+
It provides a simple way to analyze any text or voice input and outputs three key psychological indicators:
|
5 |
+
|
6 |
+
Sentiment β Overall polarity of the text (positive/negative/neutral)
|
7 |
+
|
8 |
+
Emotion β Emotional undertone detected (positive/negative/neutral)
|
9 |
+
|
10 |
+
Tone β Financial/business tone detection using FinBERT (positive/negative/neutral)
|
11 |
+
|
12 |
+
The system returns a clean JSON output with numeric scores in the range -1 to +1, where:
|
13 |
+
|
14 |
+
Positive β +value
|
15 |
+
|
16 |
+
Negative β -value
|
17 |
+
|
18 |
+
Neutral β 0
|
19 |
+
|
20 |
+
Example output:
|
21 |
+
|
22 |
+
[
|
23 |
+
{
|
24 |
+
"sentiment": -0.3,
|
25 |
+
"emotion": -0.62,
|
26 |
+
"tone": -1.0
|
27 |
+
}
|
28 |
+
]
|
29 |
+
|
30 |
+
π Features
|
31 |
+
|
32 |
+
Text Analysis
|
33 |
+
|
34 |
+
Input plain text and get instant sentiment, emotion, and tone scores.
|
35 |
+
|
36 |
+
Voice Analysis
|
37 |
+
|
38 |
+
Upload a WAV/AIFF audio file.
|
39 |
+
|
40 |
+
The system transcribes it (using speech_recognition free Google Web Speech API).
|
41 |
+
|
42 |
+
Runs the transcription through the NLP pipeline.
|
43 |
+
|
44 |
+
Unified JSON Output
|
45 |
+
|
46 |
+
Strict format for easy integration into any app, dashboard, or pipeline.
|
47 |
+
|
48 |
+
Models Used
|
49 |
+
|
50 |
+
VADER (NLTK) β Sentiment scoring
|
51 |
+
|
52 |
+
tabularisai/multilingual-sentiment-analysis (Hugging Face) β Emotion classification
|
53 |
+
|
54 |
+
FinBERT (yiyanghkust/finbert-tone) β Business/financial tone detection
|
55 |
+
|
56 |
+
π οΈ Tech Stack
|
57 |
+
|
58 |
+
Backend: Python + FastAPI
|
59 |
+
|
60 |
+
Libraries: nltk, transformers, torch, SpeechRecognition
|
61 |
+
|
62 |
+
Deployment: Hugging Face Spaces (Docker SDK, free CPU)
|
63 |
+
|
64 |
+
π‘ Endpoints
|
65 |
+
1. POST /analyze-text
|
66 |
+
|
67 |
+
Request:
|
68 |
+
|
69 |
+
{ "text": "I love the service but delivery was late." }
|
70 |
+
|
71 |
+
|
72 |
+
Response:
|
73 |
+
|
74 |
+
[
|
75 |
+
{ "sentiment": 0.7, "emotion": -0.4, "tone": -0.9 }
|
76 |
+
]
|
77 |
+
|
78 |
+
2. POST /analyze-voice
|
79 |
+
|
80 |
+
Request:
|
81 |
+
|
82 |
+
Form-data upload: [email protected]
|
83 |
+
|
84 |
+
Response:
|
85 |
+
|
86 |
+
[
|
87 |
+
{ "sentiment": -0.2, "emotion": -0.5, "tone": 0.0 }
|
88 |
+
]
|
89 |
+
|
90 |
+
π Use Cases
|
91 |
+
|
92 |
+
Customer support analysis (detect angry vs happy customers).
|
93 |
+
|
94 |
+
Financial news / earnings call tone monitoring.
|
95 |
+
|
96 |
+
Social media listening (track public mood & emotions).
|
97 |
+
|
98 |
+
Personal productivity apps (journal tone/sentiment analysis).
|
99 |
+
|
100 |
+
Call center or chatbot integrations.
|
101 |
+
|
102 |
+
β‘ Advantages
|
103 |
+
|
104 |
+
β
Free & lightweight (no paid API required).
|
105 |
+
|
106 |
+
β
Works on both text & voice.
|
107 |
+
|
108 |
+
β
Multilingual support for emotions.
|
109 |
+
|
110 |
+
β
JSON output with strict schema (easy to integrate).
|
111 |
+
|
112 |
+
β
Deployable on Hugging Face Spaces for free.
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
|
117 |
---
|
118 |
title: Sentiment Analysis
|
119 |
emoji: π’
|
|
|
124 |
license: mit
|
125 |
short_description: 'This project is a Sentiment, Emotion, and Tone Analysis API '
|
126 |
---
|
|
|
127 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|