SHassan commited on
Commit
6082a98
Β·
verified Β·
1 Parent(s): 966685e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -30
app.py CHANGED
@@ -1,37 +1,31 @@
1
  import gradio as gr
2
 
3
- # Function to generate greeting card content
4
- def generate_card(name, message):
5
- # HTML greeting card layout with inline CSS
6
- html = f"""
7
- <div style="background-image: url('https://imgur.com/gallery/tried-hand-digital-watercolor-what-do-you-think-9MNLzB3#/t/wallpaper');
8
- background-size: cover;
9
- color: white;
10
- height: 300px;
11
- padding: 20px;
12
- font-family: 'Segoe UI', sans-serif;
13
- border-radius: 15px;
14
- box-shadow: 0 0 20px rgba(0,0,0,0.3);
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
- # Gradio interface using HTML output
 
 
 
 
 
 
26
  demo = gr.Interface(
27
- fn=generate_card,
28
- inputs=[
29
- gr.Textbox(label="Enter your name"),
30
- gr.Textbox(label="Enter a custom message")
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)