Spaces:
Runtime error
Runtime error
Emanuele Lapponi
commited on
Commit
Β·
499849b
1
Parent(s):
a0a7a38
:sparkles: make it less shit
Browse files
app.py
CHANGED
@@ -8,19 +8,24 @@ from audio_recorder_streamlit import audio_recorder
|
|
8 |
import pedalboard as pb
|
9 |
|
10 |
|
11 |
-
def stretch(audio, factor
|
|
|
12 |
for s in audio:
|
13 |
for _ in range(factor):
|
14 |
buffer.append(s)
|
15 |
-
return buffer
|
16 |
|
17 |
|
18 |
-
def
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
st.title("πΉ Sound Refuckulator")
|
26 |
|
@@ -43,33 +48,44 @@ else:
|
|
43 |
|
44 |
|
45 |
if audio.any():
|
|
|
46 |
cols = st.columns(5)
|
47 |
chunk_dividend = cols[0].slider("π« Chunkizer", 16, 128, step=16)
|
48 |
-
|
49 |
-
|
50 |
sr_factor = cols[3].slider("πββοΈ Chirpidize", 1, 16, 1)
|
51 |
-
rev_size = cols[4].slider("π Hugermaker", 0.0, 0.
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
53 |
reverb = pb.Pedalboard([pb.Reverb(room_size=rev_size)])
|
54 |
-
chorus = pb.Pedalboard([pb.Chorus()])
|
55 |
-
|
|
|
|
|
|
|
56 |
processed = []
|
57 |
chunk_dividend = sorted(np.random.randint(audio.shape[0], size=chunk_dividend))
|
58 |
for i, chunk in enumerate(np.array_split(audio, chunk_dividend)):
|
59 |
-
if np.random.randint(100) < prob
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
processed += [s for s in chunk]
|
68 |
|
69 |
processed = np.array(processed)
|
70 |
reverb = pb.Pedalboard([pb.Reverb(room_size=0.3)])
|
71 |
-
|
72 |
compressor = pb.Pedalboard([pb.Limiter(threshold_db=-1)])
|
73 |
-
|
74 |
|
75 |
-
st.audio(
|
|
|
8 |
import pedalboard as pb
|
9 |
|
10 |
|
11 |
+
def stretch(audio, factor):
|
12 |
+
buffer = []
|
13 |
for s in audio:
|
14 |
for _ in range(factor):
|
15 |
buffer.append(s)
|
16 |
+
return np.array(buffer)
|
17 |
|
18 |
|
19 |
+
def fix_pops(chunk):
|
20 |
+
chunk = np.array(chunk)
|
21 |
+
print(type(chunk), type(chunk[0]), type(chunk[-1]))
|
22 |
+
# print(chunk[0].shape, chunk[-1].shape)
|
23 |
+
print(chunk[0], chunk[-1])
|
24 |
+
chunk[:, 0] = fix_pops_channel(chunk[:, 0])
|
25 |
+
chunk[:, 1] = fix_pops_channel(chunk[:, 1])
|
26 |
+
|
27 |
+
return chunk
|
28 |
+
|
29 |
|
30 |
st.title("πΉ Sound Refuckulator")
|
31 |
|
|
|
48 |
|
49 |
|
50 |
if audio.any():
|
51 |
+
st.audio(audio.T, sample_rate=sr)
|
52 |
cols = st.columns(5)
|
53 |
chunk_dividend = cols[0].slider("π« Chunkizer", 16, 128, step=16)
|
54 |
+
prob = cols[1].slider("π€‘ Impredictidiblize", 0, 100, 0)
|
55 |
+
stretch_factor = cols[2].slider("π§ Trollizer", 0, 10, 0)
|
56 |
sr_factor = cols[3].slider("πββοΈ Chirpidize", 1, 16, 1)
|
57 |
+
rev_size = cols[4].slider("π Hugermaker", 0.0, 0.09, 0.0)
|
58 |
+
delay_macro = cols[0].slider("πͺ Spaceometer", 0.01, 0.09, 0.0)
|
59 |
+
rounder = cols[1].slider("π€ Rounder", 0, 100, 0)
|
60 |
+
pshift = cols[2].slider("π± Tonermaker", 0, 1, 0)
|
61 |
+
reverse = cols[3].slider("π§Ά Revolver", 0, 1, 0)
|
62 |
+
reps = cols[4].slider("π«£ Repetizer", 0, 3, 0)
|
63 |
+
delay = pb.Pedalboard([pb.Delay(delay_seconds=delay_macro, feedback=delay_macro*5)])
|
64 |
reverb = pb.Pedalboard([pb.Reverb(room_size=rev_size)])
|
65 |
+
chorus = pb.Pedalboard([pb.Chorus(rate_hz=rounder)])
|
66 |
+
pshifter7 = pb.Pedalboard([pb.PitchShift(-7)])
|
67 |
+
pshifter3 = pb.Pedalboard([pb.PitchShift(-3)])
|
68 |
+
pshifter5 = pb.Pedalboard([pb.PitchShift(-5)])
|
69 |
+
pshifter12 = pb.Pedalboard([pb.PitchShift(-12)])
|
70 |
processed = []
|
71 |
chunk_dividend = sorted(np.random.randint(audio.shape[0], size=chunk_dividend))
|
72 |
for i, chunk in enumerate(np.array_split(audio, chunk_dividend)):
|
73 |
+
chunk = stretch(chunk, stretch_factor) if np.random.randint(100) < prob and stretch_factor else chunk
|
74 |
+
chunk = reverb(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob and rev_size else chunk
|
75 |
+
chunk = delay(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob and delay_macro else chunk
|
76 |
+
chunk = chorus(chunk, sample_rate=sr, reset=False) if np.random.randint(100) < prob and rounder else chunk
|
77 |
+
chunk = pshifter7(chunk, sample_rate=sr, reset=True) if np.random.randint(100) < prob and pshift else chunk
|
78 |
+
chunk = pshifter3(chunk, sample_rate=sr, reset=True) if np.random.randint(100) < prob and pshift else chunk
|
79 |
+
chunk = pshifter5(chunk, sample_rate=sr, reset=True) if np.random.randint(100) < prob and pshift else chunk
|
80 |
+
chunk = pshifter12(chunk, sample_rate=sr, reset=True) if np.random.randint(100) < prob and pshift else chunk
|
81 |
+
chunk = chunk * reps if np.random.randint(100) < prob and reps else chunk
|
82 |
+
chunk = np.flip(chunk) if np.random.randint(100) < prob and reverse else chunk
|
83 |
processed += [s for s in chunk]
|
84 |
|
85 |
processed = np.array(processed)
|
86 |
reverb = pb.Pedalboard([pb.Reverb(room_size=0.3)])
|
87 |
+
# processed = reverb(processed, sr, reset=False)
|
88 |
compressor = pb.Pedalboard([pb.Limiter(threshold_db=-1)])
|
89 |
+
processed = compressor(processed, sr, reset=False)
|
90 |
|
91 |
+
st.audio(processed.T, sample_rate=sr * sr_factor)
|