Nick021402 commited on
Commit
72de3c7
Β·
verified Β·
1 Parent(s): 5b8f274

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +24 -14
  2. app.py +53 -0
  3. requirements.txt +5 -0
README.md CHANGED
@@ -1,14 +1,24 @@
1
- ---
2
- title: Voice2PersonaAI
3
- emoji: πŸ“š
4
- colorFrom: red
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.30.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: Turn your voice into a personality profile using AI!
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Voice2Persona-AI
3
+ emoji: πŸ”Š
4
+ colorFrom: indigo
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: "3.50.2"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # Voice2Persona-AI
13
+
14
+ Turn your voice into a personality profile using AI!
15
+ Speak or upload a short audio, and get your tone, emotion, and personality vibe revealed.
16
+
17
+ - **Input**: Your voice (5–10 seconds)
18
+ - **Output**: Emotion + Personality Profile
19
+ - **Models Used**: Hugging Face Transformers, Speech Emotion Recognition
20
+ - **Built With**: Gradio + Transformers + Torchaudio
21
+ - **Hosted On**: Hugging Face Spaces
22
+
23
+ > Free, private, and beginner-friendly.
24
+ > AI meets psychology in your pocket.
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torchaudio
3
+ from transformers import pipeline
4
+ import numpy as np
5
+
6
+ # Load model for speech emotion recognition
7
+ emotion_pipeline = pipeline("audio-classification", model="superb/hubert-large-superb-er")
8
+
9
+ # Voice Analysis Logic
10
+ def analyze_voice(audio):
11
+ if audio is None:
12
+ return "Please record or upload your voice."
13
+
14
+ # Get emotion
15
+ results = emotion_pipeline(audio["array"])
16
+ top = max(results, key=lambda x: x["score"])
17
+ emotion = top["label"].capitalize()
18
+ confidence = round(top["score"] * 100, 2)
19
+
20
+ # Personality interpretation (rule-based)
21
+ personality_map = {
22
+ "Happy": "You sound energetic, warm, and approachable. Possibly a social butterfly or a natural leader.",
23
+ "Sad": "You're deep and thoughtful. Often empathetic and emotionally intelligent.",
24
+ "Angry": "You radiate power and confidence. A strong-willed individual who’s not afraid to speak out.",
25
+ "Neutral": "Balanced and calm. Likely introspective and logical in decision-making.",
26
+ "Fearful": "You might be cautious, observant, and sensitive to surroundings.",
27
+ "Disgust": "Sharp-witted with a strong sense of right and wrong.",
28
+ "Surprise": "Curious and spontaneous. You embrace the unexpected with open arms."
29
+ }
30
+
31
+ persona = personality_map.get(emotion, "A unique voice with a unique mind. Hard to label, easy to admire.")
32
+
33
+ return f"""
34
+ ## πŸŽ™οΈ Voice2Persona-AI Report
35
+ **Detected Emotion**: {emotion}
36
+ **Confidence**: {confidence}%
37
+ **Inferred Personality Vibe**:
38
+ {persona}
39
+ """
40
+
41
+ # Gradio UI
42
+ demo = gr.Interface(
43
+ fn=analyze_voice,
44
+ inputs=gr.Audio(source="microphone", type="numpy", label="🎀 Record or Upload Your Voice"),
45
+ outputs=gr.Markdown(),
46
+ title="πŸ”Š Voice2Persona-AI",
47
+ description="Speak for 5–10 seconds and get a fun AI-generated personality profile based on your tone & emotion.",
48
+ theme="soft",
49
+ live=True
50
+ )
51
+
52
+ if __name__ == "__main__":
53
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio==3.50.2
2
+ transformers
3
+ torch
4
+ torchaudio
5
+ librosa