File size: 3,796 Bytes
dd25b4b
88055ae
 
ff47006
f301aac
88055ae
10f256f
 
 
 
88055ae
2682280
88055ae
0ebbd67
2ecd65e
b34a926
2ecd65e
88055ae
480a784
652f314
762bc34
 
8d3925f
c5a64ee
 
8d3925f
 
 
 
 
 
 
a50c991
762bc34
8739c7e
652f314
 
2ecd65e
652f314
 
72130d1
652f314
762bc34
652f314
0e38ada
c0bbccb
 
980ee5b
10f256f
0e38ada
b34c058
22a0478
b34c058
652f314
 
 
f301aac
f69d52d
89c7fb6
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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 = random.randint(1,4)
    if a == 1:
      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:
      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:
      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 (results[0]['label']=="anger"):
    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"):
    
    #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("""<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)
    
    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)
    
    
  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)