Spaces:
Running
on
Zero
Running
on
Zero
ButterCream
commited on
Commit
·
25e344b
1
Parent(s):
9bb67a6
further fine grained s-curve control
Browse files
app.py
CHANGED
@@ -217,32 +217,35 @@ def generate(audio_path, ins, speed, alpha, beta, embedding, steps=200):
|
|
217 |
# Post-Processing
|
218 |
thresh = np.percentile(np.abs(synthaud), 95)
|
219 |
CUT_SAMPLES = 20000 # max samples to cut, in practice only 4-6k are actually cut
|
|
|
|
|
|
|
220 |
|
221 |
# Leading artefact removal
|
222 |
-
left = CUT_SAMPLES +
|
223 |
for j in range(left):
|
224 |
if abs(synthaud[j]) > thresh:
|
225 |
left = j
|
226 |
break
|
227 |
|
228 |
-
left = max(0, min(left -
|
229 |
synthaud[:left] = 0
|
230 |
-
for k in range(
|
231 |
-
s = s_curve(k /
|
232 |
synthaud[k + left] *= s
|
233 |
|
234 |
# Trailing artefact removal
|
235 |
-
right = len(synthaud) - CUT_SAMPLES -
|
236 |
for j in range(len(synthaud) - 1, right, -1):
|
237 |
if abs(synthaud[j]) > thresh:
|
238 |
right = j
|
239 |
break
|
240 |
|
241 |
-
right = min(len(synthaud), max(right +
|
242 |
synthaud[right:] = 0
|
243 |
-
for k in range(
|
244 |
-
s = s_curve(k /
|
245 |
-
synthaud[right -
|
246 |
|
247 |
|
248 |
audio = np.concatenate((audio, synthaud))
|
|
|
217 |
# Post-Processing
|
218 |
thresh = np.percentile(np.abs(synthaud), 95)
|
219 |
CUT_SAMPLES = 20000 # max samples to cut, in practice only 4-6k are actually cut
|
220 |
+
lead_percent = 0.008
|
221 |
+
trail_percent = 0.009
|
222 |
+
|
223 |
|
224 |
# Leading artefact removal
|
225 |
+
left = CUT_SAMPLES + int(len(synthaud) * lead_percent)
|
226 |
for j in range(left):
|
227 |
if abs(synthaud[j]) > thresh:
|
228 |
left = j
|
229 |
break
|
230 |
|
231 |
+
left = max(0, min(left - int(len(synthaud) * lead_percent), CUT_SAMPLES))
|
232 |
synthaud[:left] = 0
|
233 |
+
for k in range(int(len(synthaud) * lead_percent)):
|
234 |
+
s = s_curve(k / int(len(synthaud) * lead_percent))
|
235 |
synthaud[k + left] *= s
|
236 |
|
237 |
# Trailing artefact removal
|
238 |
+
right = len(synthaud) - CUT_SAMPLES - int(len(synthaud) * trail_percent)
|
239 |
for j in range(len(synthaud) - 1, right, -1):
|
240 |
if abs(synthaud[j]) > thresh:
|
241 |
right = j
|
242 |
break
|
243 |
|
244 |
+
right = min(len(synthaud), max(right + int(len(synthaud) * trail_percent), len(synthaud) - CUT_SAMPLES))
|
245 |
synthaud[right:] = 0
|
246 |
+
for k in range(int(len(synthaud) * trail_percent)):
|
247 |
+
s = s_curve(k / int(len(synthaud) * trail_percent))
|
248 |
+
synthaud[right - int(len(synthaud) * trail_percent) + k] *= s
|
249 |
|
250 |
|
251 |
audio = np.concatenate((audio, synthaud))
|