mrfakename commited on
Commit
20f0ed4
·
verified ·
1 Parent(s): f6a823f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -10,9 +10,13 @@ import librosa
10
  from midi2audio import FluidSynth
11
  fs = FluidSynth()
12
 
13
- def gen(piano_only, length):
14
  midi = ''
15
- for item in musicgen(piano_only=piano_only, length=length):
 
 
 
 
16
  midi = item
17
  yield item, None, None
18
  bio = BytesIO()
@@ -26,10 +30,11 @@ def gen(piano_only, length):
26
  with gr.Blocks() as demo:
27
  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.")
28
  piano_only = gr.Checkbox(label="Piano Only")
 
29
  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")
30
  synth = gr.Button("Synthesize")
31
  txtout = gr.Textbox(interactive=False, label="MIDI Tokens")
32
  fileout = gr.File(interactive=False, label="MIDI File", type="binary")
33
  audioout = gr.Audio(interactive=False, label="Audio")
34
- synth.click(gen, inputs=[piano_only, length], outputs=[txtout, fileout, audioout])
35
  demo.queue(api_open=False).launch(show_api=False)
 
10
  from midi2audio import FluidSynth
11
  fs = FluidSynth()
12
 
13
+ def gen(piano_only, piano_seed, length):
14
  midi = ''
15
+ if piano_seed:
16
+ ccc = 'v:5b:3 v:5b:2 t125 t125 t125 t106 pi:43:5 t24 pi:4a:7 t15 pi:4f:7 t17 pi:56:7 t18 pi:54:7 t125 t49 pi:51:7 t117 pi:4d:7 t125 t125 t111 pi:37:7 t14 pi:3e:6 t15 pi:43:6 t12 pi:4a:7 t17 pi:48:7 t125 t60 pi:45:7 t121 pi:41:7 t125 t117 s:46:5 s:52:5 f:46:5 f:52:5 t121 s:45:5 s:46:0 s:51:5 s:52:0 f:45:5 f:46:0 f:51:5 f:52:0 t121 s:41:5 s:45:0 s:4d:5 s:51:0 f:41:5 f:45:0 f:4d:5 f:51:0 t102 pi:37:0 pi:3e:0 pi:41:0 pi:43:0 pi:45:0 pi:48:0 pi:4a:0 pi:4d:0 pi:4f:0 pi:51:0 pi:54:0 pi:56:0 t19 s:3e:5 s:41:0 s:4a:5 s:4d:0 f:3e:5 f:41:0 f:4a:5 f:4d:0 t121 v:3a:5 t121 v:39:7 t15 v:3a:0 t106 v:35:8 t10 v:39:0 t111 v:30:8 v:35:0 t125 t117 v:32:8 t10 v:30:0 t125 t125 t103 v:5b:0 v:5b:0 t9 pi:4a:7'
17
+ else:
18
+ ccc = '<pad>'
19
+ for item in musicgen(ccc, piano_only=piano_only, length=length):
20
  midi = item
21
  yield item, None, None
22
  bio = BytesIO()
 
30
  with gr.Blocks() as demo:
31
  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.")
32
  piano_only = gr.Checkbox(label="Piano Only")
33
+ piano_seed = gr.Checkbox(label="Use Piano Melody Seed")
34
  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")
35
  synth = gr.Button("Synthesize")
36
  txtout = gr.Textbox(interactive=False, label="MIDI Tokens")
37
  fileout = gr.File(interactive=False, label="MIDI File", type="binary")
38
  audioout = gr.Audio(interactive=False, label="Audio")
39
+ synth.click(gen, inputs=[piano_only, piano_seed, length], outputs=[txtout, fileout, audioout])
40
  demo.queue(api_open=False).launch(show_api=False)