bartman081523 commited on
Commit
2d54a75
1 Parent(s): 416096f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -3,9 +3,8 @@ import soundfile as sf
3
  from scipy import signal
4
  import gradio as gr
5
 
6
- def generate_vinyl_sound(noise_ratio, lowcut, highcut):
7
  # Parameters
8
- duration = 10.0 # duration of the sound in seconds
9
  sample_rate = 44100 # sample rate in Hz
10
  num_samples = int(duration * sample_rate)
11
 
@@ -32,7 +31,6 @@ def generate_vinyl_sound(noise_ratio, lowcut, highcut):
32
  hiss_noise = signal.lfilter(b, a, hiss_noise)
33
 
34
  # Generate pops
35
- pop_rate = 10 # average number of pops per second
36
  num_pops = int(duration * pop_rate)
37
  pop_times = np.random.randint(0, num_samples, num_pops)
38
  pop_data = np.zeros(num_samples)
@@ -53,18 +51,20 @@ def generate_vinyl_sound(noise_ratio, lowcut, highcut):
53
  iface = gr.Interface(
54
  generate_vinyl_sound,
55
  [
56
- gr.inputs.Slider(minimum=0, maximum=1, default=0.7, step=0.1, label="Noise Ratio"),
57
  gr.inputs.Slider(minimum=20, maximum=20000, default=300, step=10, label="Lowcut Frequency (Hz)"),
58
- gr.inputs.Slider(minimum=20, maximum=20000, default=5000, step=10, label="Highcut Frequency (Hz)")
 
 
59
  ],
60
  gr.outputs.Audio(label="Generated Vinyl Sound"),
61
  title="Vinyl Sound Generator",
62
- description="Generate a synthetic vinyl sound using pink noise, rumble, hiss, and pops. Adjust the noise ratio and bandpass frequencies to modify the sound.",
63
  examples=[
64
- [0.7, 300, 5000],
65
- [0.5, 500, 4000],
66
- [0.8, 200, 6000]
67
  ]
68
  )
69
 
70
- iface.launch()
 
3
  from scipy import signal
4
  import gradio as gr
5
 
6
+ def generate_vinyl_sound(noise_ratio, lowcut, highcut, duration, pop_rate):
7
  # Parameters
 
8
  sample_rate = 44100 # sample rate in Hz
9
  num_samples = int(duration * sample_rate)
10
 
 
31
  hiss_noise = signal.lfilter(b, a, hiss_noise)
32
 
33
  # Generate pops
 
34
  num_pops = int(duration * pop_rate)
35
  pop_times = np.random.randint(0, num_samples, num_pops)
36
  pop_data = np.zeros(num_samples)
 
51
  iface = gr.Interface(
52
  generate_vinyl_sound,
53
  [
54
+ gr.inputs.Slider(minimum=0, maximum=1, default=0.001, step=0.001, label="Noise Ratio"),
55
  gr.inputs.Slider(minimum=20, maximum=20000, default=300, step=10, label="Lowcut Frequency (Hz)"),
56
+ gr.inputs.Slider(minimum=20, maximum=20000, default=5000, step=10, label="Highcut Frequency (Hz)"),
57
+ gr.inputs.Slider(minimum=1, maximum=60, default=10, step=1, label="Duration (seconds)"),
58
+ gr.inputs.Slider(minimum=1, maximum=100, default=10, step=1, label="Pop Rate (pops per second)")
59
  ],
60
  gr.outputs.Audio(label="Generated Vinyl Sound"),
61
  title="Vinyl Sound Generator",
62
+ description="Generate a synthetic vinyl sound using pink noise, rumble, hiss, and pops. Adjust the noise ratio, bandpass frequencies, duration, and pop rate to modify the sound.",
63
  examples=[
64
+ [0.001, 300, 5000, 10, 10],
65
+ [0.002, 500, 4000, 15, 20],
66
+ [0.005, 200, 6000, 20, 30]
67
  ]
68
  )
69
 
70
+ iface.launch()