firagne commited on
Commit
607f1ae
1 Parent(s): 0baca95

add results file

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -8,6 +8,7 @@ import sys
8
  import uuid
9
  import traceback
10
  import tensorflow
 
11
 
12
  embed_html1 = '<iframe width="560" height="315" src="https://www.youtube.com/embed/'
13
  embed_html2 = '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
@@ -85,7 +86,15 @@ def process(file_name, embed_html_all):
85
  file = os.path.splitext(os.path.basename(ind_filenames[I[0][0]]))[0]
86
  formated.append(file)
87
  formated.append(tops[i])
88
- return (embed_html_all, *formated)
 
 
 
 
 
 
 
 
89
  """except:
90
  return embed_html_all, "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", ""
91
  """
@@ -111,6 +120,10 @@ with gr.Blocks() as demo:
111
  audio_input_file = gr.Audio(type="filepath", label="Audio Input")
112
  analyze_file_btn = gr.Button("Search from file")
113
 
 
 
 
 
114
  with gr.Row():
115
  with gr.Column():
116
  for i in range(max_results):
@@ -124,6 +137,7 @@ with gr.Blocks() as demo:
124
  inputs=[audio_url_input],
125
  outputs=[
126
  html,
 
127
  *tops,
128
  ],
129
  )
@@ -139,6 +153,7 @@ with gr.Blocks() as demo:
139
  inputs=[audio_url_input],
140
  outputs=[
141
  html,
 
142
  *tops,
143
  ],
144
  fn=process_url,
@@ -147,7 +162,10 @@ with gr.Blocks() as demo:
147
  analyze_file_btn.click(
148
  process_file,
149
  inputs=[audio_input_file],
150
- outputs=tops,
 
 
 
151
  )
152
 
153
 
 
8
  import uuid
9
  import traceback
10
  import tensorflow
11
+ import csv
12
 
13
  embed_html1 = '<iframe width="560" height="315" src="https://www.youtube.com/embed/'
14
  embed_html2 = '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
 
86
  file = os.path.splitext(os.path.basename(ind_filenames[I[0][0]]))[0]
87
  formated.append(file)
88
  formated.append(tops[i])
89
+
90
+ output_csv = f"{file_name}_results.csv"
91
+ with open(output_csv, "w") as w:
92
+ writer = csv.writer(w)
93
+ for top in tops:
94
+ file = os.path.splitext(os.path.basename(top))[0]
95
+ writer.writerow(dict_catalog[top].values())
96
+
97
+ return (embed_html_all, output_csv, *formated)
98
  """except:
99
  return embed_html_all, "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", "", "Erreur Input", ""
100
  """
 
120
  audio_input_file = gr.Audio(type="filepath", label="Audio Input")
121
  analyze_file_btn = gr.Button("Search from file")
122
 
123
+ with gr.Row():
124
+ with gr.Column():
125
+ results = gr.File()
126
+
127
  with gr.Row():
128
  with gr.Column():
129
  for i in range(max_results):
 
137
  inputs=[audio_url_input],
138
  outputs=[
139
  html,
140
+ results,
141
  *tops,
142
  ],
143
  )
 
153
  inputs=[audio_url_input],
154
  outputs=[
155
  html,
156
+ results,
157
  *tops,
158
  ],
159
  fn=process_url,
 
162
  analyze_file_btn.click(
163
  process_file,
164
  inputs=[audio_input_file],
165
+ outputs=[
166
+ results,
167
+ tops,
168
+ ],
169
  )
170
 
171