Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,6 @@ import os
|
|
| 5 |
|
| 6 |
# --- Model Loading ---
|
| 7 |
# We switched to 'superb/wav2vec2-base-superb-er' as it's a well-established and public model for emotion recognition.
|
| 8 |
-
# This should resolve the download issues encountered previously.
|
| 9 |
try:
|
| 10 |
classifier = pipeline("audio-classification", model="superb/wav2vec2-base-superb-er")
|
| 11 |
except Exception as e:
|
|
@@ -68,7 +67,8 @@ def predict_emotion(audio_file):
|
|
| 68 |
# Define the Gradio interface
|
| 69 |
iface = gr.Interface(
|
| 70 |
fn=predict_emotion,
|
| 71 |
-
|
|
|
|
| 72 |
outputs=gr.Label(num_top_classes=5, label="Emotion Probabilities"), # This model has 4 emotions + 'no-emotion'
|
| 73 |
title="AI Audio Emotion Detector",
|
| 74 |
description="Upload an audio file or record your voice to detect emotions. This model is trained to recognize 'anger', 'happiness', 'neutral', 'sadness', and 'no-emotion'.",
|
|
|
|
| 5 |
|
| 6 |
# --- Model Loading ---
|
| 7 |
# We switched to 'superb/wav2vec2-base-superb-er' as it's a well-established and public model for emotion recognition.
|
|
|
|
| 8 |
try:
|
| 9 |
classifier = pipeline("audio-classification", model="superb/wav2vec2-base-superb-er")
|
| 10 |
except Exception as e:
|
|
|
|
| 67 |
# Define the Gradio interface
|
| 68 |
iface = gr.Interface(
|
| 69 |
fn=predict_emotion,
|
| 70 |
+
# THIS IS THE CORRECTED LINE:
|
| 71 |
+
inputs=gr.Audio(sources=["microphone", "upload"], type="filepath", label="Upload Audio or Record with Microphone"),
|
| 72 |
outputs=gr.Label(num_top_classes=5, label="Emotion Probabilities"), # This model has 4 emotions + 'no-emotion'
|
| 73 |
title="AI Audio Emotion Detector",
|
| 74 |
description="Upload an audio file or record your voice to detect emotions. This model is trained to recognize 'anger', 'happiness', 'neutral', 'sadness', and 'no-emotion'.",
|