Spaces:
Build error
Build error
unlock gradio
Browse files- .gitignore +1 -1
- README.md +1 -1
- app.py +58 -23
.gitignore
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
Pipfile
|
| 2 |
Pipfile.lock
|
|
|
|
| 1 |
+
Pipfile*
|
| 2 |
Pipfile.lock
|
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🐢
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
duplicated_from: PierreHanna/AudioSimilarity
|
|
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.16.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
duplicated_from: PierreHanna/AudioSimilarity
|
app.py
CHANGED
|
@@ -90,7 +90,7 @@ def process(file_name, embed_html_all):
|
|
| 90 |
with open(output_csv, "w") as w:
|
| 91 |
writer = csv.writer(w)
|
| 92 |
header = False
|
| 93 |
-
for top in tops:
|
| 94 |
if len(formated) / 2 >= max_output:
|
| 95 |
break
|
| 96 |
|
|
@@ -103,7 +103,7 @@ def process(file_name, embed_html_all):
|
|
| 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:
|
|
@@ -132,36 +132,71 @@ with gr.Blocks() as demo:
|
|
| 132 |
|
| 133 |
with gr.Row():
|
| 134 |
with gr.Column():
|
| 135 |
-
csv_results = gr.File()
|
| 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 |
|
|
|
|
| 143 |
def change_audio(value):
|
| 144 |
-
|
| 145 |
-
|
|
|
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
|
|
|
| 149 |
)
|
| 150 |
-
|
| 151 |
def update_select(json_results):
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
analyze_url_btn.click(
|
| 167 |
process_url,
|
|
|
|
| 90 |
with open(output_csv, "w") as w:
|
| 91 |
writer = csv.writer(w)
|
| 92 |
header = False
|
| 93 |
+
for position, top in enumerate(tops):
|
| 94 |
if len(formated) / 2 >= max_output:
|
| 95 |
break
|
| 96 |
|
|
|
|
| 103 |
else:
|
| 104 |
writer.writerow([file, "no metadata provided"])
|
| 105 |
|
| 106 |
+
formated.append({"f": f"{position+1} - {file}", "t": top})
|
| 107 |
|
| 108 |
return (embed_html_all, output_csv, formated)
|
| 109 |
"""except:
|
|
|
|
| 132 |
|
| 133 |
with gr.Row():
|
| 134 |
with gr.Column():
|
| 135 |
+
csv_results = gr.File(label="Results as CSV")
|
| 136 |
|
| 137 |
with gr.Row():
|
| 138 |
with gr.Column():
|
| 139 |
results = gr.JSON(visible=False)
|
| 140 |
+
select_results = gr.Dropdown(label="Results", choices=[])
|
| 141 |
+
audio_player = gr.Audio(None, label="Results player")
|
| 142 |
|
| 143 |
+
@select_results.select(inputs=select_results, outputs=audio_player)
|
| 144 |
def change_audio(value):
|
| 145 |
+
if value:
|
| 146 |
+
return gr.Audio(value, label="Results player")
|
| 147 |
+
return gr.Audio(None, label="Results player")
|
| 148 |
|
| 149 |
+
@results.change(
|
| 150 |
+
inputs=results,
|
| 151 |
+
outputs=select_results,
|
| 152 |
)
|
|
|
|
| 153 |
def update_select(json_results):
|
| 154 |
+
try:
|
| 155 |
+
print("change dropdown")
|
| 156 |
+
return gr.Dropdown(
|
| 157 |
+
label="Results",
|
| 158 |
+
choices=[(k["f"], k["t"]) for k in json_results],
|
| 159 |
+
value=None,
|
| 160 |
+
)
|
| 161 |
+
except:
|
| 162 |
+
return gr.Dropdown(
|
| 163 |
+
choices=[],
|
| 164 |
+
label="Results",
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
@audio_input_file.change(
|
| 168 |
+
outputs=[
|
| 169 |
+
audio_url_input,
|
| 170 |
+
results,
|
| 171 |
+
select_results,
|
| 172 |
+
csv_results,
|
| 173 |
+
audio_player,
|
| 174 |
+
]
|
| 175 |
+
)
|
| 176 |
+
def cleanup_on_file():
|
| 177 |
+
print("cleanup on file change")
|
| 178 |
+
return (
|
| 179 |
+
gr.Textbox(
|
| 180 |
+
placeholder="YouTube video URL", label="YouTube video URL"
|
| 181 |
+
),
|
| 182 |
+
gr.JSON([{"f": "Choose a result to play", "t": ""}], visible=False),
|
| 183 |
+
gr.Dropdown(label="Results", choices=[]),
|
| 184 |
+
gr.File(None, label="Results as CSV"),
|
| 185 |
+
gr.Audio(None, label="Results player"),
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
@audio_url_input.change(
|
| 189 |
+
outputs=[audio_input_file, results, select_results, csv_results]
|
| 190 |
+
)
|
| 191 |
+
def cleanup_on_url():
|
| 192 |
+
print("cleanup on url change")
|
| 193 |
+
return (
|
| 194 |
+
gr.Audio(None, type="filepath", label="Audio Input"),
|
| 195 |
+
gr.JSON([{"f": "Choose a result to play", "t": ""}], visible=False),
|
| 196 |
+
gr.Dropdown(choices=[], label="Results"),
|
| 197 |
+
gr.File(None, label="Results as CSV"),
|
| 198 |
+
gr.Audio(None, label="Results player"),
|
| 199 |
+
)
|
| 200 |
|
| 201 |
analyze_url_btn.click(
|
| 202 |
process_url,
|