Spaces:
Runtime error
Runtime error
File size: 7,473 Bytes
6dba858 88055ae 6dba858 f301aac 88055ae 10f256f 88055ae 2682280 88055ae 0ebbd67 2ecd65e 88055ae 6dba858 762bc34 6dba858 7b8fb1b c5a64ee 7b8fb1b 8d3925f 7b8fb1b 8d3925f 7b8fb1b 6dba858 8d3925f 2d9476c 7b8fb1b 652f314 2ecd65e 652f314 72130d1 652f314 762bc34 6dba858 d54d9d6 384ad23 6dba858 0e38ada b34c058 652f314 f301aac f69d52d 89c7fb6 65721eb 5dc3fde e9b62dd ff3a968 652f314 88055ae 7c10707 2cc0db1 9c3fb60 ca5755b 7c10707 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
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("""<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a == 2: #WALK THE MOON - Shut Up and Dance
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/6JCLY0Rlx6Q?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a == 3: #Bee Gees - Stayin' Alive
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/I_izvAbhExY?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a == 4: #Lil Nas X - Industry Baby
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/4aNUdvctOok?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a == 5: #Earth, Wind & Fire - Let's Groove
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/Lrle0x_DHBM?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a == 6: #BTS - 「Dynamite」 / Guitar Cover
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/zA_deMWtz8g?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a == 7: #The Itchyworms - Penge Naman Ako N'yan
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/cYLhKaSY6is?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif (results[0]['label']=="anger"): #songs for anger emotion
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",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("""<iframe width="560" height="315" src="https://www.youtube.com/embed/SZADEHP2yFg?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a ==2: #Pagsamo - Arthur Nery
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/Hx4-GMWWb7Q?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a ==3: #SpongeCola - Jeepney
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/YE6bbpEY4nU?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a ==4: #The Walters -- I Love You So
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/NwFVSclD_uc?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a ==5: #Coldplay - The Scientist
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/RB-RcX5DS5A?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a ==6: #Wiz Khalifa - See You Again
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/cPyovQwFmhE?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",width=560,height=325)
elif a ==7: #Ricky Montgomery - Mr Loverman
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/MxXM3H2VGy4?&autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>""",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")
with open('sadplaylist.txt') as f:
contents = f.read()
components.html(contents,width=560,height=325)
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: i love you so much")
st.write("I am exhausted.")
st.write("I feel energetic.")
st.write("bro you scared me there")
tester(emo)
|