Tator19 commited on
Commit
d87240e
·
1 Parent(s): f17bd65

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +511 -0
main.py ADDED
@@ -0,0 +1,511 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_option_menu import option_menu
3
+ import streamlit.components.v1 as components
4
+ import os
5
+ import time
6
+ import spotipy
7
+ from spotipy.oauth2 import SpotifyOAuth, SpotifyClientCredentials
8
+ import requests
9
+ from spotifysearch import *
10
+ from model import *
11
+
12
+
13
+ #Authentication - without user
14
+ #client_credentials_manager = SpotifyClientCredentials(client_id=Client_id, client_secret=client_secret)
15
+ #sp = spotipy.Spotify(client_credentials_manager = client_credentials_manager)
16
+
17
+ Client_id=os.environ['Client_ID']
18
+ client_secret=os.environ['Client_secret']
19
+ auth_manager = SpotifyClientCredentials(client_id=Client_id, client_secret=client_secret)
20
+ sp = spotipy.client.Spotify(auth_manager=auth_manager)
21
+
22
+
23
+
24
+
25
+
26
+
27
+ if 'model' not in st.session_state:
28
+ st.session_state.model = 'Model 1'
29
+ def update_radio2():
30
+ st.session_state.model=st.session_state.radio2
31
+ if 'genre' not in st.session_state:
32
+ st.session_state.genre=3
33
+ def update_num_genre():
34
+ st.session_state.genre=st.session_state.num_genre
35
+ if 'artist' not in st.session_state:
36
+ st.session_state.artist=5
37
+ def update_same_art():
38
+ st.session_state.artist=st.session_state.same_art
39
+ if 'model2' not in st.session_state:
40
+ st.session_state.model2= 'Spotify model'
41
+ def update_radio1():
42
+ st.session_state.model2 =st.session_state.radio1
43
+
44
+ if 'Region' not in st.session_state:
45
+ st.session_state.rg="US"
46
+ def update_Region():
47
+ st.session_state.rg=st.session_state.Region
48
+ if 'radio' not in st.session_state:
49
+ st.session_state.feature="Song"
50
+ def update_radio0():
51
+ st.session_state.feature=st.session_state.radio
52
+
53
+ if 'p_url' not in st.session_state:
54
+ st.session_state.p_url = 'Example: https://open.spotify.com/playlist/37i9dQZF1DX8FwnYE6PRvL?si=06ff6b38d4124af0'
55
+ def update_playlist_url():
56
+ st.session_state.p_url = st.session_state.playlist_url
57
+
58
+ if 's_url' not in st.session_state:
59
+ st.session_state.s_url = 'Example: https://open.spotify.com/track/5CQ30WqJwcep0pYcV4AMNc?si=ed4b04f153a24531'
60
+ def update_song_url():
61
+ st.session_state.s_url = st.session_state.song_url
62
+
63
+ if 'sn_url' not in st.session_state:
64
+ st.session_state.sn_url = 'In The End'
65
+ def update_song_name_url():
66
+ st.session_state.sn_url = st.session_state.songname_url
67
+
68
+ if 'a_url' not in st.session_state:
69
+ st.session_state.a_url = 'Example: https://open.spotify.com/artist/3RNrq3jvMZxD9ZyoOZbQOD?si=UNAsX20kRpG89bxOO8o7ew'
70
+ def update_artist_url():
71
+ st.session_state.a_url = st.session_state.artist_url
72
+
73
+
74
+ def play_recomm():
75
+ if 'rs' in st.session_state:
76
+ del st.session_state.rs,st.session_state.err
77
+ try:
78
+ if len(pd.read_csv('Data/new_tracks.csv')) >= 200:
79
+ with st.spinner('Updating the dataset...'):
80
+ x=update_dataset()
81
+ st.success('{} New tracks were added to the dataset.'.format(x))
82
+ except:
83
+ st.error("The dataset update failed. ")
84
+ with st.spinner('Getting Recommendations...'):
85
+ res,err = playlist_model(st.session_state.p_url,st.session_state.model,st.session_state.genre,st.session_state.artist)
86
+ st.session_state.rs=res
87
+ st.session_state.err=err
88
+ if len(st.session_state.rs)>=1:
89
+ if st.session_state.model == 'Model 1' or st.session_state.model == 'Model 2':
90
+ st.success('Go to the Result page to view the top {} recommendations, Thanks for taking the time to use this :D'.format(len(st.session_state.rs)))
91
+ st.success('- RedValis'.format(len(st.session_state.rs)))
92
+
93
+ else:
94
+ st.success('Go to the Result page to view the Spotify recommendations')
95
+ st.success('- RedValis')
96
+ else:
97
+ st.error('Model failed. Check the log for more information.')
98
+
99
+ def art_recomm():
100
+ if 'rs' in st.session_state:
101
+ del st.session_state.rs,st.session_state.err
102
+ with st.spinner('Getting Recommendations...'):
103
+ res,err = top_tracks(st.session_state.a_url,st.session_state.rg)
104
+ st.session_state.rs=res
105
+ st.session_state.err=err
106
+ if len(st.session_state.rs)>=1:
107
+ st.success("Go to the Result page to view the Artist's top tracks, Thank you for taking the time to use this :D")
108
+ st.success("- RedValis")
109
+ else:
110
+ st.error('Model failed. Check the log for more information.')
111
+
112
+ def song_recomm():
113
+ if 'rs' in st.session_state:
114
+ del st.session_state.rs,st.session_state.err
115
+ with st.spinner('Getting Recommendations...'):
116
+ res,err = song_model(st.session_state.s_url,st.session_state.model,st.session_state.genre,st.session_state.artist)
117
+ st.session_state.rs=res
118
+ st.session_state.err=err
119
+ if len(st.session_state.rs)>=1:
120
+ if st.session_state.model == 'Model 1' or st.session_state.model == 'Model 2':
121
+ st.success('Go to the Result page to view the top {} recommendations, Thank you for taking the time to use this :D'.format(len(st.session_state.rs)))
122
+ st.success('- RedValis'.format(len(st.session_state.rs)))
123
+ else:
124
+ st.success('Go to the Result page to view the Spotify recommendations')
125
+ st.success('- RedValis')
126
+ else:
127
+ st.error('Model failed. Check the log for more information.')
128
+
129
+ def playlist_page():
130
+ st.subheader("User Playlist")
131
+ st.markdown('---')
132
+ playlist_uri = (st.session_state.playlist_url).split('/')[-1].split('?')[0]
133
+ uri_link = 'https://open.spotify.com/embed/playlist/' + playlist_uri
134
+ components.iframe(uri_link, height=300)
135
+ return
136
+
137
+ def song_page():
138
+ st.subheader("User Song")
139
+ st.markdown('---')
140
+ song_uri = (st.session_state.song_url).split('/')[-1].split('?')[0]
141
+ uri_link = 'https://open.spotify.com/embed/track/' + song_uri
142
+ components.iframe(uri_link, height=100)
143
+
144
+ def artist_page():
145
+ st.subheader("User Artist")
146
+ st.markdown('---')
147
+ artist_uri = (st.session_state.artist_url).split('/')[-1].split('?')[0]
148
+ uri_link = 'https://open.spotify.com/embed/artist/' + artist_uri
149
+ components.iframe(uri_link, height=80)
150
+
151
+
152
+ def spr_sidebar():
153
+ menu=option_menu(
154
+ menu_title=None,
155
+ options=['Home','Result','About','Log'],
156
+ icons=['house','book','info-square','terminal'],
157
+ menu_icon='cast',
158
+ default_index=0,
159
+ orientation='horizontal'
160
+ )
161
+ if menu=='Home':
162
+ st.session_state.app_mode = 'Home'
163
+ elif menu=='Result':
164
+ st.session_state.app_mode = 'Result'
165
+ elif menu=='About':
166
+ st.session_state.app_mode = 'About'
167
+ elif menu=='Log':
168
+ st.session_state.app_mode = 'Log'
169
+
170
+ def home_page():
171
+ st.session_state.radio=st.session_state.feature
172
+ st.session_state.radio2=st.session_state.model
173
+ st.session_state.num_genre=st.session_state.genre
174
+ st.session_state.same_art=st.session_state.artist
175
+ st.session_state.Region=st.session_state.rg
176
+
177
+
178
+ st.title('Helical Recommendation System')
179
+ col,col2,col3=st.columns([2,2,3])
180
+ radio=col.radio("Feature",options=("Playlist","Song","Artist Top Tracks"),key='radio',on_change=update_radio0)
181
+ if radio =="Artist Top Tracks":
182
+ radio1=col2.radio("Model",options=["Spotify model"],key='radio1',on_change=update_radio1)
183
+ Region=col3.selectbox("Please Choose Region",index=58,key='Region',on_change=update_Region,options=('AD', 'AR', 'AU', 'AT', 'BE', 'BO', 'BR', 'BG', 'CA', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DK', 'DO', 'EC', 'SV', 'EE', 'FI', 'FR', 'DE', 'GR', 'GT', 'HN', 'HK', 'HU', 'IS', 'ID', 'IE', 'IT', 'JP', 'LV', 'LI', 'LT', 'LU', 'MY', 'MT', 'MX', 'MC', 'NL', 'NZ', 'NI', 'NO', 'PA', 'PY', 'PE', 'PH', 'PL', 'PT', 'SG', 'ES', 'SK', 'SE', 'CH', 'TW', 'TR', 'GB', 'US', 'UY'))
184
+ elif radio =="Playlist" or radio =="Song" :
185
+ radio2=col2.radio("Model",options=("Model 1","Model 2","Spotify Model"),key='radio2',on_change=update_radio2)
186
+ if st.session_state.radio2=="Model 1" or st.session_state.radio2=="Model 2":
187
+ num_genre=col3.selectbox("choose a number of genres to focus on",options=(1,2,3,4,5,6,7),index=2,key='num_genre',on_change=update_num_genre)
188
+ same_art=col3.selectbox("How many recommendations by the same artist",options=(1,2,3,4,5,7,10,15),index=3,key='same_art',on_change=update_same_art)
189
+
190
+
191
+ st.markdown("<br>", unsafe_allow_html=True)
192
+
193
+ if radio == "Playlist" :
194
+ st.session_state.playlist_url = st.session_state.p_url
195
+ Url = st.text_input(label="Playlist Url",key='playlist_url',on_change=update_playlist_url)
196
+ playlist_page()
197
+ state =st.button('Get Recommendations')
198
+ with st.expander("Here's how to find any Playlist URL in Spotify"):
199
+ st.write("""
200
+ - Search for Playlist on the Spotify app
201
+ - Right Click on the Playlist you like
202
+ - Click "Share"
203
+ - Choose "Copy link to playlist"
204
+ """)
205
+ st.markdown("<br>", unsafe_allow_html=True)
206
+ st.image('spotify_get_playlist_url.png')
207
+ if state:
208
+ play_recomm()
209
+ elif radio == "Song" :
210
+ st.session_state.songname_url = st.session_state.sn_url
211
+ Url_a = st.text_input(label="Type a songs name to get the url for",key='get_url',on_change=update_song_name_url)
212
+
213
+ from spotifysearch.client import Client
214
+ myclient = Client(Client_id, client_secret)
215
+ results = myclient.search(Url_a)
216
+ tracks = results.get_tracks()
217
+
218
+ track = tracks
219
+
220
+ result_length = len(tracks)
221
+
222
+ track_song_list = []
223
+ track_url_list = []
224
+ track_actual_url_list = []
225
+ anotherlist=[]
226
+
227
+
228
+ genrec = st.radio(
229
+ "Choose an option to search in:",
230
+ ["5x4"])
231
+
232
+
233
+ if genrec == "Full":
234
+
235
+ for leupz in range(result_length):
236
+ thetrack = tracks[leupz]
237
+ st.write(thetrack.name)
238
+ name_desu = thetrack.name
239
+ track_song_list.append(name_desu)
240
+
241
+ st.write(thetrack.url)
242
+ urlname_desu = thetrack.name
243
+ track_url_list.append(urlname_desu)
244
+
245
+ song_uri = (thetrack.url).split('/')[-1].split('?')[0]
246
+ uri_link = 'https://open.spotify.com/embed/track/' + song_uri
247
+ components.iframe(uri_link, height=100)
248
+
249
+
250
+ st.write(result_length)
251
+
252
+ elif genrec == "5x4":
253
+ for leupz in range(result_length):
254
+ thetrack = tracks[leupz]
255
+
256
+ name_desu = thetrack.name
257
+ track_song_list.append(name_desu)
258
+
259
+
260
+ urlname_desu = thetrack.url
261
+ track_url_list.append(urlname_desu)
262
+
263
+ song_uri = (thetrack.url).split('/')[-1].split('?')[0]
264
+ uri_link = 'https://open.spotify.com/embed/track/' + song_uri
265
+ dem = uri_link
266
+
267
+ track_actual_url_list.append(dem)
268
+ notneeded_chkbox = st.checkbox('Click on this to see the results')
269
+
270
+ if notneeded_chkbox:
271
+ ########### WARNING: MAY CAUSE SOME TO FAINT :/
272
+
273
+ st.write('Feature activated!')
274
+
275
+ pages = st.radio("Page",["1","2","3","4",], horizontal=True)
276
+
277
+ if pages == "1":
278
+ Le_songs = st.radio(
279
+ "Its time to choose...",
280
+ [track_song_list[0],track_song_list[1],track_song_list[2],track_song_list[3],track_song_list[4]])
281
+
282
+ if Le_songs == track_song_list[0]:
283
+ st.session_state.s_url = track_actual_url_list[0]
284
+
285
+ elif Le_songs == track_song_list[1]:
286
+ st.session_state.s_url = track_actual_url_list[1]
287
+
288
+ elif Le_songs == track_song_list[2]:
289
+ st.session_state.s_url = track_actual_url_list[2]
290
+
291
+ elif Le_songs == track_song_list[3]:
292
+ st.session_state.s_url = track_actual_url_list[3]
293
+
294
+ elif Le_songs == track_song_list[4]:
295
+ st.session_state.s_url = track_actual_url_list[4]
296
+
297
+
298
+ st.write('Previews')
299
+
300
+ components.iframe(track_actual_url_list[0], height=100)
301
+ components.iframe(track_actual_url_list[1], height=100)
302
+ components.iframe(track_actual_url_list[2], height=100)
303
+ components.iframe(track_actual_url_list[3], height=100)
304
+ components.iframe(track_actual_url_list[4], height=100)
305
+
306
+
307
+ if pages == "2":
308
+ Le_songs = st.radio(
309
+ "Its time to choose...",
310
+ [track_song_list[5],track_song_list[6],track_song_list[7],track_song_list[8],track_song_list[9]])
311
+ if Le_songs == track_song_list[5]:
312
+ st.session_state.s_url = track_actual_url_list[5]
313
+
314
+ elif Le_songs == track_song_list[6]:
315
+ st.session_state.s_url = track_actual_url_list[6]
316
+
317
+ elif Le_songs == track_song_list[7]:
318
+ st.session_state.s_url = track_actual_url_list[7]
319
+
320
+ elif Le_songs == track_song_list[8]:
321
+ st.session_state.s_url = track_actual_url_list[8]
322
+
323
+ elif Le_songs == track_song_list[9]:
324
+ st.session_state.s_url = track_actual_url_list[9]
325
+
326
+ st.write('Previews')
327
+
328
+ components.iframe(track_actual_url_list[5], height=100)
329
+ components.iframe(track_actual_url_list[6], height=100)
330
+ components.iframe(track_actual_url_list[7], height=100)
331
+ components.iframe(track_actual_url_list[8], height=100)
332
+ components.iframe(track_actual_url_list[9], height=100)
333
+ if pages == "3":
334
+ Le_songs = st.radio(
335
+ "Its time to choose...",
336
+ [track_song_list[10],track_song_list[11],track_song_list[12],track_song_list[13],track_song_list[14]])
337
+
338
+ if Le_songs == track_song_list[10]:
339
+ st.session_state.s_url = track_actual_url_list[10]
340
+
341
+ elif Le_songs == track_song_list[11]:
342
+ st.session_state.s_url = track_actual_url_list[11]
343
+
344
+ elif Le_songs == track_song_list[12]:
345
+ st.session_state.s_url = track_actual_url_list[12]
346
+
347
+ elif Le_songs == track_song_list[13]:
348
+ st.session_state.s_url = track_actual_url_list[13]
349
+
350
+ elif Le_songs == track_song_list[14]:
351
+ st.session_state.s_url = track_actual_url_list[14]
352
+
353
+ st.write('Previews')
354
+
355
+ components.iframe(track_actual_url_list[10], height=100)
356
+ components.iframe(track_actual_url_list[11], height=100)
357
+ components.iframe(track_actual_url_list[12], height=100)
358
+ components.iframe(track_actual_url_list[13], height=100)
359
+ components.iframe(track_actual_url_list[14], height=100)
360
+ if pages == "4":
361
+ Le_songs = st.radio(
362
+ "Its time to choose...",
363
+ [track_song_list[15],track_song_list[16],track_song_list[17],track_song_list[18],track_song_list[19]])
364
+
365
+ if Le_songs == track_song_list[15]:
366
+ st.session_state.s_url = track_actual_url_list[15]
367
+
368
+ elif Le_songs == track_song_list[16]:
369
+ st.session_state.s_url = track_actual_url_list[16]
370
+
371
+ elif Le_songs == track_song_list[17]:
372
+ st.session_state.s_url = track_actual_url_list[17]
373
+
374
+ elif Le_songs == track_song_list[18]:
375
+ st.session_state.s_url = track_actual_url_list[18]
376
+
377
+ elif Le_songs == track_song_list[19]:
378
+ st.session_state.s_url = track_actual_url_list[19]
379
+
380
+ st.write('Previews')
381
+
382
+ components.iframe(track_actual_url_list[15], height=100)
383
+ components.iframe(track_actual_url_list[16], height=100)
384
+ components.iframe(track_actual_url_list[17], height=100)
385
+ components.iframe(track_actual_url_list[18], height=100)
386
+ components.iframe(track_actual_url_list[19], height=100)
387
+
388
+ else:
389
+ st.write("""If you have clicked on an option, click on "Get recommendations" button to get recommendations""")
390
+
391
+
392
+ st.write(result_length)
393
+
394
+ st.session_state.song_url = st.session_state.s_url
395
+ Url = st.text_input(label="Song Url ",key='song_url',on_change=update_song_url)
396
+
397
+ song_page()
398
+ state =st.button('Get Recommendations')
399
+ with st.expander("Here's how to find any Song URL in Spotify"):
400
+ st.write("""
401
+ - Search for Song on the Spotify app
402
+ - Right Click on the Song you like
403
+ - Click "Share"
404
+ - Choose "Copy link to Song"
405
+ """)
406
+ st.markdown("<br>", unsafe_allow_html=True)
407
+ st.image('spotify_get_song_url.png')
408
+
409
+
410
+ if state:
411
+ song_recomm()
412
+ elif radio == "Artist Top Tracks" :
413
+ st.session_state.artist_url = st.session_state.a_url
414
+ Url = st.text_input(label="Artist Url",key='artist_url',on_change=update_artist_url)
415
+ artist_page()
416
+ state =st.button('Get Recommendations')
417
+ with st.expander("Here's how to find any Artist URL in Spotify"):
418
+ st.write("""
419
+ - Search for Artist on the Spotify app
420
+ - Right Click on the Artist you like
421
+ - Click "Share"
422
+ - Choose "Copy link to Artist"
423
+ """)
424
+ st.markdown("<br>", unsafe_allow_html=True)
425
+ st.image('spotify_get_artist_url.png')
426
+ if state:
427
+ art_recomm()
428
+
429
+ def result_page():
430
+ if 'rs' not in st.session_state:
431
+ st.error('Please select a model on the Home page and run Get Recommendations')
432
+ else:
433
+ st.success('Top {} recommendations'.format(len(st.session_state.rs)))
434
+ i=0
435
+ for uri in st.session_state.rs:
436
+ uri_link = "https://open.spotify.com/embed/track/" + uri + "?utm_source=generator&theme=0"
437
+ components.iframe(uri_link, height=80)
438
+ i+=1
439
+ if i%5==0:
440
+ time.sleep(1)
441
+ def Log_page():
442
+ log=st.checkbox('Display Output', True, key='display_output')
443
+ if log == True:
444
+ if 'err' in st.session_state:
445
+ st.write(st.session_state.err)
446
+ with open('Data/streamlit.csv') as f:
447
+ st.download_button('Download Dataset', f,file_name='streamlit.csv')
448
+ def About_page():
449
+ st.header('Development')
450
+ """
451
+ Made by Amphibient S.A. of C.V. with special thanks to Red for being the very base of this project.
452
+ """
453
+ st.subheader('Spotify Million Playlist Dataset')
454
+ """
455
+ We're using the Million Playlist Dataset, which, as its name implies, consists of one million playlists.
456
+ contains a number of songs, and some metadata is included as well, such as the name of the playlist, duration, number of songs, number of artists, etc.
457
+ This allows for a great accuracy score and a larger number of songs scored according to how people organize their public playlists
458
+ """
459
+
460
+ """
461
+ It is created by sampling playlists from the billions of playlists that Spotify users have created over the years.
462
+ Playlists that meet the following criteria were selected at random:
463
+ - Created by a user that resides in the United States and is at least 13 years old
464
+ - Was a public playlist at the time the MPD was generated
465
+ - Contains at least 10 tracks
466
+ - Contains no more than 300 tracks
467
+ - Contains at least 3 unique artists
468
+ - Contains at least 2 unique albums
469
+ - Has no local tracks (local tracks are non-Spotify tracks that a user has on their local device)
470
+ - Has at least one follower (not including the creator)
471
+ - Was created after January 1, 2010 and before December 1, 2020
472
+ - Does not have an offensive title
473
+ - Does not have an adult-oriented title if the playlist was created by a user under 18 years of age
474
+ Information about the Dataset [here](https://www.aicrowd.com/challenges/spotify-million-playlist-dataset-challenge)
475
+ """
476
+ st.subheader('Audio Features Explanation')
477
+ """
478
+ This is the list of audio features that we use to determine the similarity between songs.
479
+ For anyone who would like to inspect the source code
480
+
481
+ | Variable | Description |
482
+ | :----: | :---: |
483
+ | Acousticness | A confidence measure from 0.0 to 1.0 of whether the track is acoustic. 1.0 represents high confidence the track is acoustic. |
484
+ | Danceability | Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable. |
485
+ | Energy | Energy is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy, while a Bach prelude scores low on the scale. Perceptual features contributing to this attribute include dynamic range, perceived loudness, timbre, onset rate, and general entropy. |
486
+ | Instrumentalness | Predicts whether a track contains no vocals. "Ooh" and "aah" sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly "vocal". The closer the instrumentalness value is to 1.0, the greater likelihood the track contains no vocal content. Values above 0.5 are intended to represent instrumental tracks, but confidence is higher as the value approaches 1.0. |
487
+ | Key | The key the track is in. Integers map to pitches using standard Pitch Class notation. E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on. If no key was detected, the value is -1. |
488
+ | Liveness | Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. A value above 0.8 provides strong likelihood that the track is live. |
489
+ | Loudness | The overall loudness of a track in decibels (dB). Loudness values are averaged across the entire track and are useful for comparing relative loudness of tracks. Loudness is the quality of a sound that is the primary psychological correlate of physical strength (amplitude). Values typically range between -60 and 0 db. |
490
+ | Mode | Mode indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived. Major is represented by 1 and minor is 0. |
491
+ | Speechiness | Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the recording (e.g. talk show, audio book, poetry), the closer to 1.0 the attribute value. Values above 0.66 describe tracks that are probably made entirely of spoken words. Values between 0.33 and 0.66 describe tracks that may contain both music and speech, either in sections or layered, including such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like tracks. |
492
+ | Tempo | The overall estimated tempo of a track in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece and derives directly from the average beat duration. |
493
+ | Time Signature | An estimated time signature. The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure). The time signature ranges from 3 to 7 indicating time signatures of "3/4", to "7/4". |
494
+ | Valence | A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry). |
495
+
496
+ Information about features: [here](https://developer.spotify.com/documentation/web-api/reference/#/operations/get-audio-features)
497
+ """
498
+
499
+ def main():
500
+ spr_sidebar()
501
+ if st.session_state.app_mode == 'Home':
502
+ home_page()
503
+ if st.session_state.app_mode == 'Result':
504
+ result_page()
505
+ if st.session_state.app_mode == 'About' :
506
+ About_page()
507
+ if st.session_state.app_mode == 'Log':
508
+ Log_page()
509
+ # Run main()
510
+ #if __name__ == '__main__': this doesnt allow reletive imports >:()
511
+ main()