shawarmabytes commited on
Commit
598553f
1 Parent(s): 15107bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -54
app.py CHANGED
@@ -6,80 +6,41 @@ 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
21
- 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)
22
- elif a == 3: #Bee Gees - Stayin' Alive
23
- 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)
24
- elif a == 4: #Lil Nas X - Industry Baby
25
- 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)
26
- elif a == 5: #Earth, Wind & Fire - Let's Groove
27
- 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)
28
- elif a == 6: #BTS - 「Dynamite」 / Guitar Cover
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
-
39
-
40
 
41
  elif (results[0]['label']=="disgust"):
42
  st_player("https://www.youtube.com/watch?v=zWq2TT3ieGE")
43
 
44
  elif (results[0]['label']=="fear"):
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 ==5: #Coldplay - The Scientist
59
- 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)
60
- elif a ==6: #Wiz Khalifa - See You Again
61
- 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)
62
- elif a ==7: #Ricky Montgomery - Mr Loverman
63
- 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)
64
 
65
-
66
-
67
-
68
-
69
-
70
  elif (results[0]['label']=="surprise"):
71
- st_player("https://youtu.be/CmSKVW1v0xM")
72
- st.write("check out this [link](https://open.spotify.com/playlist/4yXfnhz0BReoVfwwYRtPBm)")
73
 
74
  elif (results[0]['label']=="love"):
75
- #st_player("https://www.youtube.com/watch?v=XVhEm62Uqog")
76
-
77
- with open('sadplaylist.txt') as f:
78
  contents = f.read()
79
  components.html(contents,width=560,height=325)
80
 
81
  return results[0]['label']
82
- #return results
83
 
84
 
85
 
 
6
 
7
 
8
  def tester(text):
 
 
 
9
  classifier = pipeline("sentiment-analysis", model='bhadresh-savani/distilbert-base-uncased-emotion')
10
  results = classifier(text)
11
 
 
12
  if (results[0]['label']=="joy"): #songs for joy emotion
13
+ with open('joyplaylist.txt') as f:
14
+ contents = f.read()
15
+ components.html(contents,width=560,height=325)
16
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  elif (results[0]['label']=="anger"): #songs for anger emotion
18
+ with open('angryplaylist.txt') as f:
19
+ contents = f.read()
20
+ components.html(contents,width=560,height=325)
 
21
 
22
  elif (results[0]['label']=="disgust"):
23
  st_player("https://www.youtube.com/watch?v=zWq2TT3ieGE")
24
 
25
  elif (results[0]['label']=="fear"):
26
+ with open('fearplaylist.txt') as f:
27
+ contents = f.read()
28
+ components.html(contents,width=560,height=325)
29
 
 
30
  elif (results[0]['label']=="sadness"): #songs for sadness emotion
31
+ with open('sadplaylist.txt') as f:
32
+ contents = f.read()
33
+ components.html(contents,width=560,height=325)
 
 
 
 
 
 
 
 
 
 
 
 
34
 
 
 
 
 
 
35
  elif (results[0]['label']=="surprise"):
36
+ st.write("gulat ka noh")
 
37
 
38
  elif (results[0]['label']=="love"):
39
+ with open('loveplaylist.txt') as f:
 
 
40
  contents = f.read()
41
  components.html(contents,width=560,height=325)
42
 
43
  return results[0]['label']
 
44
 
45
 
46