lauraibnz commited on
Commit
badd630
1 Parent(s): 6c1596b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -48,10 +48,10 @@ def synthesize(midi_file=None):
48
  midi_synth = midi_synth.reshape(midi_synth.shape[0], 1)
49
  return (SAMPLE_RATE, midi_synth)
50
 
51
- def upload(midi_file=None):
52
- if isinstance(midi_file, _TemporaryFileWrapper):
53
- midi_file = midi_file.name
54
- return midi_file
55
 
56
  with gr.Blocks(title="🎹 MIDI-AudioLDM", theme=gr.themes.Base(text_size=gr.themes.sizes.text_md, font=[gr.themes.GoogleFont("Nunito Sans")])) as demo:
57
  gr.HTML(
@@ -62,13 +62,14 @@ with gr.Blocks(title="🎹 MIDI-AudioLDM", theme=gr.themes.Base(text_size=gr.the
62
  """
63
  MIDI-AudioLDM is a MIDI-conditioned text-to-audio model based on the project [AudioLDM](https://huggingface.co/spaces/haoheliu/audioldm-text-to-audio-generation). The model has been conditioned using the ControlNet architecture and has been developed within Hugging Face’s [🧨 Diffusers](https://huggingface.co/docs/diffusers/) framework. Once trained, MIDI-AudioLDM accepts a MIDI file and a text prompt as input and returns an audio file, which is an interpretation of the MIDI based on the given text description. This enables detailed control over different musical aspects such as notes, mood and timbre.
64
  """)
65
- upload_button = gr.UploadButton("Upload MIDI file", file_types=[".mid"], value="S00.mid")
66
  with gr.Row():
67
  with gr.Column(variant='panel'):
68
- midi = gr.File(visible=False, value="S00.mid")
 
69
  midi_synth = gr.Audio(label="synthesized midi")
70
- upload_button.upload(upload, upload_button, midi)
71
- upload_button.upload(synthesize, upload_button, midi_synth)
72
  prompt = gr.Textbox(label="prompt", info="Enter a descriptive text prompt to guide the audio generation.")
73
  with gr.Column(variant='panel'):
74
  audio = gr.Audio(label="generated audio")
 
48
  midi_synth = midi_synth.reshape(midi_synth.shape[0], 1)
49
  return (SAMPLE_RATE, midi_synth)
50
 
51
+ # def upload(midi_file=None):
52
+ # if isinstance(midi_file, _TemporaryFileWrapper):
53
+ # midi_file = midi_file.name
54
+ # return midi_file
55
 
56
  with gr.Blocks(title="🎹 MIDI-AudioLDM", theme=gr.themes.Base(text_size=gr.themes.sizes.text_md, font=[gr.themes.GoogleFont("Nunito Sans")])) as demo:
57
  gr.HTML(
 
62
  """
63
  MIDI-AudioLDM is a MIDI-conditioned text-to-audio model based on the project [AudioLDM](https://huggingface.co/spaces/haoheliu/audioldm-text-to-audio-generation). The model has been conditioned using the ControlNet architecture and has been developed within Hugging Face’s [🧨 Diffusers](https://huggingface.co/docs/diffusers/) framework. Once trained, MIDI-AudioLDM accepts a MIDI file and a text prompt as input and returns an audio file, which is an interpretation of the MIDI based on the given text description. This enables detailed control over different musical aspects such as notes, mood and timbre.
64
  """)
65
+ # upload_button = gr.UploadButton("Upload MIDI file", file_types=[".mid"], value="S00.mid")
66
  with gr.Row():
67
  with gr.Column(variant='panel'):
68
+ # midi = gr.File(visible=False, value="S00.mid")
69
+ midi = gr.File(label="midi file", file_types=[".mid"], value="S00.mid")
70
  midi_synth = gr.Audio(label="synthesized midi")
71
+ # upload_button.upload(upload, upload_button, midi)
72
+ midi.upload(synthesize, midi, midi_synth)
73
  prompt = gr.Textbox(label="prompt", info="Enter a descriptive text prompt to guide the audio generation.")
74
  with gr.Column(variant='panel'):
75
  audio = gr.Audio(label="generated audio")