Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -125,22 +125,17 @@ def create_midi(prediction_output):
|
|
125 |
new_chord = chord.Chord(notes)
|
126 |
new_chord.offset = offset
|
127 |
output_notes.append(new_chord)
|
128 |
-
|
129 |
-
# pattern is a rest
|
130 |
elif pattern == 'r':
|
131 |
-
|
|
|
132 |
new_note.offset = offset
|
133 |
new_note.storedInstrument = instrument.Piano()
|
134 |
output_notes.append(new_note)
|
135 |
-
|
136 |
-
# pattern is a note
|
137 |
else:
|
138 |
new_note = note.Note(pattern)
|
139 |
new_note.offset = offset
|
140 |
new_note.storedInstrument = instrument.Piano()
|
141 |
output_notes.append(new_note)
|
142 |
-
|
143 |
-
# increase offset each iteration so that notes do not stack
|
144 |
offset += 0.5
|
145 |
|
146 |
midi_stream = stream.Stream(output_notes)
|
|
|
125 |
new_chord = chord.Chord(notes)
|
126 |
new_chord.offset = offset
|
127 |
output_notes.append(new_chord)
|
|
|
|
|
128 |
elif pattern == 'r':
|
129 |
+
# Create a rest note with a default duration (e.g., 1.0)
|
130 |
+
new_note = note.Rest(1.0) # Set a valid duration
|
131 |
new_note.offset = offset
|
132 |
new_note.storedInstrument = instrument.Piano()
|
133 |
output_notes.append(new_note)
|
|
|
|
|
134 |
else:
|
135 |
new_note = note.Note(pattern)
|
136 |
new_note.offset = offset
|
137 |
new_note.storedInstrument = instrument.Piano()
|
138 |
output_notes.append(new_note)
|
|
|
|
|
139 |
offset += 0.5
|
140 |
|
141 |
midi_stream = stream.Stream(output_notes)
|