asigalov61 commited on
Commit
26615ae
1 Parent(s): a44bbef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -39
app.py CHANGED
@@ -126,11 +126,8 @@ def GenerateMusic(input_title):
126
  print('Sample INTs', out1[:12])
127
  print('=' * 70)
128
 
129
- generated_song_title = ''.join(tokens2txt(out1)).title()
130
-
131
- print('Generated song title:', generated_song_title)
132
- print('=' * 70)
133
-
134
  if len(out1) != 0:
135
 
136
  song = out1
@@ -140,44 +137,46 @@ def GenerateMusic(input_title):
140
  dur = 0
141
  vel = 90
142
  pitch = 0
 
143
  channel = 0
144
- chan = 0
145
-
146
  for ss in song:
147
-
148
- if 0 <= ss < 128:
149
-
150
- time += ss * 32
151
-
152
- if 128 <= ss < 256:
153
-
154
  dur = (ss-128) * 32
155
-
156
- if 256 <= ss < 2432:
157
-
158
- chan = (ss-256) // 128
159
-
160
- if chan < 9:
161
- channel = chan
162
- elif 9 < chan < 15:
163
- channel = chan+1
164
- elif chan == 15:
165
- channel = 15
166
- elif chan == 16:
167
- channel = 9
168
-
169
- pitch = (ss-256) % 128
170
-
171
- if 2432 <= ss < 2440:
172
-
173
- vel = (((ss-2432)+1) * 15)-1
174
-
175
- song_f.append(['note', time, dur, channel, pitch, vel, chan*8 ])
176
 
177
- fn1 = "Text-to-Music-Transformer-Composition"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
  detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
180
- output_signature = 'Text-to-Music Transformer',
181
  output_file_name = fn1,
182
  track_name='Project Los Angeles',
183
  list_of_MIDI_patches=patches
@@ -198,8 +197,8 @@ def GenerateMusic(input_title):
198
 
199
  #========================================================
200
 
201
- output_midi_title = generated_song_title
202
- output_midi_summary = str(song_f[:3])
203
  output_midi = str(new_fn)
204
  output_audio = (16000, audio)
205
 
 
126
  print('Sample INTs', out1[:12])
127
  print('=' * 70)
128
 
129
+ generated_song_description = '\n'.join(''.join(tokens2txt(out1)).split('.'))
130
+
 
 
 
131
  if len(out1) != 0:
132
 
133
  song = out1
 
137
  dur = 0
138
  vel = 90
139
  pitch = 0
140
+ pat = 0
141
  channel = 0
142
+
 
143
  for ss in song:
144
+
145
+ if 0 < ss < 128:
146
+
147
+ time += (ss * 32)
148
+
149
+ if 128 < ss < 256:
150
+
151
  dur = (ss-128) * 32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
+ if 256 <= ss <= 384:
154
+
155
+ pat = (ss-256)
156
+
157
+ channel = pat // 8
158
+
159
+ if channel == 9:
160
+ channel = 15
161
+ if channel == 16:
162
+ channel = 9
163
+
164
+ if 384 < ss < 640:
165
+
166
+ pitch = (ss-384) % 128
167
+
168
+ if 640 <= ss < 648:
169
+
170
+ vel = ((ss-640)+1) * 15
171
+
172
+ song_f.append(['note', time, dur, channel, pitch, vel, pat])
173
+
174
+ song_f, patches, overflow_patches = TMIDIX.patch_enhanced_score_notes(song_f)
175
+
176
+ fn1 = "Descriptive-Music-Transformer-Composition"
177
 
178
  detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(song_f,
179
+ output_signature = 'Descriptive Music Transformer',
180
  output_file_name = fn1,
181
  track_name='Project Los Angeles',
182
  list_of_MIDI_patches=patches
 
197
 
198
  #========================================================
199
 
200
+ output_midi_title = str(fn1).replace('-', ' ')
201
+ output_midi_summary = str(generated_song_description)
202
  output_midi = str(new_fn)
203
  output_audio = (16000, audio)
204