Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,10 +26,7 @@ generator = torch.Generator(device)
|
|
26 |
def predict(midi_file=None, prompt="", negative_prompt="", audio_length_in_s=10, random_seed=0, controlnet_conditioning_scale=1, num_inference_steps=20, guidance_scale=2.5, guess_mode=False):
|
27 |
if isinstance(midi_file, _TemporaryFileWrapper):
|
28 |
midi_file = midi_file.name
|
29 |
-
|
30 |
-
midi = PrettyMIDI(midi_file)
|
31 |
-
else:
|
32 |
-
midi = midi_file
|
33 |
audio = pipe(
|
34 |
prompt,
|
35 |
negative_prompt=negative_prompt,
|
@@ -51,6 +48,9 @@ def synthesize(midi_file=None):
|
|
51 |
midi_synth = midi_synth.reshape(midi_synth.shape[0], 1)
|
52 |
return midi, (SAMPLE_RATE, midi_synth)
|
53 |
|
|
|
|
|
|
|
54 |
with gr.Blocks(title="🎹 MIDI-AudioLDM", theme=gr.themes.Base(text_size=gr.themes.sizes.text_md, font=[gr.themes.GoogleFont("Nunito Sans")])) as demo:
|
55 |
gr.HTML(
|
56 |
"""
|
@@ -63,9 +63,10 @@ with gr.Blocks(title="🎹 MIDI-AudioLDM", theme=gr.themes.Base(text_size=gr.the
|
|
63 |
with gr.Row():
|
64 |
with gr.Column(variant='panel'):
|
65 |
midi_synth = gr.Audio(label="synthesized midi")
|
66 |
-
|
67 |
-
midi =
|
68 |
-
midi_file.upload(
|
|
|
69 |
prompt = gr.Textbox(label="prompt", info="Enter a descriptive text prompt to guide the audio generation.")
|
70 |
with gr.Column(variant='panel'):
|
71 |
audio = gr.Audio(label="generated audio")
|
|
|
26 |
def predict(midi_file=None, prompt="", negative_prompt="", audio_length_in_s=10, random_seed=0, controlnet_conditioning_scale=1, num_inference_steps=20, guidance_scale=2.5, guess_mode=False):
|
27 |
if isinstance(midi_file, _TemporaryFileWrapper):
|
28 |
midi_file = midi_file.name
|
29 |
+
midi = PrettyMIDI(midi_file)
|
|
|
|
|
|
|
30 |
audio = pipe(
|
31 |
prompt,
|
32 |
negative_prompt=negative_prompt,
|
|
|
48 |
midi_synth = midi_synth.reshape(midi_synth.shape[0], 1)
|
49 |
return midi, (SAMPLE_RATE, midi_synth)
|
50 |
|
51 |
+
def upload(midi_file=None):
|
52 |
+
return midi_file
|
53 |
+
|
54 |
with gr.Blocks(title="🎹 MIDI-AudioLDM", theme=gr.themes.Base(text_size=gr.themes.sizes.text_md, font=[gr.themes.GoogleFont("Nunito Sans")])) as demo:
|
55 |
gr.HTML(
|
56 |
"""
|
|
|
63 |
with gr.Row():
|
64 |
with gr.Column(variant='panel'):
|
65 |
midi_synth = gr.Audio(label="synthesized midi")
|
66 |
+
upload_button = gr.UploadButton("Upload a MIDI File", file_types=[".mid"])
|
67 |
+
midi = gr.File(visible=False, value="S00.mid")
|
68 |
+
midi_file.upload(upload, upload_button, midi)
|
69 |
+
midi_file.upload(synthesize, midi_file, midi)
|
70 |
prompt = gr.Textbox(label="prompt", info="Enter a descriptive text prompt to guide the audio generation.")
|
71 |
with gr.Column(variant='panel'):
|
72 |
audio = gr.Audio(label="generated audio")
|