PierreHanna commited on
Commit
b51151a
·
verified ·
1 Parent(s): 9551d15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -29,7 +29,7 @@ ind = get_index()
29
  ind_filenames = get_audio_names()
30
  catalog = get_catalog()
31
  url_dict = get_durl_myma()
32
- dict_catalog = get_dict_catalog() # dict containing track infos : key = track name (without ".mp3")
33
 
34
 
35
  def download_audio_(link):
@@ -64,9 +64,7 @@ def process(audio_file, embed_html_all):
64
  timestart = time.time()
65
  emb, ts = get_embed(audio_file)
66
  print("Embed time :", time.time()-timestart)
67
-
68
-
69
-
70
  _, I = do_search(emb, ind)
71
  print("Search + embed time :", time.time()-timestart)
72
 
@@ -76,7 +74,9 @@ def process(audio_file, embed_html_all):
76
  return embed_html_all, ind_filenames[I[0][0]].split('.')[0], top1, ind_filenames[I[0][1]].split('.')[0], top2, ind_filenames[I[0][2]].split('.')[0], top3, ind_filenames[I[0][3]].split('.')[0], top4, ind_filenames[I[0][4]].split('.')[0], top5, ind_filenames[I[0][5]].split('.')[0], top6, ind_filenames[I[0][6]].split('.')[0], top7, ind_filenames[I[0][7]].split('.')[0], top8, ind_filenames[I[0][8]].split('.')[0], top9, ind_filenames[I[0][9]].split('.')[0], top10
77
  #except:
78
  # return embed_html_all, "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", ""
79
-
 
 
80
  with gr.Blocks() as demo:
81
 
82
  with gr.Row():
@@ -112,8 +112,10 @@ with gr.Blocks() as demo:
112
  gr.HTML("<h3>Top 5</h3>")
113
  top5 = gr.Textbox(label="top5", show_label=False)
114
  '''
115
- top1_name = gr.Textbox(label="top1 track name", show_label=True)
116
  top1 = gr.Audio(label="top1", show_label=False)
 
 
117
  top2_name = gr.Textbox(label="top2 track name", show_label=True)
118
  top2 = gr.Audio(label="top2", show_label=False)
119
  top3_name = gr.Textbox(label="top3 track name", show_label=True)
@@ -136,7 +138,7 @@ with gr.Blocks() as demo:
136
 
137
 
138
  analyze_url_btn.click(process_url, inputs=[audio_url_input],
139
- outputs=[html,top1_name, top1, top2_name, top2, top3_name, top3, top4_name, top4, top5_name, top5, top6_name, top6, top7_name, top7, top8_name, top8, top9_name, top9, top10_name, top10])
140
  gr.Examples(
141
  examples = [
142
  "https://www.youtube.com/watch?v=aNzCDt2eidg",
@@ -146,12 +148,12 @@ with gr.Blocks() as demo:
146
  "https://www.youtube.com/watch?v=dRX0wDNK6S4",#
147
  "https://www.youtube.com/watch?v=Guzu9aAeDIc"],
148
  inputs = [audio_url_input],
149
- outputs = [html,top1_name, top1, top2_name, top2, top3_name, top3, top4_name, top4, top5_name, top5, top6_name, top6, top7_name, top7, top8_name, top8, top9_name, top9, top10_name, top10],
150
  fn = process_url,
151
  cache_examples=False,
152
  )
153
  analyze_file_btn.click(process_file, inputs=[audio_input_file],
154
- outputs=[top1_name, top1, top2_name, top2, top3_name, top3, top4_name, top4, top5_name, top5, top6_name, top6, top7_name, top7, top8_name, top8, top9_name, top9, top10_name, top10])
155
 
156
 
157
  demo.launch(debug=False)
 
29
  ind_filenames = get_audio_names()
30
  catalog = get_catalog()
31
  url_dict = get_durl_myma()
32
+ ###dict_catalog = get_dict_catalog() # dict containing track infos : key = track name (without ".mp3")
33
 
34
 
35
  def download_audio_(link):
 
64
  timestart = time.time()
65
  emb, ts = get_embed(audio_file)
66
  print("Embed time :", time.time()-timestart)
67
+
 
 
68
  _, I = do_search(emb, ind)
69
  print("Search + embed time :", time.time()-timestart)
70
 
 
74
  return embed_html_all, ind_filenames[I[0][0]].split('.')[0], top1, ind_filenames[I[0][1]].split('.')[0], top2, ind_filenames[I[0][2]].split('.')[0], top3, ind_filenames[I[0][3]].split('.')[0], top4, ind_filenames[I[0][4]].split('.')[0], top5, ind_filenames[I[0][5]].split('.')[0], top6, ind_filenames[I[0][6]].split('.')[0], top7, ind_filenames[I[0][7]].split('.')[0], top8, ind_filenames[I[0][8]].split('.')[0], top9, ind_filenames[I[0][9]].split('.')[0], top10
75
  #except:
76
  # return embed_html_all, "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", ""
77
+
78
+ topname=[]
79
+
80
  with gr.Blocks() as demo:
81
 
82
  with gr.Row():
 
112
  gr.HTML("<h3>Top 5</h3>")
113
  top5 = gr.Textbox(label="top5", show_label=False)
114
  '''
115
+ topname[0] = gr.Textbox(label="top1 track name", show_label=True)
116
  top1 = gr.Audio(label="top1", show_label=False)
117
+ #top1_name = gr.Textbox(label="top1 track name", show_label=True)
118
+ #top1 = gr.Audio(label="top1", show_label=False)
119
  top2_name = gr.Textbox(label="top2 track name", show_label=True)
120
  top2 = gr.Audio(label="top2", show_label=False)
121
  top3_name = gr.Textbox(label="top3 track name", show_label=True)
 
138
 
139
 
140
  analyze_url_btn.click(process_url, inputs=[audio_url_input],
141
+ outputs=[html,topname[0], top1, top2_name, top2, top3_name, top3, top4_name, top4, top5_name, top5, top6_name, top6, top7_name, top7, top8_name, top8, top9_name, top9, top10_name, top10])
142
  gr.Examples(
143
  examples = [
144
  "https://www.youtube.com/watch?v=aNzCDt2eidg",
 
148
  "https://www.youtube.com/watch?v=dRX0wDNK6S4",#
149
  "https://www.youtube.com/watch?v=Guzu9aAeDIc"],
150
  inputs = [audio_url_input],
151
+ outputs = [html,topname[0], top1, top2_name, top2, top3_name, top3, top4_name, top4, top5_name, top5, top6_name, top6, top7_name, top7, top8_name, top8, top9_name, top9, top10_name, top10],
152
  fn = process_url,
153
  cache_examples=False,
154
  )
155
  analyze_file_btn.click(process_file, inputs=[audio_input_file],
156
+ outputs=[topname[0], top1, top2_name, top2, top3_name, top3, top4_name, top4, top5_name, top5, top6_name, top6, top7_name, top7, top8_name, top8, top9_name, top9, top10_name, top10])
157
 
158
 
159
  demo.launch(debug=False)