Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,15 +34,18 @@ def generate_vinyl_sound(noise_ratio, lowcut, highcut, duration, pop_rate):
|
|
34 |
b, a = signal.butter(2, 0.4, btype='high')
|
35 |
hiss_noise = signal.lfilter(b, a, hiss_noise)
|
36 |
|
37 |
-
# Generate pops
|
38 |
num_pops = int(duration * pop_rate)
|
39 |
pop_times = np.random.randint(0, num_samples, num_pops)
|
40 |
pop_data = np.zeros(num_samples)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
|
47 |
# Combine the noises and pops
|
48 |
vinyl_sound = noise_ratio * (pink_noise + 0.05 * rumble_noise + 0.05 * hiss_noise) + (1 - noise_ratio) * pop_data
|
@@ -94,4 +97,4 @@ iface = gr.Interface(
|
|
94 |
]
|
95 |
)
|
96 |
|
97 |
-
iface.launch()
|
|
|
34 |
b, a = signal.butter(2, 0.4, btype='high')
|
35 |
hiss_noise = signal.lfilter(b, a, hiss_noise)
|
36 |
|
37 |
+
# Generate pops with varying loudness and frequency
|
38 |
num_pops = int(duration * pop_rate)
|
39 |
pop_times = np.random.randint(0, num_samples, num_pops)
|
40 |
pop_data = np.zeros(num_samples)
|
41 |
+
pop_amplitudes = np.random.uniform(0.05, 0.2, num_pops) # Vary pop amplitudes
|
42 |
+
pop_data[pop_times] = pop_amplitudes # Apply random loudness
|
43 |
+
|
44 |
+
# Create a low-pass filter for clicks, with varying filter frequencies for more realistic pops
|
45 |
+
for i in range(num_pops):
|
46 |
+
pop_filter_freq = np.random.uniform(0.05, 0.2) # Vary filter frequency
|
47 |
+
b, a = signal.butter(4, pop_filter_freq)
|
48 |
+
pop_data[pop_times[i]] = signal.lfilter(b, a, pop_data[pop_times[i]])
|
49 |
|
50 |
# Combine the noises and pops
|
51 |
vinyl_sound = noise_ratio * (pink_noise + 0.05 * rumble_noise + 0.05 * hiss_noise) + (1 - noise_ratio) * pop_data
|
|
|
97 |
]
|
98 |
)
|
99 |
|
100 |
+
iface.launch()
|