Spaces:
Running
on
Zero
Running
on
Zero
ameerazam08
commited on
Commit
•
26b5772
1
Parent(s):
fe606bc
length cut change
Browse files
app.py
CHANGED
@@ -69,7 +69,11 @@ def generate_audio(prompt, sampler_type_dropdown, seconds_total=30, steps=100, c
|
|
69 |
|
70 |
# Peak normalize, clip, convert to int16
|
71 |
output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
|
72 |
-
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Generate a unique filename for the output
|
75 |
unique_filename = f"output_{uuid.uuid4().hex}.wav"
|
|
|
69 |
|
70 |
# Peak normalize, clip, convert to int16
|
71 |
output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
|
72 |
+
|
73 |
+
max_length = sample_rate * seconds_total
|
74 |
+
if output.shape[1] > max_length:
|
75 |
+
output = output[:, :max_length]
|
76 |
+
print(f"Audio trimmed to {seconds_total} seconds.")
|
77 |
|
78 |
# Generate a unique filename for the output
|
79 |
unique_filename = f"output_{uuid.uuid4().hex}.wav"
|