Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
moods = {
|
| 5 |
+
"Happy": {
|
| 6 |
+
"quote": "Happiness is a direction, not a place.",
|
| 7 |
+
"emoji": "π",
|
| 8 |
+
"activity": "Go out for a walk or dance to your favorite song!",
|
| 9 |
+
"song": "π΅ 'Happy' by Pharrell Williams"
|
| 10 |
+
},
|
| 11 |
+
"Sad": {
|
| 12 |
+
"quote": "Tears come from the heart and not from the brain.",
|
| 13 |
+
"emoji": "π’",
|
| 14 |
+
"activity": "Watch a feel-good movie or call a friend.",
|
| 15 |
+
"song": "π΅ 'Someone Like You' by Adele"
|
| 16 |
+
},
|
| 17 |
+
"Angry": {
|
| 18 |
+
"quote": "For every minute you remain angry, you give up sixty seconds of peace.",
|
| 19 |
+
"emoji": "π‘",
|
| 20 |
+
"activity": "Try deep breathing or a short walk.",
|
| 21 |
+
"song": "π΅ 'Lose Yourself' by Eminem"
|
| 22 |
+
},
|
| 23 |
+
"Excited": {
|
| 24 |
+
"quote": "The future belongs to those who believe in the beauty of their dreams.",
|
| 25 |
+
"emoji": "π€©",
|
| 26 |
+
"activity": "Start that new project you've been thinking about!",
|
| 27 |
+
"song": "π΅ 'Canβt Stop the Feeling!' by Justin Timberlake"
|
| 28 |
+
},
|
| 29 |
+
"Tired": {
|
| 30 |
+
"quote": "Sometimes the most productive thing you can do is rest.",
|
| 31 |
+
"emoji": "π΄",
|
| 32 |
+
"activity": "Take a short nap or meditate for 10 minutes.",
|
| 33 |
+
"song": "π΅ 'Let It Be' by The Beatles"
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
def mood_respond(mood):
|
| 38 |
+
response = moods.get(mood, {})
|
| 39 |
+
return response.get("quote", ""), response.get("emoji", ""), response.get("activity", ""), response.get("song", "")
|
| 40 |
+
|
| 41 |
+
demo = gr.Interface(
|
| 42 |
+
fn=mood_respond,
|
| 43 |
+
inputs=gr.Radio(list(moods.keys()), label="How are you feeling today?"),
|
| 44 |
+
outputs=[
|
| 45 |
+
gr.Textbox(label="Inspiring Quote"),
|
| 46 |
+
gr.Textbox(label="Emoji"),
|
| 47 |
+
gr.Textbox(label="Suggested Activity"),
|
| 48 |
+
gr.Textbox(label="Recommended Song")
|
| 49 |
+
],
|
| 50 |
+
title="π AI Mood Generator",
|
| 51 |
+
theme="soft"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
demo.launch()
|