|
import gradio as gr |
|
import random |
|
|
|
moods = { |
|
"Happy": { |
|
"quote": "Happiness is a direction, not a place.", |
|
"emoji": "π", |
|
"activity": "Go out for a walk or dance to your favorite song!", |
|
"song": "π΅ 'Happy' by Pharrell Williams" |
|
}, |
|
"Sad": { |
|
"quote": "Tears come from the heart and not from the brain.", |
|
"emoji": "π’", |
|
"activity": "Watch a feel-good movie or call a friend.", |
|
"song": "π΅ 'Someone Like You' by Adele" |
|
}, |
|
"Angry": { |
|
"quote": "For every minute you remain angry, you give up sixty seconds of peace.", |
|
"emoji": "π‘", |
|
"activity": "Try deep breathing or a short walk.", |
|
"song": "π΅ 'Lose Yourself' by Eminem" |
|
}, |
|
"Excited": { |
|
"quote": "The future belongs to those who believe in the beauty of their dreams.", |
|
"emoji": "π€©", |
|
"activity": "Start that new project you've been thinking about!", |
|
"song": "π΅ 'Canβt Stop the Feeling!' by Justin Timberlake" |
|
}, |
|
"Tired": { |
|
"quote": "Sometimes the most productive thing you can do is rest.", |
|
"emoji": "π΄", |
|
"activity": "Take a short nap or meditate for 10 minutes.", |
|
"song": "π΅ 'Let It Be' by The Beatles" |
|
} |
|
} |
|
|
|
def mood_respond(mood): |
|
response = moods.get(mood, {}) |
|
return response.get("quote", ""), response.get("emoji", ""), response.get("activity", ""), response.get("song", "") |
|
|
|
demo = gr.Interface( |
|
fn=mood_respond, |
|
inputs=gr.Radio(list(moods.keys()), label="How are you feeling today?"), |
|
outputs=[ |
|
gr.Textbox(label="Inspiring Quote"), |
|
gr.Textbox(label="Emoji"), |
|
gr.Textbox(label="Suggested Activity"), |
|
gr.Textbox(label="Recommended Song") |
|
], |
|
title="π AI Mood Generator", |
|
theme="soft" |
|
) |
|
|
|
demo.launch() |
|
|