File size: 1,858 Bytes
6dba858
88055ae
 
6dba858
f301aac
88055ae
10f256f
88055ae
2ecd65e
88055ae
6dba858
 
598553f
 
 
 
2d9476c
598553f
 
 
652f314
 
2ecd65e
652f314
 
598553f
 
 
652f314
6dba858
598553f
 
 
6dba858
652f314
598553f
f69d52d
89c7fb6
598553f
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
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='bhadresh-savani/distilbert-base-uncased-emotion')
  results = classifier(text)

  if (results[0]['label']=="joy"): #songs for joy emotion
    with open('joyplaylist.txt') as f:
      contents = f.read()
    components.html(contents,width=560,height=325)   

  elif (results[0]['label']=="anger"): #songs for anger emotion
    with open('angryplaylist.txt') as f:
      contents = f.read()
    components.html(contents,width=560,height=325)
    
  elif (results[0]['label']=="disgust"):
    st_player("https://www.youtube.com/watch?v=zWq2TT3ieGE")
    
  elif (results[0]['label']=="fear"):
    with open('fearplaylist.txt') as f:
      contents = f.read()
    components.html(contents,width=560,height=325)
    
  elif (results[0]['label']=="sadness"): #songs for sadness emotion
    with open('sadplaylist.txt') as f:
      contents = f.read()
    components.html(contents,width=560,height=325)

  elif (results[0]['label']=="surprise"):
    st.write("gulat ka noh")

  elif (results[0]['label']=="love"):
    with open('loveplaylist.txt') as f:
      contents = f.read()
    components.html(contents,width=560,height=325)
  
  return results[0]['label']





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)