srisuriyas's picture
Create app.py
0effd85 verified
raw
history blame contribute delete
538 Bytes
import gradio as gr
from transformers import pipeline
# Load model
pipe = pipeline("audio-classification", model="ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition")
# Prediction function
def predict_emotion(audio):
result = pipe(audio)
return result[0]["label"].lower()
# Gradio Interface
interface = gr.Interface(
fn=predict_emotion,
inputs=gr.Audio(type="filepath", label="Upload Audio"),
outputs=gr.Textbox(label="Predicted Emotion"),
title="Audio Emotion Classifier"
)
# Launch
interface.launch()