from pyharp import * import gradio as gr model_card = ModelCard( name='MIDI Pitch Shifter', description='Use the slider to shift the pitch of the input MIDI file.', author='xribene', tags=['midi', 'pitch', 'shift'], midi_in=True, midi_out=True ) # def process_fn(input_midi_path, pitch_shift_amount): """ This function defines the MIDI processing steps Args: input_midi_path (str): the MIDI filepath to be processed. : additional keyword arguments necessary for processing. NOTE: These should correspond to and match order of UI elements defined below. Returns: output_midi_path (str): the filepath of the processed MIDI. """ """ # Load MIDI at specified path using symusic """ midi = load_midi(input_midi_path) """ # Perform a trivial operation (i.e. pitch-shifting) """ for t in midi.tracks: for n in t.notes: n.pitch += int(pitch_shift_amount) """ # Save processed MIDI and obtain default path """ output_midi_path = save_midi(midi, None) return output_midi_path # Build Gradio endpoint with gr.Blocks() as demo: # Define Gradio Components components = [ gr.Slider( minimum=-24, maximum=24, step=1, value=0, label="Pitch Shift (semitones)" ), ] # Build endpoint app = build_endpoint(model_card=model_card, components=components, process_fn=process_fn) demo.queue() demo.launch(share=True)