Spaces:
Running
Running
generate_music_segments: Logical error fix
Browse files
audiocraft/utils/extend.py
CHANGED
@@ -73,12 +73,14 @@ def generate_music_segments(text, melody, seed, MODEL, duration:int=10, overlap:
|
|
73 |
while excess_duration + duration_loss > segment_duration:
|
74 |
total_segments += 1
|
75 |
#calculate duration loss from segment overlap
|
76 |
-
duration_loss
|
77 |
#calc excess duration
|
78 |
excess_duration = segment_duration - (total_segments * segment_duration - duration)
|
79 |
print(f"total Segments to Generate: {total_segments} for {duration} seconds. Each segment is {segment_duration} seconds. Excess {excess_duration} Overlap Loss {duration_loss}")
|
80 |
if excess_duration + duration_loss > segment_duration:
|
81 |
duration += duration_loss
|
|
|
|
|
82 |
|
83 |
# If melody_segments is shorter than total_segments, repeat the segments until the total_segments is reached
|
84 |
if len(melody_segments) < total_segments:
|
|
|
73 |
while excess_duration + duration_loss > segment_duration:
|
74 |
total_segments += 1
|
75 |
#calculate duration loss from segment overlap
|
76 |
+
duration_loss += math.ceil(overlap / 2)
|
77 |
#calc excess duration
|
78 |
excess_duration = segment_duration - (total_segments * segment_duration - duration)
|
79 |
print(f"total Segments to Generate: {total_segments} for {duration} seconds. Each segment is {segment_duration} seconds. Excess {excess_duration} Overlap Loss {duration_loss}")
|
80 |
if excess_duration + duration_loss > segment_duration:
|
81 |
duration += duration_loss
|
82 |
+
duration_loss = 0
|
83 |
+
total_segments = min(total_segments, (720 // segment_duration))
|
84 |
|
85 |
# If melody_segments is shorter than total_segments, repeat the segments until the total_segments is reached
|
86 |
if len(melody_segments) < total_segments:
|