import streamlit as st
from streamlit_player import st_player
from transformers import pipeline
from IPython.display import YouTubeVideo
import random
import streamlit as st
import streamlit.components.v1 as components
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)
st.write(results[0]['label'])
if (results[0]['label']=="joy"):
a = 1
if a == 1:
components.html("""""",width=560,height=325)
elif (results[0]['label']=="anger"):
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"):
#video = YouTubeVideo("1k8craCGpgs")
#display(video)
#st_player("https://www.youtube.com/watch?v=BZsXcc_tC-o")
# embed streamlit docs in a streamlit app
#components.html("""""",width=560,height=325)
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
emo = st.text_input('This application detects the emotion in your text input and suggests a song that matches it. Please enter text below to try:')
tester(emo)