bartman081523
commited on
Commit
·
6671fe4
1
Parent(s):
f2f7de9
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import numpy as np
|
|
2 |
import soundfile as sf
|
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
|
@@ -58,6 +59,11 @@ def convert_to_wav(data, sample_rate):
|
|
58 |
|
59 |
return temp_file
|
60 |
|
|
|
|
|
|
|
|
|
|
|
61 |
iface = gr.Interface(
|
62 |
generate_vinyl_sound,
|
63 |
[
|
@@ -69,7 +75,7 @@ iface = gr.Interface(
|
|
69 |
],
|
70 |
[
|
71 |
gr.outputs.Audio(label="Generated Vinyl Sound", type="numpy"),
|
72 |
-
gr.outputs.
|
73 |
],
|
74 |
title="Vinyl Sound Generator",
|
75 |
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.",
|
|
|
2 |
import soundfile as sf
|
3 |
from scipy import signal
|
4 |
import gradio as gr
|
5 |
+
import shutil
|
6 |
|
7 |
def generate_vinyl_sound(noise_ratio, lowcut, highcut, duration, pop_rate):
|
8 |
# Parameters
|
|
|
59 |
|
60 |
return temp_file
|
61 |
|
62 |
+
def download_wav(data, sample_rate):
|
63 |
+
temp_file = convert_to_wav(data, sample_rate)
|
64 |
+
shutil.move(temp_file, "download.wav")
|
65 |
+
return "download.wav"
|
66 |
+
|
67 |
iface = gr.Interface(
|
68 |
generate_vinyl_sound,
|
69 |
[
|
|
|
75 |
],
|
76 |
[
|
77 |
gr.outputs.Audio(label="Generated Vinyl Sound", type="numpy"),
|
78 |
+
gr.outputs.Button(label="Download Vinyl Sound", type="auto", callback=download_wav)
|
79 |
],
|
80 |
title="Vinyl Sound Generator",
|
81 |
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.",
|