Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -9,10 +9,11 @@ drive.mount('/content/drive')
|
|
9 |
|
10 |
from transformers import pipeline
|
11 |
|
12 |
-
#
|
13 |
emotion_classifier = pipeline("text-classification", model="bhadresh-savani/distilbert-base-uncased-emotion")
|
14 |
|
15 |
def detect_emotion(text):
|
|
|
16 |
result = emotion_classifier(text)
|
17 |
emotion = result[0]['label']
|
18 |
confidence = result[0]['score']
|
@@ -87,6 +88,7 @@ def generate_emotional_speech(text, emotion):
|
|
87 |
from IPython.display import Audio, display
|
88 |
|
89 |
def emotion_aware_tts_pipeline(text):
|
|
|
90 |
emotion, confidence = detect_emotion(text)
|
91 |
print(f"Emotion Detected: {emotion} with Confidence: {confidence:.2f}")
|
92 |
|
|
|
9 |
|
10 |
from transformers import pipeline
|
11 |
|
12 |
+
# Initialize the emotion classifier pipeline globally
|
13 |
emotion_classifier = pipeline("text-classification", model="bhadresh-savani/distilbert-base-uncased-emotion")
|
14 |
|
15 |
def detect_emotion(text):
|
16 |
+
# Ensure the emotion_classifier is used properly
|
17 |
result = emotion_classifier(text)
|
18 |
emotion = result[0]['label']
|
19 |
confidence = result[0]['score']
|
|
|
88 |
from IPython.display import Audio, display
|
89 |
|
90 |
def emotion_aware_tts_pipeline(text):
|
91 |
+
# Ensure the emotion_classifier is being accessed globally
|
92 |
emotion, confidence = detect_emotion(text)
|
93 |
print(f"Emotion Detected: {emotion} with Confidence: {confidence:.2f}")
|
94 |
|