tarrasyed19472007's picture
Update app.py
993cea6 verified
raw
history blame
1.75 kB
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}")