asigalov61 commited on
Commit
941fa24
·
verified ·
1 Parent(s): e9b7435

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -27
app.py CHANGED
@@ -205,38 +205,36 @@ def Generate_Accompaniment(input_midi,
205
 
206
  def generate_block_seq(input_seq, trg_dtime, temperature=0.9):
207
 
 
 
 
 
208
  cur_time = 0
209
 
210
- block_seq = [128]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
- while cur_time != trg_dtime or len(block_seq) < 2 or block_seq[-1] > 127:
 
213
 
214
- inp_seq = copy.deepcopy(input_seq)
215
-
216
- block_seq = []
217
-
218
- cur_time = 0
219
-
220
- while cur_time < trg_dtime:
221
-
222
- x = torch.LongTensor(inp_seq).cuda()
223
-
224
- with ctx:
225
- out = model.generate(x,
226
- 1,
227
- temperature=temperature,
228
- return_prime=False,
229
- verbose=False)
230
-
231
- y = out.tolist()[0][0]
232
-
233
- if y < 128:
234
- cur_time += y
235
-
236
- inp_seq.append(y)
237
- block_seq.append(y)
238
 
239
- return block_seq
 
240
 
241
  #===============================================================================
242
 
 
205
 
206
  def generate_block_seq(input_seq, trg_dtime, temperature=0.9):
207
 
208
+ inp_seq = copy.deepcopy(input_seq)
209
+
210
+ block_seq = []
211
+
212
  cur_time = 0
213
 
214
+ while cur_time < trg_dtime:
215
+
216
+ x = torch.LongTensor(inp_seq).cuda()
217
+
218
+ with ctx:
219
+ out = model.generate(x,
220
+ 1,
221
+ temperature=temperature,
222
+ return_prime=False,
223
+ verbose=False)
224
+
225
+ y = out.tolist()[0][0]
226
+
227
+ if y < 128:
228
+ cur_time += y
229
 
230
+ inp_seq.append(y)
231
+ block_seq.append(y)
232
 
233
+ if cur_time != trg_dtime:
234
+ return []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
+ else:
237
+ return block_seq
238
 
239
  #===============================================================================
240