Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the model
|
| 5 |
+
pipe = pipeline("audio-classification", model="superb/wav2vec2-base-superb-er")
|
| 6 |
+
|
| 7 |
+
def classify_emotion(audio):
|
| 8 |
+
result = pipe(audio, top_k=5)
|
| 9 |
+
return result
|
| 10 |
+
|
| 11 |
+
# Gradio interface for uploading an audio file
|
| 12 |
+
gr.Interface(fn=classify_emotion, inputs=gr.Audio(sources=['upload', 'microphone'], type="filepath"), outputs="text").launch()
|