Spaces:
Running
on
T4
Running
on
T4
Allow 0 overlap option
Browse files
app.py
CHANGED
@@ -225,23 +225,26 @@ def predict(model, text, melody_filepath, duration, dimension, topk, topp, tempe
|
|
225 |
|
226 |
output = output_segments[0]
|
227 |
for i in range(1, len(output_segments)):
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
|
|
|
|
|
|
245 |
output = output.detach().cpu().float()[0]
|
246 |
except Exception as e:
|
247 |
print(f"Error combining segments: {e}. Using the first segment only.")
|
@@ -323,12 +326,12 @@ def ui(**kwargs):
|
|
323 |
settings_font_color = gr.ColorPicker(label="Settings Font Color", value="#c87f05", interactive=True)
|
324 |
with gr.Accordion("Expert", open=False):
|
325 |
with gr.Row():
|
326 |
-
overlap = gr.Slider(minimum=
|
327 |
dimension = gr.Slider(minimum=-2, maximum=2, value=2, step=1, label="Dimension", info="determines which direction to add new segements of audio. (1 = stack tracks, 2 = lengthen, -2..0 = ?)", interactive=True)
|
328 |
with gr.Row():
|
329 |
topk = gr.Number(label="Top-k", value=280, precision=0, interactive=True)
|
330 |
-
topp = gr.Number(label="Top-p", value=
|
331 |
-
temperature = gr.Number(label="Randomness Temperature", value=0.
|
332 |
cfg_coef = gr.Number(label="Classifier Free Guidance", value=8.5, precision=None, interactive=True)
|
333 |
with gr.Row():
|
334 |
seed = gr.Number(label="Seed", value=-1, precision=0, interactive=True)
|
|
|
225 |
|
226 |
output = output_segments[0]
|
227 |
for i in range(1, len(output_segments)):
|
228 |
+
if overlap > 0:
|
229 |
+
overlap_samples = overlap * MODEL.sample_rate
|
230 |
+
#stack tracks and fade out/in
|
231 |
+
overlapping_output_fadeout = output[:, :, -overlap_samples:]
|
232 |
+
#overlapping_output_fadeout = apply_fade(overlapping_output_fadeout,sample_rate=MODEL.sample_rate,duration=overlap,out=True,start=True, curve_end=0.0, current_device=MODEL.device)
|
233 |
+
overlapping_output_fadeout = apply_tafade(overlapping_output_fadeout,sample_rate=MODEL.sample_rate,duration=overlap,out=True,start=True,shape="linear")
|
234 |
+
|
235 |
+
overlapping_output_fadein = output_segments[i][:, :, :overlap_samples]
|
236 |
+
#overlapping_output_fadein = apply_fade(overlapping_output_fadein,sample_rate=MODEL.sample_rate,duration=overlap,out=False,start=False, curve_start=0.0, current_device=MODEL.device)
|
237 |
+
overlapping_output_fadein = apply_tafade(overlapping_output_fadein,sample_rate=MODEL.sample_rate,duration=overlap,out=False,start=False, shape="linear")
|
238 |
+
|
239 |
+
overlapping_output = torch.cat([overlapping_output_fadeout[:, :, :-(overlap_samples // 2)], overlapping_output_fadein],dim=2)
|
240 |
+
print(f" overlap size Fade:{overlapping_output.size()}\n output: {output.size()}\n segment: {output_segments[i].size()}")
|
241 |
+
##overlapping_output = torch.cat([output[:, :, -overlap_samples:], output_segments[i][:, :, :overlap_samples]], dim=1) #stack tracks
|
242 |
+
##print(f" overlap size stack:{overlapping_output.size()}\n output: {output.size()}\n segment: {output_segments[i].size()}")
|
243 |
+
#overlapping_output = torch.cat([output[:, :, -overlap_samples:], output_segments[i][:, :, :overlap_samples]], dim=2) #stack tracks
|
244 |
+
#print(f" overlap size cat:{overlapping_output.size()}\n output: {output.size()}\n segment: {output_segments[i].size()}")
|
245 |
+
output = torch.cat([output[:, :, :-overlap_samples], overlapping_output, output_segments[i][:, :, overlap_samples:]], dim=dimension)
|
246 |
+
else:
|
247 |
+
output = torch.cat([output, output_segments[i]], dim=dimension)
|
248 |
output = output.detach().cpu().float()[0]
|
249 |
except Exception as e:
|
250 |
print(f"Error combining segments: {e}. Using the first segment only.")
|
|
|
326 |
settings_font_color = gr.ColorPicker(label="Settings Font Color", value="#c87f05", interactive=True)
|
327 |
with gr.Accordion("Expert", open=False):
|
328 |
with gr.Row():
|
329 |
+
overlap = gr.Slider(minimum=0, maximum=15, value=2, step=1, label="Verse Overlap", interactive=True)
|
330 |
dimension = gr.Slider(minimum=-2, maximum=2, value=2, step=1, label="Dimension", info="determines which direction to add new segements of audio. (1 = stack tracks, 2 = lengthen, -2..0 = ?)", interactive=True)
|
331 |
with gr.Row():
|
332 |
topk = gr.Number(label="Top-k", value=280, precision=0, interactive=True)
|
333 |
+
topp = gr.Number(label="Top-p", value=1150, precision=0, interactive=True)
|
334 |
+
temperature = gr.Number(label="Randomness Temperature", value=0.7, precision=None, interactive=True)
|
335 |
cfg_coef = gr.Number(label="Classifier Free Guidance", value=8.5, precision=None, interactive=True)
|
336 |
with gr.Row():
|
337 |
seed = gr.Number(label="Seed", value=-1, precision=0, interactive=True)
|