Spaces:
Runtime error
Runtime error
File size: 1,542 Bytes
dd25b4b 88055ae ff47006 88055ae 2682280 88055ae 0ebbd67 2ecd65e b34a926 2ecd65e 88055ae 758f4ba 652f314 2ecd65e 652f314 2ecd65e 652f314 2ecd65e 652f314 2ecd65e 652f314 ff47006 cf3860f 652f314 88055ae 2ecd65e 68de716 88055ae |
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 38 39 40 41 42 43 44 45 |
import streamlit as st
from streamlit_player import st_player
from transformers import pipeline
from IPython.display import YouTubeVideo
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']=="anger"):
st_player("https://www.youtube.com/watch?v=kh0BWQ4Uo6w")
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")
elif (results[0]['label']=="joy"):
st_player("https://www.youtube.com/watch?v=1k8craCGpgs")
elif (results[0]['label']=="sadness"):
video = YouTubeVideo("1k8craCGpgs")
display(video)
#st_player("https://www.youtube.com/embed/BZsXcc_tC-o?autoplay=1")
elif (results[0]['label']=="surprise"):
st_player("https://youtu.be/CmSKVW1v0xM")
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)
|