Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
display: flex;
|
16 |
-
flex-direction: column;
|
17 |
-
justify-content: center;
|
18 |
-
text-align: center;">
|
19 |
-
<h1 style="font-size: 2.5em;">Salaam, {name}!</h1>
|
20 |
-
<p style="font-size: 1.5em;">{message}</p>
|
21 |
-
</div>
|
22 |
-
"""
|
23 |
-
return html
|
24 |
|
25 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
demo = gr.Interface(
|
27 |
-
fn=
|
28 |
-
inputs=
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
outputs=gr.HTML(label="Your Greeting Card"),
|
33 |
-
title="π Greeting Card Generator",
|
34 |
-
description="Create a beautiful greeting card with a name and message. Powered by Gradio + HTML."
|
35 |
)
|
36 |
|
37 |
demo.launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Dictionary of moods and emojis
|
4 |
+
mood_emojis = {
|
5 |
+
"happy": "π",
|
6 |
+
"sad": "π’",
|
7 |
+
"angry": "π ",
|
8 |
+
"excited": "π€©",
|
9 |
+
"nervous": "π¬",
|
10 |
+
"tired": "π΄",
|
11 |
+
"surprised": "π²",
|
12 |
+
"love": "β€οΈ",
|
13 |
+
"bored": "π"
|
14 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
# Function to detect mood keywords and return emojis
|
17 |
+
def mood_to_emoji(text):
|
18 |
+
text = text.lower()
|
19 |
+
found = [emoji for mood, emoji in mood_emojis.items() if mood in text]
|
20 |
+
return " ".join(found) if found else "π€ Can't tell how you're feeling!"
|
21 |
+
|
22 |
+
# Gradio interface
|
23 |
demo = gr.Interface(
|
24 |
+
fn=mood_to_emoji,
|
25 |
+
inputs=gr.Textbox(lines=2, placeholder="How are you feeling?"),
|
26 |
+
outputs="text",
|
27 |
+
title="π§ Mood to Emoji Translator",
|
28 |
+
description="Type a sentence describing your mood and get the emoji version!"
|
|
|
|
|
|
|
29 |
)
|
30 |
|
31 |
demo.launch(share=True)
|