asigalov61
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,16 @@ from pytz import timezone
|
|
8 |
import gradio as gr
|
9 |
|
10 |
def classify_lyrics(lyric):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
search_query = lyric
|
13 |
|
@@ -25,6 +35,8 @@ def classify_lyrics(lyric):
|
|
25 |
random.shuffle(lyrics_set_final)
|
26 |
|
27 |
texts_match_ratios = []
|
|
|
|
|
28 |
|
29 |
for l in lyrics_set_final:
|
30 |
|
@@ -41,9 +53,13 @@ def classify_lyrics(lyric):
|
|
41 |
sorted_texts_match_ratios = sorted(set(texts_match_ratios), reverse=True)
|
42 |
|
43 |
result = lyrics_set_final[texts_match_ratios.index(sorted_texts_match_ratios[0])][:2]
|
44 |
-
|
45 |
-
print(
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
return sorted_texts_match_ratios[0], result[0], result[1]
|
48 |
|
49 |
demo = gr.Interface(
|
@@ -53,8 +69,7 @@ demo = gr.Interface(
|
|
53 |
gr.Textbox(label="Title/Artist"),
|
54 |
gr.Textbox(label="Genre (if identified)")],
|
55 |
title="Algorithmic Lyrics Classifier",
|
56 |
-
description="Algorithmic match lyrics classification by artist and genre"
|
57 |
-
gr.Markdown("![Visitors](https://api.visitorbadge.io/api/visitors?path=asigalov61.Algorithmic-Lyrics-Classifier&style=flat)\n\n")
|
58 |
)
|
59 |
|
60 |
if __name__ == "__main__":
|
|
|
8 |
import gradio as gr
|
9 |
|
10 |
def classify_lyrics(lyric):
|
11 |
+
|
12 |
+
print('=' * 70)
|
13 |
+
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
14 |
+
start_time = time.time()
|
15 |
+
|
16 |
+
print('=' * 70)
|
17 |
+
print('Req string:', lyric)
|
18 |
+
|
19 |
+
print('=' * 70)
|
20 |
+
print('Preparing to search...')
|
21 |
|
22 |
search_query = lyric
|
23 |
|
|
|
35 |
random.shuffle(lyrics_set_final)
|
36 |
|
37 |
texts_match_ratios = []
|
38 |
+
|
39 |
+
print('Searching titles...Please wait...')
|
40 |
|
41 |
for l in lyrics_set_final:
|
42 |
|
|
|
53 |
sorted_texts_match_ratios = sorted(set(texts_match_ratios), reverse=True)
|
54 |
|
55 |
result = lyrics_set_final[texts_match_ratios.index(sorted_texts_match_ratios[0])][:2]
|
56 |
+
|
57 |
+
print('Done!')
|
58 |
+
print('=' * 70)
|
59 |
+
print('Search match ratio:', sorted_texts_match_ratios[0])
|
60 |
+
print('Found title/artist and genre:',result[0], "---", result[1])
|
61 |
+
print('=' * 70)
|
62 |
+
|
63 |
return sorted_texts_match_ratios[0], result[0], result[1]
|
64 |
|
65 |
demo = gr.Interface(
|
|
|
69 |
gr.Textbox(label="Title/Artist"),
|
70 |
gr.Textbox(label="Genre (if identified)")],
|
71 |
title="Algorithmic Lyrics Classifier",
|
72 |
+
description="Algorithmic match lyrics classification by artist and genre"
|
|
|
73 |
)
|
74 |
|
75 |
if __name__ == "__main__":
|