Spaces:
Running
Running
File size: 2,859 Bytes
c9dbbbe e08994d b4654f2 c9dbbbe 61aa7f2 e08994d 61aa7f2 c9dbbbe 61aa7f2 c9dbbbe 61aa7f2 c9dbbbe 61aa7f2 c9dbbbe 824146a c9dbbbe e08994d |
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 58 59 60 61 62 63 64 |
from matplotlib.pyplot import title
from yaml import Mark
from music import music_gen #Funtion to generate music based on ABC files
import gradio as gr
import os
from MC.markov_chain import main_markov #Function to generate music based on midi files
keysignature = ["C","G","D","A","No selection"]
difficulty = ["beginner","intermediate","expert"]
timesignature = ['3/4','4/4','2/2','2/4']
# output = gr.Gallery() if GlobalUIGallery else "image"
# interface = gr.Interface(fn = music_gen,
# inputs=[gr.Radio(difficulty,label="Difficulty"),
# gr.Radio(timesignature,label="Time Signature"),
# gr.Dropdown(keysignature,label="Key Signature")],
# outputs = [gr.Gallery(label="Sheet Music"),gr.Audio(label="Audio")],
# title="Sheet Music Generation for Sight-Reading",
# description="TO be added")
# interface.launch(inline=False)
with gr.Blocks() as demo:
gr.Markdown("""
## Sight-reading generator for sheet music.
Markov models which generate sheet music based on different input
parameters given by the user.
""")
with gr.Tabs():
with gr.TabItem("ABC Model"):
gr.Markdown("N-grams model using ABC data as training data.")
with gr.Row():
with gr.Column():
difficulty_input_abc = gr.Radio(difficulty,label="Difficulty") #input
time_sig_input_abc = gr.Radio(timesignature,label="Time Signature") #input
key_sig_input_abc = gr.Dropdown(keysignature,label="Key Signature") #input
with gr.Row():
abc_button = gr.Button("Create Music!!") #Submit
with gr.Column():
output_gallery_abc = gr.Gallery(label="Sheet Music")
output_audio_abc = gr.Audio(label="Audio")
with gr.TabItem("MIDI Model"):
gr.Markdown("Markov model using MIDI fata as training data.")
with gr.Row():
with gr.Column():
# difficulty_input_midi = gr.Radio(difficulty,label="Difficulty") #input
time_sig_input_midi = gr.Radio(timesignature,label="Time Signature") #input
# key_sig_input_midi = gr.Dropdown(keysignature,label="Key Signature") #input
with gr.Row():
midi_button = gr.Button("Create Music!!") #Submit
with gr.Column():
output_gallery_midi = gr.Gallery(label="Sheet Music")
output_audio_midi = gr.Audio(label="Audio")
abc_button.click(music_gen, inputs=[difficulty_input_abc,time_sig_input_abc,key_sig_input_abc], outputs=[output_gallery_abc,output_audio_abc])
midi_button.click(main_markov, inputs= time_sig_input_midi, outputs=[output_gallery_midi,output_audio_midi])
if __name__ == "__main__":
demo.launch()
|