Spaces:
Sleeping
Sleeping
File size: 827 Bytes
ea084ed 6082a98 ea084ed 6082a98 ea084ed 6082a98 ea084ed 966685e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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)
|