| import gradio as gr | |
| from transformers import pipeline | |
| # Cargar el modelo de Hugging Face para an谩lisis de emociones | |
| classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-large") | |
| # Funci贸n para predecir la emoci贸n | |
| def detect_emotion(text): | |
| result = classifier(text) | |
| emotion = result[0]['label'] | |
| return emotion | |
| # Crear la interfaz con Gradio | |
| interface = gr.Interface( | |
| fn=detect_emotion, | |
| inputs="text", | |
| outputs="text", | |
| live=True, | |
| title="Detector de Emociones", | |
| description="Introduce un texto para detectar la emoci贸n que expresa." | |
| ) | |
| # Lanzar la interfaz | |
| interface.launch() | |