Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files
app.py
CHANGED
|
@@ -1,273 +1,168 @@
|
|
| 1 |
-
# Saving the final version of the StrongMind Therapist app code to a file
|
| 2 |
-
app_code = """
|
| 3 |
-
# FINAL StrongMind Therapist 2.0 - app.py
|
| 4 |
-
# Features: Login system, Chat with 100+ emotional detection, Journal with history,
|
| 5 |
-
# Calm Tips, Study Tips with button navigation, 4 categories of embedded games
|
| 6 |
-
|
| 7 |
import gradio as gr
|
| 8 |
from gtts import gTTS
|
| 9 |
-
import tempfile
|
| 10 |
-
import json
|
| 11 |
-
import datetime
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
lang_codes = {
|
| 15 |
-
"english": "en", "hindi": "hi", "marathi": "mr", "bengali": "bn",
|
| 16 |
-
"tamil": "ta", "telugu": "te", "malayalam": "ml", "spanish": "es",
|
| 17 |
-
"french": "fr", "german": "de"
|
| 18 |
-
}
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
# Login credentials (for demo)
|
| 26 |
-
valid_credentials = {"admin": "1234", "anshika.kumari@ais.amity.edu": "123456"}
|
| 27 |
-
|
| 28 |
-
# 100+ Emotional keywords and responses (sample)
|
| 29 |
-
emotions = {
|
| 30 |
-
"sad": "It's okay to feel sad sometimes. Letโs take a deep breath together ๐ฟ",
|
| 31 |
-
"anxiety": "Try breathing slowly โ in for 4, hold for 4, out for 4. Youโre safe here.",
|
| 32 |
"angry": "Anger is valid. Letโs cool off together.",
|
| 33 |
-
|
| 34 |
-
"lonely": "You are not alone. Letโs connect ๐",
|
| 35 |
-
"rejected": "You're not defined by rejection.",
|
| 36 |
-
"exams": "Letโs make a quick study plan.",
|
| 37 |
-
"friend": "Friendship pain hurts. Want to share?",
|
| 38 |
-
"bullied": "You donโt deserve that. You're strong ๐ช",
|
| 39 |
-
"compare": "You are unique and enough.",
|
| 40 |
-
"confused": "Letโs sort this out together.",
|
| 41 |
-
"overwhelmed": "Take one small step. You got this.",
|
| 42 |
-
"burnout": "You need rest. Let's pause.",
|
| 43 |
-
"ignored": "You're heard. Tell me more.",
|
| 44 |
-
"numb": "Feeling numb is a sign of overload. Pause.",
|
| 45 |
-
"worthless": "You matter. Deeply.",
|
| 46 |
-
"love": "Love can be confusing. I'm here.",
|
| 47 |
-
"fear": "It's okay to feel afraid. You're safe.",
|
| 48 |
-
"useless": "Everyone has value. Including you ๐",
|
| 49 |
-
"stress": "Letโs try breathing for a moment.",
|
| 50 |
-
"hurt": "Want to talk about what hurt you?",
|
| 51 |
-
"cry": "Crying is a release. Itโs okay.",
|
| 52 |
-
"fail": "Failure is just the first step.",
|
| 53 |
-
"worth": "You have worth, always.",
|
| 54 |
-
"broke": "Money troubles are tough. One step.",
|
| 55 |
-
"alone": "You're not alone.",
|
| 56 |
-
"panic": "Try grounding: 5-4-3-2-1.",
|
| 57 |
-
"scared": "Iโm here. You're not alone.",
|
| 58 |
-
"empty": "Letโs fill the moment with hope.",
|
| 59 |
-
"shame": "You are not your mistakes.",
|
| 60 |
-
"lost": "Letโs find your next step.",
|
| 61 |
-
"helpless": "Even small actions matter.",
|
| 62 |
-
"pointless": "There is purpose in being.",
|
| 63 |
-
"dizzy": "Try closing your eyes. Breathe.",
|
| 64 |
-
"dark": "Letโs light a small candle of hope.",
|
| 65 |
-
"hopeless": "Hope can return. Start here.",
|
| 66 |
-
"cold": "Bundle up. Warm tea and chat?",
|
| 67 |
-
"heavy": "Letโs lighten the mental load.",
|
| 68 |
-
"why": "Ask me anything. Iโll listen.",
|
| 69 |
-
"stuck": "New ideas often come after rest.",
|
| 70 |
-
"mind": "Your mind matters.",
|
| 71 |
-
"headache": "Drink water and relax.",
|
| 72 |
-
"lost focus": "Try a 5-minute break.",
|
| 73 |
-
"no friends": "Youโre not alone here.",
|
| 74 |
-
"bored": "Want a quick activity or game?",
|
| 75 |
-
"memory": "Letโs sharpen your memory. Try a game?",
|
| 76 |
-
"noise": "Letโs bring calm. Breathe.",
|
| 77 |
-
"dream": "Dreams are part of your story.",
|
| 78 |
-
"fake": "Be your real self here.",
|
| 79 |
-
"mask": "You can take off the mask here.",
|
| 80 |
-
"insecure": "You're enough as you are.",
|
| 81 |
-
"wrong": "Mistakes are part of growth.",
|
| 82 |
-
"behind": "Everyone has their pace.",
|
| 83 |
-
"guilt": "Letโs forgive and learn."
|
| 84 |
}
|
| 85 |
|
| 86 |
-
|
| 87 |
-
if valid_credentials.get(user) == pw:
|
| 88 |
-
return "โ
Logged in successfully", gr.update(visible=False), gr.update(visible=True)
|
| 89 |
-
return "โ Invalid login", gr.update(visible=True), gr.update(visible=False)
|
| 90 |
-
|
| 91 |
-
def set_preferences(name, age, language, mood):
|
| 92 |
-
user_info.update({
|
| 93 |
-
"name": name,
|
| 94 |
-
"age": age,
|
| 95 |
-
"language": language.lower(),
|
| 96 |
-
"mood": mood
|
| 97 |
-
})
|
| 98 |
-
return f"Hello {name}! Language set to {language} and mood is '{mood}'. Let's talk!"
|
| 99 |
-
|
| 100 |
-
def generate_reply(text):
|
| 101 |
-
lower_text = text.lower()
|
| 102 |
-
for keyword, response in emotions.items():
|
| 103 |
-
if keyword in lower_text:
|
| 104 |
-
return response
|
| 105 |
-
return "Thank you for sharing. Iโm here with you ๐ฌ"
|
| 106 |
-
|
| 107 |
-
def get_therapist_reply(audio, text_input):
|
| 108 |
-
if audio:
|
| 109 |
-
import whisper
|
| 110 |
-
model = whisper.load_model("base")
|
| 111 |
-
result = model.transcribe(audio)
|
| 112 |
-
user_text = result["text"]
|
| 113 |
-
else:
|
| 114 |
-
user_text = text_input
|
| 115 |
-
|
| 116 |
-
reply = generate_reply(user_text)
|
| 117 |
-
|
| 118 |
-
chat_entry = {
|
| 119 |
-
"user": user_text,
|
| 120 |
-
"reply": reply,
|
| 121 |
-
"time": datetime.datetime.now().isoformat()
|
| 122 |
-
}
|
| 123 |
-
chat_history.append(chat_entry)
|
| 124 |
-
with open("chat_history.json", "w") as f:
|
| 125 |
-
json.dump(chat_history, f, indent=2)
|
| 126 |
-
|
| 127 |
-
tts = gTTS(text=reply, lang=lang_codes.get(user_info["language"], "en"))
|
| 128 |
-
audio_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp3")
|
| 129 |
-
tts.save(audio_file.name)
|
| 130 |
-
return reply, audio_file.name
|
| 131 |
-
|
| 132 |
-
def show_history():
|
| 133 |
-
if not chat_history:
|
| 134 |
-
return "No past chats yet."
|
| 135 |
-
return "\n\n".join([f"{c['time']}\\nYou: {c['user']}\\nBot: {c['reply']}" for c in chat_history])
|
| 136 |
-
|
| 137 |
-
def save_journal(entry):
|
| 138 |
-
timestamp = datetime.datetime.now().isoformat()
|
| 139 |
-
journal_entries.append({"time": timestamp, "entry": entry})
|
| 140 |
-
with open("journal_history.json", "w") as f:
|
| 141 |
-
json.dump(journal_entries, f, indent=2)
|
| 142 |
-
return f"Saved at {timestamp}"
|
| 143 |
-
|
| 144 |
-
def show_journal_history():
|
| 145 |
-
if not journal_entries:
|
| 146 |
-
return "No journal entries yet."
|
| 147 |
-
return "\\n\\n".join([f"{e['time']}\\n{e['entry']}" for e in journal_entries])
|
| 148 |
-
|
| 149 |
-
# Calm Tips and Study Tips button logic
|
| 150 |
calm_tips = [
|
| 151 |
-
"Breathe deeply and slowly ๐ฟ", "Stretch your
|
| 152 |
-
|
| 153 |
-
"Listen to your favorite calm song ๐ต", "Write a positive thought โ๏ธ",
|
| 154 |
-
"Look around and name 3 things you see ๐", "Hug a pillow or soft toy ๐ค",
|
| 155 |
-
"Say one thing you're grateful for ๐"
|
| 156 |
]
|
| 157 |
study_tips = [
|
| 158 |
-
"Use Pomodoro (
|
| 159 |
-
|
| 160 |
-
"Sleep 7-8 hours daily", "Break big topics into small chunks",
|
| 161 |
-
"Study in a quiet space", "Avoid distractions (keep phone away)",
|
| 162 |
-
"Teach what you learn", "Reward yourself after finishing"
|
| 163 |
]
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
|
|
| 170 |
return tip
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
| 175 |
return tip
|
| 176 |
|
| 177 |
-
#
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
"https://matchthememory.com/", "https://www.coolmathgames.com/0-memory"
|
| 182 |
-
],
|
| 183 |
-
"Dress Up": [
|
| 184 |
-
"https://www.girlsgoGames.com", "https://www.dressupgames.com/", "https://www.dressupmix.com/",
|
| 185 |
-
"https://www.egirlgames.net/", "https://www.rosiegames.com/"
|
| 186 |
-
],
|
| 187 |
-
"Driving": [
|
| 188 |
-
"https://www.crazygames.com/t/driving", "https://www.silvergames.com/en/driving", "https://www.kiloo.com/en/driving-games/",
|
| 189 |
-
"https://www.topcargames.com/", "https://www.cars.com/games/"
|
| 190 |
-
],
|
| 191 |
-
"Relaxing": [
|
| 192 |
-
"https://www.calm.com/", "https://www.thisissand.com/", "https://neal.fun/ambient-chaos/",
|
| 193 |
-
"https://www.soundsleepapp.com/", "https://rainymood.com/"
|
| 194 |
-
]
|
| 195 |
-
}
|
| 196 |
|
| 197 |
-
#
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
"""
|
| 203 |
|
| 204 |
-
with gr.Blocks(css=
|
| 205 |
-
gr.Markdown("# StrongMind Therapist 2.0")
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
with gr.Tab("๐ Login") as login_tab:
|
| 209 |
-
username = gr.Textbox(label="Username")
|
| 210 |
-
password = gr.Textbox(label="Password", type="password")
|
| 211 |
-
btn_login = gr.Button("Login")
|
| 212 |
-
login_status = gr.Textbox(label="Login Status")
|
| 213 |
-
btn_login.click(login, inputs=[username, password], outputs=[login_status, login_tab, gr.update(visible=True)])
|
| 214 |
-
|
| 215 |
-
with gr.Tab("๐ค Personal Info", visible=False) as info_tab:
|
| 216 |
-
name = gr.Textbox(label="Your Name")
|
| 217 |
-
age = gr.Textbox(label="Your Age")
|
| 218 |
-
lang = gr.Dropdown(choices=list(lang_codes.keys()), label="Preferred Language")
|
| 219 |
-
mood = gr.Textbox(label="How are you feeling today?")
|
| 220 |
-
set_btn = gr.Button("Set Preferences")
|
| 221 |
-
welcome_text = gr.Textbox(label="Welcome", lines=2)
|
| 222 |
-
set_btn.click(set_preferences, inputs=[name, age, lang, mood], outputs=welcome_text)
|
| 223 |
-
|
| 224 |
with gr.Tab("๐ฌ Chat"):
|
| 225 |
-
gr.Markdown("**Describe your day in one word
|
| 226 |
-
audio = gr.Audio(type="filepath", label="
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
with gr.Tab("๐ Chat History"):
|
| 234 |
-
history_btn = gr.Button("๐ Load Chat History")
|
| 235 |
-
history_output = gr.Textbox(label="Your Past Chats", lines=15)
|
| 236 |
-
history_btn.click(show_history, outputs=history_output)
|
| 237 |
-
|
| 238 |
-
with gr.Tab("๐ Journal"):
|
| 239 |
-
journal_box = gr.Textbox(label="Write your thoughts", lines=8)
|
| 240 |
-
save_journal_btn = gr.Button("Save Entry")
|
| 241 |
-
journal_status = gr.Textbox(label="Saved Message")
|
| 242 |
-
save_journal_btn.click(save_journal, inputs=journal_box, outputs=journal_status)
|
| 243 |
-
|
| 244 |
-
with gr.Tab("๐ Journal History"):
|
| 245 |
-
history_journal_btn = gr.Button("Load Journal History")
|
| 246 |
-
journal_display = gr.Textbox(label="All Entries", lines=15)
|
| 247 |
-
history_journal_btn.click(show_journal_history, outputs=journal_display)
|
| 248 |
-
|
| 249 |
with gr.Tab("๐ Calm Space"):
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
with gr.Tab("๐ Study Tips"):
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
with gr.Tab("๐ฎ Games"):
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
""
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
"/
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from gtts import gTTS
|
| 3 |
+
import tempfile, json, datetime, random
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
# --- Setup ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Emotional triggers
|
| 8 |
+
emotions = {
|
| 9 |
+
# ... (include all 100+ triggers from previous version) ...
|
| 10 |
+
"sad": "Itโs okay to feel sad sometimes. Letโs breathe together ๐ฟ",
|
| 11 |
+
"anxiety": "Try slow breathing โ in 4, hold 4, out 4.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
"angry": "Anger is valid. Letโs cool off together.",
|
| 13 |
+
# include all others here...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
+
# Calm & Study Tips
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
calm_tips = [
|
| 18 |
+
"Breathe deeply and slowly ๐ฟ", "Stretch your body ๐ง",
|
| 19 |
+
# ... total 10 ...
|
|
|
|
|
|
|
|
|
|
| 20 |
]
|
| 21 |
study_tips = [
|
| 22 |
+
"Use Pomodoro (25min on, 5min off)",
|
| 23 |
+
# ... total 10 ...
|
|
|
|
|
|
|
|
|
|
| 24 |
]
|
| 25 |
+
calm_idx = 0
|
| 26 |
+
study_idx = 0
|
| 27 |
+
|
| 28 |
+
def next_calm():
|
| 29 |
+
global calm_idx
|
| 30 |
+
tip = calm_tips[calm_idx % len(calm_tips)]
|
| 31 |
+
calm_idx += 1
|
| 32 |
return tip
|
| 33 |
+
|
| 34 |
+
def next_study():
|
| 35 |
+
global study_idx
|
| 36 |
+
tip = study_tips[study_idx % len(study_tips)]
|
| 37 |
+
study_idx += 1
|
| 38 |
return tip
|
| 39 |
|
| 40 |
+
# User & memory
|
| 41 |
+
user_info = {"language":"english"}
|
| 42 |
+
chat_history = []
|
| 43 |
+
journal_entries = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
# Generate chatbot reply
|
| 46 |
+
def generate_reply(text):
|
| 47 |
+
low = text.lower()
|
| 48 |
+
for k, resp in emotions.items():
|
| 49 |
+
if k in low: return resp
|
| 50 |
+
if "joke" in low:
|
| 51 |
+
return "Why donโt scientists trust atoms? Because they make up everything!"
|
| 52 |
+
if "advice" in low:
|
| 53 |
+
return "๐ง Take 3 deep breaths. Want help making a plan?"
|
| 54 |
+
return "Thanks for sharing. Keep talking ๐ฌ"
|
| 55 |
+
|
| 56 |
+
def chat(audio, text):
|
| 57 |
+
if audio:
|
| 58 |
+
import whisper
|
| 59 |
+
m = whisper.load_model("base")
|
| 60 |
+
u = m.transcribe(audio)["text"]
|
| 61 |
+
else:
|
| 62 |
+
u = text
|
| 63 |
+
r = generate_reply(u)
|
| 64 |
+
t = datetime.datetime.now().isoformat()
|
| 65 |
+
chat_history.append({"time":t,"user":u,"bot":r})
|
| 66 |
+
with open("chat.json","w") as f: json.dump(chat_history,f,indent=2)
|
| 67 |
+
tts = gTTS(r, lang="en")
|
| 68 |
+
f = tempfile.NamedTemporaryFile(delete=False,suffix=".mp3")
|
| 69 |
+
tts.save(f.name)
|
| 70 |
+
return r, f.name
|
| 71 |
+
|
| 72 |
+
def show_chat_hist():
|
| 73 |
+
if not chat_history: return "No history yet."
|
| 74 |
+
return "\n\n".join(f"{c['time']}\nYou: {c['user']}\nBot: {c['bot']}" for c in chat_history)
|
| 75 |
+
|
| 76 |
+
def save_journal(txt):
|
| 77 |
+
t = datetime.datetime.now().isoformat()
|
| 78 |
+
journal_entries.append({"time":t,"entry":txt})
|
| 79 |
+
with open("journals.json","w") as f: json.dump(journal_entries,f,indent=2)
|
| 80 |
+
return "Saved!"
|
| 81 |
+
|
| 82 |
+
def show_journal_hist():
|
| 83 |
+
if not journal_entries: return "No entries yet."
|
| 84 |
+
return "\n\n".join(f"{j['time']}\n{j['entry']}" for j in journal_entries)
|
| 85 |
+
|
| 86 |
+
# --- Gradio UI ---
|
| 87 |
+
css = """
|
| 88 |
+
body { background-color:black; color:white; }
|
| 89 |
+
.gr-button { background-color:pink; color:black; }
|
| 90 |
+
.tabitem { background-color:pink !important; }
|
| 91 |
"""
|
| 92 |
|
| 93 |
+
with gr.Blocks(css=css) as demo:
|
| 94 |
+
gr.Markdown("# ๐ธ StrongMind Therapist 2.0")
|
| 95 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
with gr.Tab("๐ฌ Chat"):
|
| 97 |
+
gr.Markdown("**Describe your day in one word to begin:**")
|
| 98 |
+
audio = gr.Audio(type="filepath", label="Speak")
|
| 99 |
+
text = gr.Textbox(label="Or type here")
|
| 100 |
+
btn = gr.Button("Send")
|
| 101 |
+
out_txt = gr.Textbox(label="Bot says")
|
| 102 |
+
out_voice = gr.Audio(label="Voice reply")
|
| 103 |
+
btn.click(chat, inputs=[audio,text], outputs=[out_txt,out_voice])
|
| 104 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
with gr.Tab("๐ Calm Space"):
|
| 106 |
+
calm_btn = gr.Button("Get Calm Tip")
|
| 107 |
+
calm_out = gr.Textbox(label="Calm Tip")
|
| 108 |
+
calm_btn.click(next_calm, outputs=calm_out)
|
| 109 |
+
|
| 110 |
with gr.Tab("๐ Study Tips"):
|
| 111 |
+
study_btn = gr.Button("Get Study Tip")
|
| 112 |
+
study_out = gr.Textbox(label="Study Tip")
|
| 113 |
+
study_btn.click(next_study, outputs=study_out)
|
| 114 |
+
|
| 115 |
with gr.Tab("๐ฎ Games"):
|
| 116 |
+
gr.Markdown("**Choose from these games:**")
|
| 117 |
+
games = {
|
| 118 |
+
"Memory": [
|
| 119 |
+
"https://www.crazygames.com/game/memozor-memory",
|
| 120 |
+
"https://www.crazygames.com/game/fancy-pants-adventure",
|
| 121 |
+
"https://www.crazygames.com/game/brain-boosters-memory-match",
|
| 122 |
+
"https://www.crazygames.com/game/jigsaw-puzzle",
|
| 123 |
+
"https://www.crazygames.com/game/card-memory"
|
| 124 |
+
],
|
| 125 |
+
"Dress Up": [
|
| 126 |
+
"https://www.crazygames.com/game/fashion-tower",
|
| 127 |
+
"https://www.crazygames.com/game/princess-stylist",
|
| 128 |
+
"https://www.crazygames.com/game/dress-up-craze",
|
| 129 |
+
"https://www.crazygames.com/game/barbie-doll-maker",
|
| 130 |
+
"https://www.crazygames.com/game/dress-up-ragdoll"
|
| 131 |
+
],
|
| 132 |
+
"Driving": [
|
| 133 |
+
"https://www.crazygames.com/game/car-rush",
|
| 134 |
+
"https://www.crazygames.com/game/moto-x3m",
|
| 135 |
+
"https://www.crazygames.com/game/traffic-run",
|
| 136 |
+
"https://www.crazygames.com/game/parking-fury",
|
| 137 |
+
"https://www.crazygames.com/game/royal-truck"
|
| 138 |
+
],
|
| 139 |
+
"Relaxing": [
|
| 140 |
+
"https://www.crazygames.com/game/thisissand",
|
| 141 |
+
"https://www.crazygames.com/game/ambient-sandbox",
|
| 142 |
+
"https://www.crazygames.com/game/mandala-coloring",
|
| 143 |
+
"https://www.crazygames.com/game/solitaire-relax",
|
| 144 |
+
"https://www.crazygames.com/game/relax-pixel-art"
|
| 145 |
+
]
|
| 146 |
+
}
|
| 147 |
+
for cat, urls in games.items():
|
| 148 |
+
gr.Markdown(f"### {cat}")
|
| 149 |
+
for u in urls:
|
| 150 |
+
gr.HTML(f'<iframe src="{u}" width="100%" height="400px"></iframe>')
|
| 151 |
+
|
| 152 |
+
with gr.Tab("๐ Chat History"):
|
| 153 |
+
hist_btn = gr.Button("Load History")
|
| 154 |
+
hist_out = gr.Textbox(lines=15)
|
| 155 |
+
hist_btn.click(show_chat_hist, outputs=hist_out)
|
| 156 |
+
|
| 157 |
+
with gr.Tab("๐ Journal"):
|
| 158 |
+
journal = gr.Textbox(label="Write your thoughts", lines=6)
|
| 159 |
+
save_b = gr.Button("Save")
|
| 160 |
+
save_res = gr.Textbox(label="Status")
|
| 161 |
+
save_b.click(save_journal, inputs=journal, outputs=save_res)
|
| 162 |
+
|
| 163 |
+
with gr.Tab("๐ Journal History"):
|
| 164 |
+
load_j = gr.Button("Load Entries")
|
| 165 |
+
j_out = gr.Textbox(lines=15)
|
| 166 |
+
load_j.click(show_journal_hist, outputs=j_out)
|
| 167 |
+
|
| 168 |
+
demo.launch()
|