manikanta2026
commited on
Commit
·
3ed80eb
1
Parent(s):
e3c2886
changes2
Browse files
app.py
CHANGED
@@ -45,14 +45,15 @@ def predict_emotion(audio_file):
|
|
45 |
predicted_class = np.argmax(predictions[0])
|
46 |
predicted_emotion = label_encoder.inverse_transform([predicted_class])[0]
|
47 |
|
48 |
-
# Output confidences as floats (0-100),
|
49 |
emotion_probabilities = {
|
50 |
-
label_encoder.inverse_transform([i])[0]: float(pred * 100)
|
51 |
for i, pred in enumerate(predictions[0])
|
52 |
}
|
53 |
|
54 |
return predicted_emotion, emotion_probabilities
|
55 |
|
|
|
56 |
# Gradio interface
|
57 |
iface = gr.Interface(
|
58 |
fn=predict_emotion,
|
|
|
45 |
predicted_class = np.argmax(predictions[0])
|
46 |
predicted_emotion = label_encoder.inverse_transform([predicted_class])[0]
|
47 |
|
48 |
+
# Output confidences as floats (0-100), rounded to 2 decimals
|
49 |
emotion_probabilities = {
|
50 |
+
label_encoder.inverse_transform([i])[0]: round(float(pred) * 100, 2)
|
51 |
for i, pred in enumerate(predictions[0])
|
52 |
}
|
53 |
|
54 |
return predicted_emotion, emotion_probabilities
|
55 |
|
56 |
+
|
57 |
# Gradio interface
|
58 |
iface = gr.Interface(
|
59 |
fn=predict_emotion,
|