Spaces:
Runtime error
Runtime error
Emanuele Lapponi
commited on
Commit
Β·
fd00f97
1
Parent(s):
499849b
:sparkles: airplane-sweat.gif
Browse files
app.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
import numpy as np
|
2 |
import io
|
|
|
|
|
|
|
3 |
import pydub
|
4 |
import soundfile as sf
|
5 |
import streamlit as st
|
6 |
from audio_recorder_streamlit import audio_recorder
|
7 |
|
8 |
-
import pedalboard as pb
|
9 |
-
|
10 |
|
11 |
def stretch(audio, factor):
|
12 |
buffer = []
|
@@ -23,11 +23,10 @@ def fix_pops(chunk):
|
|
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
|
31 |
|
32 |
audio = np.array([])
|
33 |
|
@@ -48,19 +47,22 @@ else:
|
|
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 |
-
|
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 |
-
|
63 |
-
delay = pb.Pedalboard(
|
|
|
|
|
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)])
|
@@ -70,14 +72,46 @@ if audio.any():
|
|
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 =
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
chunk =
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]
|
@@ -88,4 +122,5 @@ if audio.any():
|
|
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)
|
|
|
|
|
1 |
import io
|
2 |
+
|
3 |
+
import numpy as np
|
4 |
+
import pedalboard as pb
|
5 |
import pydub
|
6 |
import soundfile as sf
|
7 |
import streamlit as st
|
8 |
from audio_recorder_streamlit import audio_recorder
|
9 |
|
|
|
|
|
10 |
|
11 |
def stretch(audio, factor):
|
12 |
buffer = []
|
|
|
23 |
print(chunk[0], chunk[-1])
|
24 |
chunk[:, 0] = fix_pops_channel(chunk[:, 0])
|
25 |
chunk[:, 1] = fix_pops_channel(chunk[:, 1])
|
|
|
26 |
return chunk
|
27 |
|
28 |
|
29 |
+
st.title("πΉ Sound Refukculator")
|
30 |
|
31 |
audio = np.array([])
|
32 |
|
|
|
47 |
|
48 |
|
49 |
if audio.any():
|
50 |
+
st.write("Original sound:")
|
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 |
+
reps = cols[3].slider("π«£ Repetizer", 0, 3, 0)
|
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 |
+
sr_factor = cols[4].slider("πββοΈ Chirpidize", 1, 16, 1)
|
63 |
+
delay = pb.Pedalboard(
|
64 |
+
[pb.Delay(delay_seconds=delay_macro, feedback=delay_macro * 5)]
|
65 |
+
)
|
66 |
reverb = pb.Pedalboard([pb.Reverb(room_size=rev_size)])
|
67 |
chorus = pb.Pedalboard([pb.Chorus(rate_hz=rounder)])
|
68 |
pshifter7 = pb.Pedalboard([pb.PitchShift(-7)])
|
|
|
72 |
processed = []
|
73 |
chunk_dividend = sorted(np.random.randint(audio.shape[0], size=chunk_dividend))
|
74 |
for i, chunk in enumerate(np.array_split(audio, chunk_dividend)):
|
75 |
+
chunk = (
|
76 |
+
stretch(chunk, stretch_factor)
|
77 |
+
if np.random.randint(100) < prob and stretch_factor
|
78 |
+
else chunk
|
79 |
+
)
|
80 |
+
chunk = (
|
81 |
+
reverb(chunk, sample_rate=sr, reset=False)
|
82 |
+
if np.random.randint(100) < prob and rev_size
|
83 |
+
else chunk
|
84 |
+
)
|
85 |
+
chunk = (
|
86 |
+
delay(chunk, sample_rate=sr, reset=False)
|
87 |
+
if np.random.randint(100) < prob and delay_macro
|
88 |
+
else chunk
|
89 |
+
)
|
90 |
+
chunk = (
|
91 |
+
chorus(chunk, sample_rate=sr, reset=False)
|
92 |
+
if np.random.randint(100) < prob and rounder
|
93 |
+
else chunk
|
94 |
+
)
|
95 |
+
chunk = (
|
96 |
+
pshifter7(chunk, sample_rate=sr, reset=True)
|
97 |
+
if np.random.randint(100) < prob and pshift
|
98 |
+
else chunk
|
99 |
+
)
|
100 |
+
chunk = (
|
101 |
+
pshifter3(chunk, sample_rate=sr, reset=True)
|
102 |
+
if np.random.randint(100) < prob and pshift
|
103 |
+
else chunk
|
104 |
+
)
|
105 |
+
chunk = (
|
106 |
+
pshifter5(chunk, sample_rate=sr, reset=True)
|
107 |
+
if np.random.randint(100) < prob and pshift
|
108 |
+
else chunk
|
109 |
+
)
|
110 |
+
chunk = (
|
111 |
+
pshifter12(chunk, sample_rate=sr, reset=True)
|
112 |
+
if np.random.randint(100) < prob and pshift
|
113 |
+
else chunk
|
114 |
+
)
|
115 |
chunk = chunk * reps if np.random.randint(100) < prob and reps else chunk
|
116 |
chunk = np.flip(chunk) if np.random.randint(100) < prob and reverse else chunk
|
117 |
processed += [s for s in chunk]
|
|
|
122 |
compressor = pb.Pedalboard([pb.Limiter(threshold_db=-1)])
|
123 |
processed = compressor(processed, sr, reset=False)
|
124 |
|
125 |
+
st.write("Refukculized sound:")
|
126 |
st.audio(processed.T, sample_rate=sr * sr_factor)
|