Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -147,38 +147,39 @@ def Generate_POP_Section(input_comp_section,
|
|
147 |
#===============================================================================
|
148 |
|
149 |
print('Generating...')
|
150 |
-
|
151 |
-
# seq = [916] + [part_tok+512, mode_time(score)+532, mode_dur(score)+660, mode_pitch(score)+788]
|
152 |
-
|
153 |
-
part = 'chorus'
|
154 |
-
mode_time = 10
|
155 |
-
mode_dur = 10
|
156 |
-
mode_pitch = 66
|
157 |
-
|
158 |
-
#seq = [916] + [parts_dict.index(part)+512, mode_time+532, mode_dur+660, mode_pitch+788]
|
159 |
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
|
|
|
|
|
|
|
|
162 |
x = torch.LongTensor(seq).cuda()
|
163 |
|
164 |
with ctx:
|
165 |
out = model.generate(x,
|
166 |
-
512,
|
167 |
temperature=0.9,
|
168 |
-
|
169 |
-
|
170 |
eos_token=917,
|
171 |
return_prime=True,
|
172 |
verbose=True)
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
song.extend(y)
|
177 |
|
178 |
print('Done!')
|
179 |
print('=' * 70)
|
180 |
|
181 |
#===============================================================================
|
|
|
182 |
print('Rendering results...')
|
183 |
|
184 |
print('=' * 70)
|
|
|
147 |
#===============================================================================
|
148 |
|
149 |
print('Generating...')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
+
if input_comp_section == 'random':
|
152 |
+
seq = [916]
|
153 |
+
|
154 |
+
else:
|
155 |
+
seq = [916, sections_dict.index(input_comp_section)+512]
|
156 |
+
|
157 |
+
input_seq = [input_mode_time, input_mode_dur, input_mode_ptc]
|
158 |
+
input_seq_toks = [input_mode_time+532, input_mode_dur+660, input_mode_ptc+788]
|
159 |
|
160 |
+
input_seq = input_seq_toks[:input_seq.index(0)]
|
161 |
+
|
162 |
+
seq += input_seq
|
163 |
+
|
164 |
x = torch.LongTensor(seq).cuda()
|
165 |
|
166 |
with ctx:
|
167 |
out = model.generate(x,
|
168 |
+
512-len(seq),
|
169 |
temperature=0.9,
|
170 |
+
filter_logits_fn=top_p,
|
171 |
+
filter_kwargs={'thres': 0.96},
|
172 |
eos_token=917,
|
173 |
return_prime=True,
|
174 |
verbose=True)
|
175 |
|
176 |
+
song = out.tolist()[0]
|
|
|
|
|
177 |
|
178 |
print('Done!')
|
179 |
print('=' * 70)
|
180 |
|
181 |
#===============================================================================
|
182 |
+
|
183 |
print('Rendering results...')
|
184 |
|
185 |
print('=' * 70)
|