File size: 409 Bytes
c8118bc
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import gradio as gr
from transformers import pipeline

# Load the model
pipe = pipeline("audio-classification", model="superb/wav2vec2-base-superb-er")
 
def classify_emotion(audio):
    result = pipe(audio, top_k=5)
    return result

# Gradio interface for uploading an audio file
gr.Interface(fn=classify_emotion, inputs=gr.Audio(sources=['upload', 'microphone'], type="filepath"), outputs="text").launch()