Spaces:
Sleeping
Sleeping
import gradio as gr | |
# Dictionary of moods and emojis | |
mood_emojis = { | |
"happy": "π", | |
"sad": "π’", | |
"angry": "π ", | |
"excited": "π€©", | |
"nervous": "π¬", | |
"tired": "π΄", | |
"surprised": "π²", | |
"love": "β€οΈ", | |
"bored": "π" | |
} | |
# Function to detect mood keywords and return emojis | |
def mood_to_emoji(text): | |
text = text.lower() | |
found = [emoji for mood, emoji in mood_emojis.items() if mood in text] | |
return " ".join(found) if found else "π€ Can't tell how you're feeling!" | |
# Gradio interface | |
demo = gr.Interface( | |
fn=mood_to_emoji, | |
inputs=gr.Textbox(lines=2, placeholder="How are you feeling?"), | |
outputs="text", | |
title="π§ Mood to Emoji Translator", | |
description="Type a sentence describing your mood and get the emoji version!" | |
) | |
demo.launch(share=True) | |