Yassmen commited on
Commit
5530a43
·
verified ·
1 Parent(s): d55ae9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -121,14 +121,18 @@ with st.container():
121
  # Display a GIF instead of Lottie animation
122
  st.image("im.gif", use_column_width=True)
123
 
 
124
  # Sidebar for user input
125
  with st.sidebar:
126
- len_notes = st.slider('Please Choose The Notes Length', 20, 750, 20, 4)
 
 
127
  st.write("Notes Length = ", len_notes)
128
 
129
  # Music generation functionality
130
  if st.sidebar.button('Generate My Music'):
131
- if len_notes:
 
132
  with st.container():
133
  st.write("---")
134
  with st.spinner('✨ Your music is now under processing... ✨'):
@@ -140,6 +144,18 @@ if st.sidebar.button('Generate My Music'):
140
 
141
  st.audio('output.wav')
142
  st.markdown("Here you are! You can download your music by right-clicking on the media player.")
 
 
 
 
 
 
 
 
143
 
 
 
144
 
 
 
145
 
 
121
  # Display a GIF instead of Lottie animation
122
  st.image("im.gif", use_column_width=True)
123
 
124
+ # Sidebar for user input
125
  # Sidebar for user input
126
  with st.sidebar:
127
+ # Set a default value for len_notes
128
+ default_len_notes = 100 # Example default value
129
+ len_notes = st.slider('Please Choose The Notes Length', 20, 750, default_len_notes, 4)
130
  st.write("Notes Length = ", len_notes)
131
 
132
  # Music generation functionality
133
  if st.sidebar.button('Generate My Music'):
134
+ # Use the default value if len_notes is not explicitly set by the user
135
+ if len_notes is not None:
136
  with st.container():
137
  st.write("---")
138
  with st.spinner('✨ Your music is now under processing... ✨'):
 
144
 
145
  st.audio('output.wav')
146
  st.markdown("Here you are! You can download your music by right-clicking on the media player.")
147
+ else:
148
+ # Fallback to the default value if no selection is made
149
+ with st.container():
150
+ st.write("---")
151
+ st.warning("No notes length selected. Using default value of 100.")
152
+ with st.spinner('✨ Your music is now under processing... ✨'):
153
+ time.sleep(10) # Simulate processing time
154
+ generate(10, default_len_notes)
155
 
156
+ fs = FluidSynth('font.sf2', sample_rate=44100)
157
+ fs.midi_to_audio('test_output2.mid', 'output.wav')
158
 
159
+ st.audio('output.wav')
160
+ st.markdown("Here you are! You can download your music by right-clicking on the media player.")
161