Spaces:
Sleeping
Sleeping
File size: 2,002 Bytes
82e08dd ef96802 82e08dd 9aa1091 82e08dd 66e823b 82e08dd 66e823b 82e08dd 66e823b 82e08dd 9aa1091 82e08dd ef96802 66e823b 82e08dd ef96802 329de81 9aa1091 82e08dd c0e317b 329de81 82e08dd 329de81 82e08dd ef96802 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | import gradio as gr
from gradio_midibridge import MIDIBridge
from processor import Processor
model_location_repo = "adricl/midi_single_instrument_mistral_transformer"
model_tokenizer_file = "HuggingFace_Mistral_Transformer_Single_Instrument.json"
# Create the Gradio interface
with gr.Blocks(title="MIDI Jam Session") as demo:
gr.Markdown("""
# 🎹 MIDI Jam Session
This demo shows the MIDI Jam Session in action:
1. **Select your MIDI input device** - Connect your MIDI keyboard or controller
2. **Select your MIDI output device** - Choose where to send the processed MIDI
3. **Play some notes** - The component will record your input
4. **Wait 5 seconds** - After inactivity, the recording is sent for processing
5. **""" + model_location_repo + """** - The MIDI is processed using a transformer model to generate new content based on your input
6. **Listen to the result** - The generated MIDI content is played back
""")
midi_session = MIDIBridge(
label="MIDI Jam Session",
bpm=120,
interactive=True,
)
with gr.Accordion("Generation Settings", open=False):
max_new_tokens = gr.Slider(
minimum=0, maximum=10000, value=2000, step=1,
label="Max New Tokens",
)
temperature = gr.Slider(
minimum=0.0, maximum=1.0, value=0.9, step=0.01,
label="Temperature",
)
top_p = gr.Slider(
minimum=0.0, maximum=1.0, value=0.95, step=0.01,
label="Top P",
)
do_sample = gr.Checkbox(value=True, label="Do Sample")
processor = Processor(model_location_repo=model_location_repo, model_tokenizer_file=model_tokenizer_file)
# Connect the processing function
midi_session.change(
fn=processor.transpose_midi,
inputs=[midi_session, max_new_tokens, temperature, top_p, do_sample],
outputs=midi_session,
)
if __name__ == "__main__":
demo.launch() |