thecollabagepatch commited on
Commit
90d8e0f
1 Parent(s): 717ff8a

add gr.Variable

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -117,7 +117,8 @@ def generate_midi(seed, use_chords, chord_progression, bpm):
117
  # Clean up temporary MIDI file
118
  os.remove(midi_filename)
119
 
120
- return wav_filename
 
121
 
122
  @spaces.GPU(duration=120)
123
  def generate_music(midi_audio_path, prompt_duration, musicgen_model, num_iterations, bpm):
@@ -239,7 +240,9 @@ with gr.Blocks() as iface:
239
  generate_music_button = gr.Button("Generate Music")
240
  output_audio = gr.Audio(label="Generated Music")
241
 
242
- generate_midi_button.click(generate_midi, inputs=[seed, use_chords, chord_progression, bpm], outputs=midi_audio)
243
- generate_music_button.click(generate_music, inputs=[midi_audio, prompt_duration, musicgen_model, num_iterations, bpm], outputs=output_audio)
 
 
244
 
245
  iface.launch()
 
117
  # Clean up temporary MIDI file
118
  os.remove(midi_filename)
119
 
120
+ sample_rate = 44100 # Assuming fixed sample rate from fluidsynth command
121
+ return (wav_filename, sample_rate)
122
 
123
  @spaces.GPU(duration=120)
124
  def generate_music(midi_audio_path, prompt_duration, musicgen_model, num_iterations, bpm):
 
240
  generate_music_button = gr.Button("Generate Music")
241
  output_audio = gr.Audio(label="Generated Music")
242
 
243
+ midi_result = gr.Variable()
244
+
245
+ generate_midi_button.click(generate_midi, inputs=[seed, use_chords, chord_progression, bpm], outputs=midi_result)
246
+ generate_music_button.click(generate_music, inputs=[midi_result, prompt_duration, musicgen_model, num_iterations, bpm], outputs=output_audio)
247
 
248
  iface.launch()