import gradio as gr from transformers import pipeline from datetime import datetime import random # ------------------------------------------------- # 🎯 MODEL INITIALIZATION # ------------------------------------------------- MODEL_NAME = "superb/hubert-large-superb-er" emotion_classifier = pipeline("audio-classification", model=MODEL_NAME) # ------------------------------------------------- # 😄 EMOTION MAP + COLORS # ------------------------------------------------- EMOTION_MAP = { "ang": ("Angry", "😡", "#ff4d4d"), "hap": ("Happy", "😄", "#4caf50"), "neu": ("Neutral", "😐", "#9e9e9e"), "sad": ("Sad", "😢", "#2196f3"), "exc": ("Excited", "🤩", "#ff9800"), "fru": ("Frustrated", "😤", "#f44336"), "fea": ("Fearful", "😨", "#673ab7"), "sur": ("Surprised", "😲", "#00bcd4"), "dis": ("Disgusted", "🤢", "#8bc34a"), } # ------------------------------------------------- # 🧠 EMOTION ANALYSIS # ------------------------------------------------- def analyze_emotion(audio, team, purpose): if audio is None: return "
⚠️ Please record or upload audio first.
", None if team == "Other": team = "Custom/Unspecified" if purpose == "Other": purpose = "Custom/Unspecified" results = emotion_classifier(audio) results = sorted(results, key=lambda x: x["score"], reverse=True) top = results[0] label, emoji, color = EMOTION_MAP.get(top["label"], (top["label"], "🎭", "#607d8b")) score = round(top["score"] * 100, 2) dashboard_html = f"""Detected Emotion Intensity (Confidence)
{insights}
(Demo mode — not stored to any database)
This is a demonstration version created for HR and leadership showcases.
Your voice data is
NOT being saved or shared
anywhere.
Database logging is simulated — you can record or upload audio freely.
✅ Safe to explore and test in this environment.
Analyze uploaded or recorded team meeting audio to understand the emotional tone of employees.
Built for HR and Managers to assess engagement and team well-being.
Awaiting input... Upload or record to begin analysis.
This may take a few seconds depending on file size.
💾 (Demo Mode) Database integration coming soon for Power BI visualization.
Presented by Dhrubo Bhattacharjee