Taejun Kim commited on
Commit
afa4c92
1 Parent(s): b1d66c1
Files changed (1) hide show
  1. app.py +31 -8
app.py CHANGED
@@ -1,20 +1,43 @@
1
  import gradio as gr
2
  import allin1
3
 
 
4
 
5
- def greet(name, progress=gr.Progress(track_tqdm=True)):
 
 
6
  result = allin1.analyze(
7
- name,
8
  keep_byproducts=True, # TODO: remove this
9
  )
 
 
10
 
11
- return result
12
 
13
 
14
  with gr.Blocks() as demo:
15
- name = gr.Audio(source='upload', type='filepath')
16
- output = gr.Textbox(label="Output Box")
17
- greet_btn = gr.Button("Greet")
18
- greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- demo.queue().launch()
 
 
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()