Yassmen commited on
Commit
dd4994c
·
verified ·
1 Parent(s): 214bf41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -180,12 +180,14 @@ if st.sidebar.button('Generate My Music'):
180
  with st.spinner('✨ Your music is now under processing... ✨'):
181
  time.sleep(10) # Simulate processing time
182
  generate(10, len_notes)
183
-
184
- fs = FluidSynth('font.sf2', sample_rate=44100)
185
- fs.midi_to_audio('test_output2.mid', 'output.wav')
186
-
187
- st.audio('output.wav')
188
- st.markdown("Here you are! You can download your music by right-clicking on the media player.")
 
 
189
  else:
190
  # Fallback to the default value if no selection is made
191
  with st.container():
@@ -194,10 +196,11 @@ if st.sidebar.button('Generate My Music'):
194
  with st.spinner('✨ Your music is now under processing... ✨'):
195
  time.sleep(10) # Simulate processing time
196
  generate(10, default_len_notes)
197
-
198
- fs = FluidSynth('font.sf2', sample_rate=44100)
199
- fs.midi_to_audio('test_output2.mid', 'output.wav')
200
-
201
- st.audio('output.wav')
202
- st.markdown("Here you are! You can download your music by right-clicking on the media player.")
203
-
 
 
180
  with st.spinner('✨ Your music is now under processing... ✨'):
181
  time.sleep(10) # Simulate processing time
182
  generate(10, len_notes)
183
+ if shutil.which("fluidsynth") is None:
184
+ st.error("FluidSynth is not available. Unable to convert MIDI to audio.")
185
+ else:
186
+ fs = FluidSynth('font.sf2', sample_rate=44100)
187
+ fs.midi_to_audio('test_output2.mid', 'output.wav')
188
+ st.audio('output.wav')
189
+ st.markdown("Here you are! You can download your music by right-clicking on the media player.")
190
+
191
  else:
192
  # Fallback to the default value if no selection is made
193
  with st.container():
 
196
  with st.spinner('✨ Your music is now under processing... ✨'):
197
  time.sleep(10) # Simulate processing time
198
  generate(10, default_len_notes)
199
+ if shutil.which("fluidsynth") is None:
200
+ st.error("FluidSynth is not available. Unable to convert MIDI to audio.")
201
+ else:
202
+ fs = FluidSynth('font.sf2', sample_rate=44100)
203
+ fs.midi_to_audio('test_output2.mid', 'output.wav')
204
+ st.audio('output.wav')
205
+ st.markdown("Here you are! You can download your music by right-clicking on the media player.")
206
+