mrfakename commited on
Commit
7b603c0
·
verified ·
1 Parent(s): a97e9bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -28,11 +28,15 @@ def gen(piano_only, piano_seed, length):
28
  mid.save(tmp.name)
29
  fs.midi_to_audio(tmp.name, aud.name)
30
  yield midi, tmp.name, aud.name
 
 
31
  with gr.Blocks() as demo:
32
  gr.Markdown("# RWKV 4 Music (MIDI)\n\nThis demo uses the RWKV 4 MIDI model available [here](https://huggingface.co/BlinkDL/rwkv-4-music/blob/main/RWKV-4-MIDI-560M-v1-20230717-ctx4096.pth). Details may be found [here](https://huggingface.co/BlinkDL/rwkv-4-music). The music generation code may be found [here](https://github.com/BlinkDL/ChatRWKV/tree/main/music). The MIDI Tokenizer may be found [here](https://github.com/briansemrau/MIDI-LLM-tokenizer).\n\nNot sure how to play MIDI files? I recommend using the open source [VLC Media Player](https://www.videolan.org/vlc/) with can play MIDI files using FluidSynth.\n\nYou are responsible for your usage.")
33
  piano_only = gr.Checkbox(label="Piano Only")
34
  piano_seed = gr.Checkbox(label="Use Piano Melody Seed")
35
  length = gr.Slider(label="Max Length (in tokens)", minimum=4, maximum=4096, step=1, value=512, info="The audio may still be shorter than this")
 
 
36
  synth = gr.Button("Synthesize")
37
  txtout = gr.Textbox(interactive=False, label="MIDI Tokens")
38
  fileout = gr.File(interactive=False, label="MIDI File", type="binary")
 
28
  mid.save(tmp.name)
29
  fs.midi_to_audio(tmp.name, aud.name)
30
  yield midi, tmp.name, aud.name
31
+ def enable_longer(en):
32
+ return gr.update(maximum=(8192 if en else 4096))
33
  with gr.Blocks() as demo:
34
  gr.Markdown("# RWKV 4 Music (MIDI)\n\nThis demo uses the RWKV 4 MIDI model available [here](https://huggingface.co/BlinkDL/rwkv-4-music/blob/main/RWKV-4-MIDI-560M-v1-20230717-ctx4096.pth). Details may be found [here](https://huggingface.co/BlinkDL/rwkv-4-music). The music generation code may be found [here](https://github.com/BlinkDL/ChatRWKV/tree/main/music). The MIDI Tokenizer may be found [here](https://github.com/briansemrau/MIDI-LLM-tokenizer).\n\nNot sure how to play MIDI files? I recommend using the open source [VLC Media Player](https://www.videolan.org/vlc/) with can play MIDI files using FluidSynth.\n\nYou are responsible for your usage.")
35
  piano_only = gr.Checkbox(label="Piano Only")
36
  piano_seed = gr.Checkbox(label="Use Piano Melody Seed")
37
  length = gr.Slider(label="Max Length (in tokens)", minimum=4, maximum=4096, step=1, value=512, info="The audio may still be shorter than this")
38
+ longer = gr.Checkbox(label="Enable longer generation", info="This will increase the maximum value of the maximum length slider to 8192 even though the model context length is not this long. Results may be substandard and you may get errors.")
39
+ longer.input(enable_longer, inputs=longer, outputs=length)
40
  synth = gr.Button("Synthesize")
41
  txtout = gr.Textbox(interactive=False, label="MIDI Tokens")
42
  fileout = gr.File(interactive=False, label="MIDI File", type="binary")