MT3 / app.py
Ahsen Khaliq
Update app.py
47cf8fb
raw history blame
No virus
1.68 kB
import gradio as gr
import os
from pathlib import Path
os.system("pip install gsutil")
os.system("git clone --branch=main https://github.com/google-research/t5x")
os.system("mv t5x t5x_tmp; mv t5x_tmp/* .; rm -r t5x_tmp")
os.system("sed -i 's:jax\[tpu\]:jax:' setup.py")
os.system("python3 -m pip install -e .")
# install mt3
os.system("git clone --branch=main https://github.com/magenta/mt3")
os.system("mv mt3 mt3_tmp; mv mt3_tmp/* .; rm -r mt3_tmp")
os.system("python3 -m pip install -e .")
# copy checkpoints
os.system("gsutil -q -m cp -r gs://mt3/checkpoints .")
# copy soundfont (originally from https://sites.google.com/site/soundfonts4u)
os.system("gsutil -q -m cp gs://magentadata/soundfonts/SGM-v2.01-Sal-Guit-Bass-V1.3.sf2 .")
def inference(audio):
os.system("midi_ddsp_synthesize --midi_path "+audio.name)
return Path(audio.name).stem+"/0_violin.wav"
title = "Midi-DDSP"
description = "Gradio demo for MIDI-DDSP: Detailed Control of Musical Performance via Hierarchical Modeling. To use it, simply upload your midi file, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2112.09312' target='_blank'>MIDI-DDSP: Detailed Control of Musical Performance via Hierarchical Modeling</a> | <a href='https://github.com/magenta/midi-ddsp' target='_blank'>Github Repo</a></p>"
examples=[['input.mid']]
gr.Interface(
inference,
gr.inputs.File(type="file", label="Input"),
[gr.outputs.Audio(type="file", label="Output")],
title=title,
description=description,
article=article,
examples=examples,
enable_queue=True
).launch(debug=True)