audio_sentiment / app.py
Mark0047's picture
Create app.py
c8118bc verified
raw
history blame
409 Bytes
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()