Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
from gtts import gTTS
|
4 |
-
import random
|
5 |
from pytube import Search
|
|
|
6 |
|
7 |
# Load DialoGPT model and tokenizer from Hugging Face
|
8 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
|
@@ -52,30 +52,20 @@ def generate_response(user_input):
|
|
52 |
|
53 |
# Add general supportive message
|
54 |
response += "\n\nYou're doing your best, and that’s all anyone can ask for. Please take care of yourself and know that it’s okay to take a step back when things feel too much. Your well-being is the most important thing."
|
55 |
-
|
56 |
# Suggest a productive activity based on detected keywords
|
57 |
-
if any(keyword in user_input.lower() for keyword in ["lonely", "lost", "sad", "overwhelmed"
|
58 |
st.info("Here's a suggestion to help you cope:")
|
59 |
|
60 |
-
#
|
61 |
-
|
62 |
-
|
63 |
-
"yoga": "Yoga helps you relax and refocus. Try some deep breathing exercises or light stretching.",
|
64 |
-
"painting": "Creative expression through painting or drawing can be soothing and help you release pent-up emotions.",
|
65 |
-
"meditation": "Take a moment to calm your mind. Guided meditation can help reduce stress and anxiety.",
|
66 |
-
"exercise": "Physical activity can lift your mood. Even a short walk in nature can make a big difference."
|
67 |
-
}
|
68 |
-
|
69 |
-
# Randomly select an activity category to suggest
|
70 |
-
activity = random.choice(list(activities.keys()))
|
71 |
-
st.write(f"How about {activity}? {activities[activity]}")
|
72 |
-
|
73 |
-
# Search YouTube for videos related to the selected activity
|
74 |
-
search = Search(activity)
|
75 |
|
76 |
-
#
|
77 |
try:
|
|
|
78 |
search_results = search.results[:3] # limit results to 3 videos
|
|
|
79 |
if not search_results:
|
80 |
st.write(f"No results found for '{activity}'. Please try again.")
|
81 |
else:
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
from gtts import gTTS
|
|
|
4 |
from pytube import Search
|
5 |
+
import random
|
6 |
|
7 |
# Load DialoGPT model and tokenizer from Hugging Face
|
8 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
|
|
|
52 |
|
53 |
# Add general supportive message
|
54 |
response += "\n\nYou're doing your best, and that’s all anyone can ask for. Please take care of yourself and know that it’s okay to take a step back when things feel too much. Your well-being is the most important thing."
|
55 |
+
|
56 |
# Suggest a productive activity based on detected keywords
|
57 |
+
if any(keyword in user_input.lower() for keyword in ["lonely", "lost", "sad", "overwhelmed"]):
|
58 |
st.info("Here's a suggestion to help you cope:")
|
59 |
|
60 |
+
# List of activities
|
61 |
+
hobbies = ["journaling", "yoga", "painting", "exercise", "meditation"]
|
62 |
+
activity = st.selectbox("Choose an activity you'd like to try:", hobbies)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
+
# Search YouTube for videos related to the selected activity
|
65 |
try:
|
66 |
+
search = Search(activity)
|
67 |
search_results = search.results[:3] # limit results to 3 videos
|
68 |
+
|
69 |
if not search_results:
|
70 |
st.write(f"No results found for '{activity}'. Please try again.")
|
71 |
else:
|