Spaces:
Runtime error
Runtime error
Commit
·
cb68822
1
Parent(s):
6c35e3d
Update app.py
Browse files
app.py
CHANGED
@@ -4,57 +4,13 @@ from transformers import pipeline
|
|
4 |
import streamlit as st
|
5 |
import random
|
6 |
|
|
|
7 |
def tester(text):
|
8 |
classifier = pipeline("sentiment-analysis", model='bhadresh-savani/distilbert-base-uncased-emotion')
|
9 |
results = classifier(text)
|
10 |
st.subheader(results[0]['label'])
|
11 |
|
12 |
-
|
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']=="fear"):
|
18 |
-
with open('fearplaylist.txt') as f:
|
19 |
-
contents = f.read()
|
20 |
-
components.html(contents,width=560,height=325)
|
21 |
-
|
22 |
-
elif (results[0]['label']=="anger"): #songs for anger emotion
|
23 |
-
with open('angryplaylist.txt') as f:
|
24 |
-
contents = f.read()
|
25 |
-
components.html(contents,width=560,height=325)
|
26 |
-
|
27 |
-
elif (results[0]['label']=="sadness"): #songs for sadness emotion
|
28 |
-
with open('sadplaylist.txt') as f:
|
29 |
-
contents = f.read()
|
30 |
-
components.html(contents,width=560,height=325)
|
31 |
-
|
32 |
-
elif (results[0]['label']=="surprise"):
|
33 |
-
st.write("gulat ka noh")
|
34 |
-
|
35 |
-
elif (results[0]['label']=="love"):
|
36 |
-
with open('loveplaylist.txt') as f:
|
37 |
-
contents = f.read()
|
38 |
-
components.html(contents,width=560,height=325)
|
39 |
-
|
40 |
-
|
41 |
-
st.header("stream your emotions")
|
42 |
-
|
43 |
-
option = st.selectbox(
|
44 |
-
'Please choose your input style.',
|
45 |
-
('Enter own text input.', 'Try one of the app\'s examples.'))
|
46 |
-
|
47 |
-
if (option == 'Enter own text input.'):
|
48 |
-
|
49 |
-
with st.form(key="form1"):
|
50 |
-
emo = st.text_input("Enter a text/phrase/sentence. A corresponding song will be recommended based on its emotion.", placeholder="tester po")
|
51 |
-
submit = st.form_submit_button("Generate Playlist!")
|
52 |
-
|
53 |
-
if (option == 'Try one of the app\'s examples.'):
|
54 |
-
st.write('tester')
|
55 |
-
|
56 |
-
|
57 |
-
tester(emo)
|
58 |
|
59 |
|
60 |
|
|
|
4 |
import streamlit as st
|
5 |
import random
|
6 |
|
7 |
+
|
8 |
def tester(text):
|
9 |
classifier = pipeline("sentiment-analysis", model='bhadresh-savani/distilbert-base-uncased-emotion')
|
10 |
results = classifier(text)
|
11 |
st.subheader(results[0]['label'])
|
12 |
|
13 |
+
#tester(emo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
|