File size: 2,575 Bytes
e841a30
 
 
 
 
 
 
 
 
 
 
 
 
 
c85f75b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
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 }
]

2. 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.