Spaces:
Running
on
Zero
Running
on
Zero
Continue ➡️
Browse files
app.py
CHANGED
@@ -18,6 +18,20 @@ def gen(piano_only, piano_seed, length):
|
|
18 |
else:
|
19 |
ccc = '<pad>'
|
20 |
for item in musicgen(ccc, piano_only=piano_only, length=length):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
midi = item
|
22 |
yield item, None, None
|
23 |
bio = BytesIO()
|
@@ -41,5 +55,7 @@ with gr.Blocks() as demo:
|
|
41 |
txtout = gr.Textbox(interactive=False, label="MIDI Tokens")
|
42 |
fileout = gr.File(interactive=False, label="MIDI File", type="binary")
|
43 |
audioout = gr.Audio(interactive=False, label="Audio")
|
44 |
-
|
|
|
|
|
45 |
demo.queue(api_open=False, default_concurrency_limit=5).launch(show_api=False)
|
|
|
18 |
else:
|
19 |
ccc = '<pad>'
|
20 |
for item in musicgen(ccc, piano_only=piano_only, length=length):
|
21 |
+
midi = item
|
22 |
+
yield item, None, None, None
|
23 |
+
bio = BytesIO()
|
24 |
+
cfg = VocabConfig.from_json('./vocab_config.json')
|
25 |
+
text = midi.strip()
|
26 |
+
mid = midi_util.convert_str_to_midi(cfg, text)
|
27 |
+
with tempfile.NamedTemporaryFile(suffix='.midi', delete=False) as tmp, tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as aud:
|
28 |
+
mid.save(tmp.name)
|
29 |
+
fs.midi_to_audio(tmp.name, aud.name)
|
30 |
+
yield midi, tmp.name, aud.name, gr.update(visible=True)
|
31 |
+
@spaces.GPU(enable_queue=True)
|
32 |
+
def continueit(piano_only, piano_seed, length, txtout):
|
33 |
+
midi = ''
|
34 |
+
for item in musicgen(txtout.strip().strip('<end>').strip(), piano_only=piano_only, length=length):
|
35 |
midi = item
|
36 |
yield item, None, None
|
37 |
bio = BytesIO()
|
|
|
55 |
txtout = gr.Textbox(interactive=False, label="MIDI Tokens")
|
56 |
fileout = gr.File(interactive=False, label="MIDI File", type="binary")
|
57 |
audioout = gr.Audio(interactive=False, label="Audio")
|
58 |
+
continuebtn = gr.Button("Continue ➡️", visible=False)
|
59 |
+
synth.click(gen, inputs=[piano_only, piano_seed, length], outputs=[txtout, fileout, audioout, continuebtn])
|
60 |
+
continuebtn.click(gen, inputs=[piano_only, piano_seed, length, txtout], outputs=[txtout, fileout, audioout])
|
61 |
demo.queue(api_open=False, default_concurrency_limit=5).launch(show_api=False)
|