Spaces:
Sleeping
Sleeping
File size: 1,746 Bytes
bb770b6 596e12a bb770b6 596e12a 993cea6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import streamlit as st
from transformers import pipeline
# Load the emotion classification model
emotion_analyzer = pipeline("text-classification", model="cardiffnlp/twitter-roberta-base-sentiment")
# Streamlit app interface
st.title("Emotion Prediction and Well-Being Suggestions")
# Ask 3 questions to the user
question1 = st.text_input("How are you feeling today?")
question2 = st.text_input("Have you felt stressed recently?")
question3 = st.text_input("Do you have enough time for relaxation?")
if st.button("Get Suggestions"):
# Combine responses to analyze sentiment
user_input = f"{question1} {question2} {question3}"
# Perform emotion analysis
emotion = emotion_analyzer(user_input)
# Provide suggestions based on emotion
if "positive" in emotion[0]['label'].lower():
suggestion = "It's great to hear that you're feeling positive! Consider doing a relaxing activity like walking on the beach or practicing mindfulness."
video_url = "https://www.youtube.com/watch?v=1LkV2STw2so" # Example relaxation video
elif "negative" in emotion[0]['label'].lower():
suggestion = "It seems like you're experiencing some stress. Try deep breathing exercises or a walk in nature to relieve tension."
video_url = "https://www.youtube.com/watch?v=5J5nZ9Tr6Cw" # Example deep breathing exercise video
else:
suggestion = "It seems like you're having a mixed experience. Balance your day with some light exercise like hula dancing or yoga."
video_url = "https://www.youtube.com/watch?v=Hk4pJOPsFq4" # Example hula dancing video
# Show suggestions and video
st.write(suggestion)
st.write(f"Check out this video for more guidance: {video_url}")
|