Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,9 +109,9 @@ print('=' * 70)
|
|
| 109 |
def load_midi(input_midi):
|
| 110 |
|
| 111 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi)
|
| 112 |
-
|
| 113 |
escore_notes = TMIDIX.advanced_score_processor(raw_score, return_enhanced_score_notes=True, apply_sustain=True)
|
| 114 |
-
|
| 115 |
if escore_notes:
|
| 116 |
|
| 117 |
escore_notes = TMIDIX.augment_enhanced_score_notes(escore_notes[0], sort_drums_last=True)
|
|
@@ -121,6 +121,8 @@ def load_midi(input_midi):
|
|
| 121 |
dcscore = TMIDIX.chordify_score([d[1:] for d in dscore])
|
| 122 |
|
| 123 |
melody_chords = [18816]
|
|
|
|
|
|
|
| 124 |
|
| 125 |
#=======================================================
|
| 126 |
# MAIN PROCESSING CYCLE
|
|
@@ -131,6 +133,10 @@ def load_midi(input_midi):
|
|
| 131 |
delta_time = c[0][0]
|
| 132 |
|
| 133 |
melody_chords.append(delta_time)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
for e in c:
|
| 136 |
|
|
@@ -160,14 +166,17 @@ def load_midi(input_midi):
|
|
| 160 |
dur_vel = (8 * dur) + velocity
|
| 161 |
|
| 162 |
melody_chords.extend([pat_ptc+256, dur_vel+16768]) # 18816
|
|
|
|
| 163 |
|
|
|
|
| 164 |
|
| 165 |
print('Done!')
|
| 166 |
print('=' * 70)
|
| 167 |
-
print('Score
|
|
|
|
| 168 |
print('=' * 70)
|
| 169 |
|
| 170 |
-
return melody_chords
|
| 171 |
|
| 172 |
else:
|
| 173 |
return None
|
|
@@ -176,9 +185,9 @@ def load_midi(input_midi):
|
|
| 176 |
|
| 177 |
@spaces.GPU
|
| 178 |
def Generate_Drums(input_midi,
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
|
| 183 |
#===============================================================================
|
| 184 |
|
|
|
|
| 109 |
def load_midi(input_midi):
|
| 110 |
|
| 111 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi)
|
| 112 |
+
|
| 113 |
escore_notes = TMIDIX.advanced_score_processor(raw_score, return_enhanced_score_notes=True, apply_sustain=True)
|
| 114 |
+
|
| 115 |
if escore_notes:
|
| 116 |
|
| 117 |
escore_notes = TMIDIX.augment_enhanced_score_notes(escore_notes[0], sort_drums_last=True)
|
|
|
|
| 121 |
dcscore = TMIDIX.chordify_score([d[1:] for d in dscore])
|
| 122 |
|
| 123 |
melody_chords = [18816]
|
| 124 |
+
|
| 125 |
+
chords = []
|
| 126 |
|
| 127 |
#=======================================================
|
| 128 |
# MAIN PROCESSING CYCLE
|
|
|
|
| 133 |
delta_time = c[0][0]
|
| 134 |
|
| 135 |
melody_chords.append(delta_time)
|
| 136 |
+
|
| 137 |
+
cho = []
|
| 138 |
+
|
| 139 |
+
cho.append(delta_time)
|
| 140 |
|
| 141 |
for e in c:
|
| 142 |
|
|
|
|
| 166 |
dur_vel = (8 * dur) + velocity
|
| 167 |
|
| 168 |
melody_chords.extend([pat_ptc+256, dur_vel+16768]) # 18816
|
| 169 |
+
cho.extend([pat_ptc+256, dur_vel+16768])
|
| 170 |
|
| 171 |
+
chords.append(cho)
|
| 172 |
|
| 173 |
print('Done!')
|
| 174 |
print('=' * 70)
|
| 175 |
+
print('Score has', len(melody_chords), 'tokens')
|
| 176 |
+
print('Score has', len(chords), 'chords')
|
| 177 |
print('=' * 70)
|
| 178 |
|
| 179 |
+
return melody_chords, chords
|
| 180 |
|
| 181 |
else:
|
| 182 |
return None
|
|
|
|
| 185 |
|
| 186 |
@spaces.GPU
|
| 187 |
def Generate_Drums(input_midi,
|
| 188 |
+
model_temperature,
|
| 189 |
+
model_sampling_top_p
|
| 190 |
+
):
|
| 191 |
|
| 192 |
#===============================================================================
|
| 193 |
|