import gradio as gr from music21 import converter def process_musicxml(file): score = converter.parse(file.name) notes = [str(n.pitch) for n in score.flat.notes if n.isNote] unique_notes = sorted(set(notes)) study_plan = { "Scales": { "All Notes": unique_notes, "Suggested Practice": [f"{note} Major Scale" for note in unique_notes] }, "Practice Exercises": { "Sight Reading (4-note chunks)": [notes[i:i+4] for i in range(0, len(notes)-3, 4)], "Finger Exercises": [f"{note} Arpeggio" for note in unique_notes] } } return study_plan gr.Interface( fn=process_musicxml, inputs=gr.File(file_types=[".musicxml", ".xml"], label="Upload MusicXML File"), outputs=gr.JSON(label="Study Plan"), title="🎼 MusicXML Study Generator", description="Upload a MusicXML file to generate scales and practice routines." ).launch()