mrfakename commited on
Commit
46f15cd
·
verified ·
1 Parent(s): 6f5cd14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -5,9 +5,9 @@ import midi_util
5
  from midi_util import VocabConfig
6
  from midi2audio import FluidSynth
7
  fs = FluidSynth()
8
- def gen(piano_only):
9
  midi = ''
10
- for item in musicgen(piano_only=piano_only):
11
  midi = item
12
  yield item, None, None
13
  bio = BytesIO()
@@ -20,9 +20,10 @@ def gen(piano_only):
20
  return midi, bio.getvalue(), audio.getvalue()
21
  with gr.Blocks() as demo:
22
  piano_only = gr.Checkbox(label="Piano Only")
 
23
  synth = gr.Button("Synthesize")
24
  txtout = gr.Textbox(interactive=False)
25
  fileout = gr.File(interactive=False)
26
  audioout = gr.Audio(interactive=False)
27
- synth.click(gen, inputs=[piano_only], outputs=[txtout, fileout, audioout])
28
  demo.queue().launch()
 
5
  from midi_util import VocabConfig
6
  from midi2audio import FluidSynth
7
  fs = FluidSynth()
8
+ def gen(piano_only, length):
9
  midi = ''
10
+ for item in musicgen(piano_only=piano_only, length=length):
11
  midi = item
12
  yield item, None, None
13
  bio = BytesIO()
 
20
  return midi, bio.getvalue(), audio.getvalue()
21
  with gr.Blocks() as demo:
22
  piano_only = gr.Checkbox(label="Piano Only")
23
+ length = gr.Slider(label="Length", minimum=4, maximum=4096, step=1)
24
  synth = gr.Button("Synthesize")
25
  txtout = gr.Textbox(interactive=False)
26
  fileout = gr.File(interactive=False)
27
  audioout = gr.Audio(interactive=False)
28
+ synth.click(gen, inputs=[piano_only, length], outputs=[txtout, fileout, audioout])
29
  demo.queue().launch()