firagne commited on
Commit
2672b0d
1 Parent(s): 0fb5151

test with json results

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -85,7 +85,7 @@ def process(file_name, embed_html_all):
85
  print("search time :", time.time() - timestart)
86
 
87
  tops = get_topN(I, ind_filenames, url_dict, catalog, max_results)
88
- formated = [("Choose a result to play", "")]
89
  output_csv = f"{file_name}_results.csv"
90
  with open(output_csv, "w") as w:
91
  writer = csv.writer(w)
@@ -103,7 +103,7 @@ def process(file_name, embed_html_all):
103
  else:
104
  writer.writerow([file, "no metadata provided"])
105
 
106
- formated.append((file, top))
107
 
108
  return (embed_html_all, output_csv, formated)
109
  """except:
@@ -136,6 +136,7 @@ with gr.Blocks() as demo:
136
 
137
  with gr.Row():
138
  with gr.Column():
 
139
  select_results = gr.Dropdown()
140
  audio_player = gr.Audio()
141
 
@@ -146,6 +147,16 @@ with gr.Blocks() as demo:
146
  select_results.select(
147
  fn=change_audio, inputs=select_results, outputs=audio_player
148
  )
 
 
 
 
 
 
 
 
 
 
149
  # for i in range(max_output):
150
 
151
  # tops.append(
@@ -156,7 +167,7 @@ with gr.Blocks() as demo:
156
  analyze_url_btn.click(
157
  process_url,
158
  inputs=[audio_url_input],
159
- outputs=[html, csv_results, select_results.choices],
160
  )
161
  gr.Examples(
162
  examples=[
@@ -168,14 +179,14 @@ with gr.Blocks() as demo:
168
  "https://www.youtube.com/watch?v=Guzu9aAeDIc",
169
  ],
170
  inputs=[audio_url_input],
171
- outputs=[html, csv_results, select_results.choices],
172
  fn=process_url,
173
  cache_examples=False,
174
  )
175
  analyze_file_btn.click(
176
  process_file,
177
  inputs=[audio_input_file],
178
- outputs=[csv_results, select_results.choices],
179
  )
180
 
181
 
 
85
  print("search time :", time.time() - timestart)
86
 
87
  tops = get_topN(I, ind_filenames, url_dict, catalog, max_results)
88
+ formated = [{"f": "Choose a result to play", "t": ""}]
89
  output_csv = f"{file_name}_results.csv"
90
  with open(output_csv, "w") as w:
91
  writer = csv.writer(w)
 
103
  else:
104
  writer.writerow([file, "no metadata provided"])
105
 
106
+ formated.append({"f": file, "t": top})
107
 
108
  return (embed_html_all, output_csv, formated)
109
  """except:
 
136
 
137
  with gr.Row():
138
  with gr.Column():
139
+ results = gr.JSON(visible=False)
140
  select_results = gr.Dropdown()
141
  audio_player = gr.Audio()
142
 
 
147
  select_results.select(
148
  fn=change_audio, inputs=select_results, outputs=audio_player
149
  )
150
+
151
+ def update_select(json_results):
152
+ select_results = gr.Dropdown(
153
+ choices=[k.values() for k in json_results]
154
+ )
155
+ return select_results
156
+
157
+ results.change(
158
+ fn=update_select, input=results, outputs=select_results
159
+ )
160
  # for i in range(max_output):
161
 
162
  # tops.append(
 
167
  analyze_url_btn.click(
168
  process_url,
169
  inputs=[audio_url_input],
170
+ outputs=[html, csv_results, results],
171
  )
172
  gr.Examples(
173
  examples=[
 
179
  "https://www.youtube.com/watch?v=Guzu9aAeDIc",
180
  ],
181
  inputs=[audio_url_input],
182
+ outputs=[html, csv_results, results],
183
  fn=process_url,
184
  cache_examples=False,
185
  )
186
  analyze_file_btn.click(
187
  process_file,
188
  inputs=[audio_input_file],
189
+ outputs=[csv_results, results],
190
  )
191
 
192