import streamlit.components.v1 as components
from streamlit_player import st_player
from transformers import pipeline
import streamlit as st
import random
def tester(text):
#classifier = pipeline("sentiment-analysis", model='arpanghoshal/EmoRoBERTa')
#classifier = pipeline("sentiment-analysis", model='cardiffnlp/twitter-roberta-base-emotion')
#classifier = pipeline("sentiment-analysis", 'j-hartmann/emotion-english-distilroberta-base')
classifier = pipeline("sentiment-analysis", model='bhadresh-savani/distilbert-base-uncased-emotion')
results = classifier(text)
if (results[0]['label']=="joy"): #songs for joy emotion
a = random.randint(1,7) #shuffle
if a == 1: #Rick Astley - Never Gonna Give You Up
components.html("""""",width=560,height=325)
elif a == 2: #WALK THE MOON - Shut Up and Dance
components.html("""""",width=560,height=325)
elif a == 3: #Bee Gees - Stayin' Alive
components.html("""""",width=560,height=325)
elif a == 4: #Lil Nas X - Industry Baby
components.html("""""",width=560,height=325)
elif a == 5: #Earth, Wind & Fire - Let's Groove
components.html("""""",width=560,height=325)
elif a == 6: #BTS - 「Dynamite」 / Guitar Cover
components.html("""""",width=560,height=325)
elif a == 7: #The Itchyworms - Penge Naman Ako N'yan
components.html("""""",width=560,height=325)
elif (results[0]['label']=="anger"): #songs for anger emotion
components.html("""""",width=560,height=325)
elif (results[0]['label']=="disgust"):
st_player("https://www.youtube.com/watch?v=zWq2TT3ieGE")
elif (results[0]['label']=="fear"):
st_player("https://www.youtube.com/watch?v=iyEUvUcMHgE?&autoplay=1")
elif (results[0]['label']=="sadness"): #songs for sadness emotion
a = random.randint(1,7)
if a == 1: #Join the Club - Nobela
components.html("""""",width=560,height=325)
elif a ==2: #Pagsamo - Arthur Nery
components.html("""""",width=560,height=325)
elif a ==3: #SpongeCola - Jeepney
components.html("""""",width=560,height=325)
elif a ==4: #The Walters -- I Love You So
components.html("""""",width=560,height=325)
elif a ==5: #Coldplay - The Scientist
components.html("""""",width=560,height=325)
elif a ==6: #Wiz Khalifa - See You Again
components.html("""""",width=560,height=325)
elif a ==7: #Pagsamo - Arthur Nery
components.html("""""",width=560,height=325)
elif (results[0]['label']=="surprise"):
st_player("https://youtu.be/CmSKVW1v0xM")
st.write("check out this [link](https://open.spotify.com/playlist/4yXfnhz0BReoVfwwYRtPBm)")
elif (results[0]['label']=="love"):
st_player("https://www.youtube.com/watch?v=XVhEm62Uqog")
return results[0]['label']
#return results
st.header("stream your emotions")
#st.write("Enter a text/phrase/sentence. A corresponding song will be recommended based on its emotion")
emo = st.text_input("Enter a text/phrase/sentence. A corresponding song will be recommended based on its emotion.")
st.write("Examples: You look wonderful tonight")
st.write("I am exhausted.")
st.write("I feel energetic.")
st.write("bro you scared me there")
tester(emo)