asigalov61
commited on
Commit
•
d85cb0d
1
Parent(s):
58881e0
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ def run(search_prompt, mid=None, progress=gr.Progress()):
|
|
20 |
for m in progress.tqdm(meta_data):
|
21 |
mid_seq = m[1][17:-1]
|
22 |
mid_seq_ticks = m[1][16][1]
|
23 |
-
mdata = m[1][:
|
24 |
|
25 |
elif mid is not None:
|
26 |
mid_seq = MIDI.midi2score(mid)
|
@@ -30,16 +30,6 @@ def run(search_prompt, mid=None, progress=gr.Progress()):
|
|
30 |
audio = synthesis(MIDI.score2opus([mid_seq_ticks, mid_seq]), soundfont_path)
|
31 |
yield mdata, "output.mid", (44100, audio)
|
32 |
|
33 |
-
|
34 |
-
def cancel_run(mid_seq):
|
35 |
-
if mid_seq is None:
|
36 |
-
return None, None
|
37 |
-
|
38 |
-
with open(f"output.mid", 'wb') as f:
|
39 |
-
f.write(MIDI.score2midi([1000, mid_seq]))
|
40 |
-
audio = synthesis(MIDI.score2opus([1000, mid_seq]), soundfont_path)
|
41 |
-
return "output.mid", (44100, audio)
|
42 |
-
|
43 |
if __name__ == "__main__":
|
44 |
parser = argparse.ArgumentParser()
|
45 |
parser.add_argument("--share", action="store_true", default=False, help="share gradio app")
|
@@ -85,7 +75,6 @@ if __name__ == "__main__":
|
|
85 |
input_allow_cc = gr.Checkbox(label="allow midi cc event", value=True)
|
86 |
|
87 |
search_btn = gr.Button("search", variant="primary")
|
88 |
-
stop_btn = gr.Button("stop and output")
|
89 |
|
90 |
output_audio = gr.Audio(label="output audio", format="mp3", elem_id="midi_audio")
|
91 |
output_midi = gr.File(label="output midi", file_types=[".mid"])
|
@@ -93,5 +82,5 @@ if __name__ == "__main__":
|
|
93 |
|
94 |
run_event = search_btn.click(run, [search_prompt],
|
95 |
[output_midi_seq, output_midi, output_audio])
|
96 |
-
|
97 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|
|
|
20 |
for m in progress.tqdm(meta_data):
|
21 |
mid_seq = m[1][17:-1]
|
22 |
mid_seq_ticks = m[1][16][1]
|
23 |
+
mdata = m[1][:16]
|
24 |
|
25 |
elif mid is not None:
|
26 |
mid_seq = MIDI.midi2score(mid)
|
|
|
30 |
audio = synthesis(MIDI.score2opus([mid_seq_ticks, mid_seq]), soundfont_path)
|
31 |
yield mdata, "output.mid", (44100, audio)
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
if __name__ == "__main__":
|
34 |
parser = argparse.ArgumentParser()
|
35 |
parser.add_argument("--share", action="store_true", default=False, help="share gradio app")
|
|
|
75 |
input_allow_cc = gr.Checkbox(label="allow midi cc event", value=True)
|
76 |
|
77 |
search_btn = gr.Button("search", variant="primary")
|
|
|
78 |
|
79 |
output_audio = gr.Audio(label="output audio", format="mp3", elem_id="midi_audio")
|
80 |
output_midi = gr.File(label="output midi", file_types=[".mid"])
|
|
|
82 |
|
83 |
run_event = search_btn.click(run, [search_prompt],
|
84 |
[output_midi_seq, output_midi, output_audio])
|
85 |
+
|
86 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|