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()