Spaces:
Runtime error
Runtime error
shawarmabytes
commited on
Commit
•
6dba858
1
Parent(s):
4bb3458
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,20 @@
|
|
1 |
-
import streamlit as
|
2 |
from streamlit_player import st_player
|
3 |
from transformers import pipeline
|
4 |
-
|
5 |
import random
|
6 |
|
7 |
|
8 |
-
import streamlit as st
|
9 |
-
import streamlit.components.v1 as components
|
10 |
-
|
11 |
def tester(text):
|
12 |
#classifier = pipeline("sentiment-analysis", model='arpanghoshal/EmoRoBERTa')
|
13 |
#classifier = pipeline("sentiment-analysis", model='cardiffnlp/twitter-roberta-base-emotion')
|
14 |
#classifier = pipeline("sentiment-analysis", 'j-hartmann/emotion-english-distilroberta-base')
|
15 |
classifier = pipeline("sentiment-analysis", model='bhadresh-savani/distilbert-base-uncased-emotion')
|
16 |
-
|
17 |
-
|
18 |
results = classifier(text)
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
if (results[0]['label']=="joy"):
|
23 |
-
a = random.randint(1,7)
|
24 |
if a == 1: #Rick Astley - Never Gonna Give You Up
|
25 |
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)
|
26 |
elif a == 2: #WALK THE MOON - Shut Up and Dance
|
@@ -35,15 +29,10 @@ def tester(text):
|
|
35 |
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)
|
36 |
elif a == 7: #The Itchyworms - Penge Naman Ako N'yan
|
37 |
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)
|
38 |
-
|
39 |
-
# 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)
|
40 |
-
#elif a == 9:
|
41 |
-
# 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)
|
42 |
-
#elif a == 10:
|
43 |
-
# 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)
|
44 |
|
45 |
|
46 |
-
elif (results[0]['label']=="anger"):
|
47 |
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)
|
48 |
|
49 |
|
@@ -56,15 +45,26 @@ def tester(text):
|
|
56 |
st_player("https://www.youtube.com/watch?v=iyEUvUcMHgE?&autoplay=1")
|
57 |
|
58 |
|
59 |
-
elif (results[0]['label']=="sadness"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
#video = YouTubeVideo("1k8craCGpgs")
|
62 |
-
#display(video)
|
63 |
-
#st_player("https://www.youtube.com/watch?v=BZsXcc_tC-o")
|
64 |
-
# embed streamlit docs in a streamlit app
|
65 |
-
#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)
|
66 |
|
67 |
-
components.html("""<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj&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)
|
68 |
|
69 |
|
70 |
elif (results[0]['label']=="surprise"):
|
|
|
1 |
+
import streamlit.components.v1 as components
|
2 |
from streamlit_player import st_player
|
3 |
from transformers import pipeline
|
4 |
+
import streamlit as st
|
5 |
import random
|
6 |
|
7 |
|
|
|
|
|
|
|
8 |
def tester(text):
|
9 |
#classifier = pipeline("sentiment-analysis", model='arpanghoshal/EmoRoBERTa')
|
10 |
#classifier = pipeline("sentiment-analysis", model='cardiffnlp/twitter-roberta-base-emotion')
|
11 |
#classifier = pipeline("sentiment-analysis", 'j-hartmann/emotion-english-distilroberta-base')
|
12 |
classifier = pipeline("sentiment-analysis", model='bhadresh-savani/distilbert-base-uncased-emotion')
|
|
|
|
|
13 |
results = classifier(text)
|
14 |
+
|
|
|
15 |
|
16 |
+
if (results[0]['label']=="joy"): #songs for joy emotion
|
17 |
+
a = random.randint(1,7) #shuffle
|
18 |
if a == 1: #Rick Astley - Never Gonna Give You Up
|
19 |
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)
|
20 |
elif a == 2: #WALK THE MOON - Shut Up and Dance
|
|
|
29 |
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)
|
30 |
elif a == 7: #The Itchyworms - Penge Naman Ako N'yan
|
31 |
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)
|
32 |
+
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
|
35 |
+
elif (results[0]['label']=="anger"): #songs for anger emotion
|
36 |
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)
|
37 |
|
38 |
|
|
|
45 |
st_player("https://www.youtube.com/watch?v=iyEUvUcMHgE?&autoplay=1")
|
46 |
|
47 |
|
48 |
+
elif (results[0]['label']=="sadness"): #songs for sadness emotion
|
49 |
+
a = random.randint(1,7)
|
50 |
+
if a == 1: #Join the Club - Nobela
|
51 |
+
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)
|
52 |
+
elif a ==2: #Pagsamo - Arthur Nery
|
53 |
+
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)
|
54 |
+
elif a ==3: #SpongeCola - Jeepney
|
55 |
+
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)
|
56 |
+
elif a ==4: #The Walters -- I Love You So
|
57 |
+
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)
|
58 |
+
elif a ==2: #Pagsamo - Arthur Nery
|
59 |
+
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)
|
60 |
+
elif a ==2: #Pagsamo - Arthur Nery
|
61 |
+
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)
|
62 |
+
elif a ==2: #Pagsamo - Arthur Nery
|
63 |
+
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)
|
64 |
+
|
65 |
+
|
66 |
|
|
|
|
|
|
|
|
|
|
|
67 |
|
|
|
68 |
|
69 |
|
70 |
elif (results[0]['label']=="surprise"):
|