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: with gr.Tabs(): with gr.TabItem("MusicGen™ Advanced (v2)"): gr.Markdown("ABC Model") with gr.Row(): with gr.Column(): user_name_input = gr.Textbox(placeholder="Only Melody supported for now!!!", label="Describe the music you want to create...") difficulty_input_abc = gr.Radio(difficulty,label="Music Complexity") #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 AI Music with SpriFi MusicGen™!!") #Submit with gr.Column(): output_audio_abc = gr.Audio(label="Generated music") output_gallery_abc = gr.Gallery(label="Music Note Sheet") with gr.TabItem("MusicGen™ (v1)"): gr.Markdown("MIDI Model") 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_audio_midi = gr.Audio(label="Generated music") output_gallery_midi = gr.Gallery(label="Music Note Sheet") 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()