File size: 951 Bytes
27b1390
b1d66c1
27b1390
afa4c92
27b1390
afa4c92
 
 
b1d66c1
afa4c92
b1d66c1
 
afa4c92
 
b1d66c1
756b159
b1d66c1
 
 
afa4c92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
756b159
afa4c92
b1d66c1
afa4c92
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import gradio as gr
import allin1

from pathlib import Path


def greet(path, progress=gr.Progress(track_tqdm=True)):
  path = Path(path)
  result = allin1.analyze(
    path,
    keep_byproducts=True,  # TODO: remove this
  )
  fig = allin1.visualize(result)
  allin1.sonify(result, out_dir='./sonif')

  return fig, Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()


with gr.Blocks() as demo:
  input_audio_path = gr.Audio(
    label='Input',
    source='upload',
    type='filepath',
    format='mp3',
    show_download_button=False,
  )
  output_viz = gr.Plot(label='Visualization')
  output_sonif = gr.Audio(
    label='Sonification',
    type='filepath',
    format='mp3',
    show_download_button=False,
  )
  greet_btn = gr.Button('Analyze')
  greet_btn.click(
    fn=greet,
    inputs=input_audio_path,
    outputs=[output_viz, output_sonif],
    api_name='analyze',
  )

if __name__ == '__main__':
  demo.queue().launch()