Spaces:
Sleeping
Sleeping
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, f'./sonif/{path.stem}.sonif{path.suffix}' | |
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='greet', | |
) | |
if __name__ == '__main__': | |
demo.queue().launch() | |