Spaces:
Sleeping
Sleeping
Taejun Kim
commited on
Commit
•
afa4c92
1
Parent(s):
b1d66c1
Update
Browse files
app.py
CHANGED
@@ -1,20 +1,43 @@
|
|
1 |
import gradio as gr
|
2 |
import allin1
|
3 |
|
|
|
4 |
|
5 |
-
|
|
|
|
|
6 |
result = allin1.analyze(
|
7 |
-
|
8 |
keep_byproducts=True, # TODO: remove this
|
9 |
)
|
|
|
|
|
10 |
|
11 |
-
return
|
12 |
|
13 |
|
14 |
with gr.Blocks() as demo:
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
import allin1
|
3 |
|
4 |
+
from pathlib import Path
|
5 |
|
6 |
+
|
7 |
+
def greet(path, progress=gr.Progress(track_tqdm=True)):
|
8 |
+
path = Path(path)
|
9 |
result = allin1.analyze(
|
10 |
+
path,
|
11 |
keep_byproducts=True, # TODO: remove this
|
12 |
)
|
13 |
+
fig = allin1.visualize(result)
|
14 |
+
allin1.sonify(result, out_dir='./sonif')
|
15 |
|
16 |
+
return fig, f'./sonif/{path.stem}.sonif{path.suffix}'
|
17 |
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
+
input_audio_path = gr.Audio(
|
21 |
+
label='Input',
|
22 |
+
source='upload',
|
23 |
+
type='filepath',
|
24 |
+
format='mp3',
|
25 |
+
show_download_button=False,
|
26 |
+
)
|
27 |
+
output_viz = gr.Plot(label='Visualization')
|
28 |
+
output_sonif = gr.Audio(
|
29 |
+
label='Sonification',
|
30 |
+
type='filepath',
|
31 |
+
format='mp3',
|
32 |
+
show_download_button=False,
|
33 |
+
)
|
34 |
+
greet_btn = gr.Button('Analyze')
|
35 |
+
greet_btn.click(
|
36 |
+
fn=greet,
|
37 |
+
inputs=input_audio_path,
|
38 |
+
outputs=[output_viz, output_sonif],
|
39 |
+
api_name='greet',
|
40 |
+
)
|
41 |
|
42 |
+
if __name__ == '__main__':
|
43 |
+
demo.queue().launch()
|