NeoPy commited on
Commit
867d88a
·
verified ·
1 Parent(s): 47540f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -410,7 +410,7 @@ html_template = """
410
  """
411
 
412
  # Define the Gradio Interface
413
- with gr.Blocks(css=css, title="MIDI Player & Visualizer") as demo:
414
  gr.Markdown("# 🎹 MIDI Player & Visualizer")
415
  gr.Markdown("Upload a MIDI file to play. Optionally upload a SoundFont (.sf2) for improved synthesis logic (simulated here).")
416
 
@@ -423,19 +423,7 @@ with gr.Blocks(css=css, title="MIDI Player & Visualizer") as demo:
423
  # The HTML component renders our visualizer and controls
424
  gr.HTML(html_template)
425
 
426
- # Logic to pass files from Python to JS
427
- # Gradio's change events trigger the JS functions defined in the HTML
428
- # Note: We use the `change` event to feed the file path to the frontend
429
- # However, for binary data (MIDI/SF2), we need a workaround or Gradio's native handling.
430
- # Gradio 3.35+ allows returning the file object directly to JS `change` event if configured,
431
- # but usually it's easier to process in Python or use a hidden state.
432
-
433
- # A robust way in Gradio to get file data into JS:
434
- # 1. User uploads file.
435
- # 2. Python reads it.
436
- # 3. Python returns the base64 string.
437
- # 4. JS receives base64 and converts to ArrayBuffer.
438
-
439
  def process_midi(file):
440
  if file is None: return None
441
  with open(file, "rb") as f:
@@ -496,4 +484,4 @@ with gr.Blocks(css=css, title="MIDI Player & Visualizer") as demo:
496
  demo.load(None, None, None, js=js_handler)
497
 
498
  if __name__ == "__main__":
499
- demo.launch()
 
410
  """
411
 
412
  # Define the Gradio Interface
413
+ with gr.Blocks(title="MIDI Player & Visualizer") as demo:
414
  gr.Markdown("# 🎹 MIDI Player & Visualizer")
415
  gr.Markdown("Upload a MIDI file to play. Optionally upload a SoundFont (.sf2) for improved synthesis logic (simulated here).")
416
 
 
423
  # The HTML component renders our visualizer and controls
424
  gr.HTML(html_template)
425
 
426
+ #
 
 
 
 
 
 
 
 
 
 
 
 
427
  def process_midi(file):
428
  if file is None: return None
429
  with open(file, "rb") as f:
 
484
  demo.load(None, None, None, js=js_handler)
485
 
486
  if __name__ == "__main__":
487
+ demo.launch(css=css)