Spaces:
Running
on
Zero
Running
on
Zero
soujanyaporia
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ from models import AudioDiffusion, DDPMScheduler
|
|
8 |
from audioldm.audio.stft import TacotronSTFT
|
9 |
from audioldm.variational_autoencoder import AutoencoderKL
|
10 |
from gradio import Markdown
|
|
|
11 |
|
12 |
class Tango:
|
13 |
def __init__(self, name="declare-lab/tango", device="cuda:0"):
|
@@ -67,11 +68,13 @@ class Tango:
|
|
67 |
return list(self.chunks(outputs, samples))
|
68 |
|
69 |
# Initialize TANGO
|
70 |
-
if torch.cuda.is_available():
|
71 |
-
tango = Tango()
|
72 |
-
else:
|
73 |
-
tango = Tango(device="cpu")
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
def gradio_generate(prompt, steps, guidance):
|
76 |
output_wave = tango.generate(prompt, steps, guidance)
|
77 |
# output_filename = f"{prompt.replace(' ', '_')}_{steps}_{guidance}"[:250] + ".wav"
|
@@ -101,8 +104,8 @@ def gradio_generate(prompt, steps, guidance):
|
|
101 |
# """
|
102 |
description_text = ""
|
103 |
# Gradio input and output components
|
104 |
-
input_text = gr.
|
105 |
-
output_audio = gr.
|
106 |
denoising_steps = gr.Slider(minimum=100, maximum=200, value=100, step=1, label="Steps", interactive=True)
|
107 |
guidance_scale = gr.Slider(minimum=1, maximum=10, value=3, step=0.1, label="Guidance Scale", interactive=True)
|
108 |
|
@@ -133,8 +136,8 @@ gr_interface = gr.Interface(
|
|
133 |
["A helicopter is in flight"],
|
134 |
["A dog barking and a man talking and a racing car passes by"],
|
135 |
],
|
136 |
-
cache_examples=
|
137 |
)
|
138 |
|
139 |
# Launch Gradio app
|
140 |
-
gr_interface.launch()
|
|
|
8 |
from audioldm.audio.stft import TacotronSTFT
|
9 |
from audioldm.variational_autoencoder import AutoencoderKL
|
10 |
from gradio import Markdown
|
11 |
+
import spaces
|
12 |
|
13 |
class Tango:
|
14 |
def __init__(self, name="declare-lab/tango", device="cuda:0"):
|
|
|
68 |
return list(self.chunks(outputs, samples))
|
69 |
|
70 |
# Initialize TANGO
|
|
|
|
|
|
|
|
|
71 |
|
72 |
+
tango = Tango(device="cpu")
|
73 |
+
tango.vae.to("cuda")
|
74 |
+
tango.stft.to("cuda")
|
75 |
+
tango.model.to("cuda")
|
76 |
+
|
77 |
+
@spaces.GPU(duration=60)
|
78 |
def gradio_generate(prompt, steps, guidance):
|
79 |
output_wave = tango.generate(prompt, steps, guidance)
|
80 |
# output_filename = f"{prompt.replace(' ', '_')}_{steps}_{guidance}"[:250] + ".wav"
|
|
|
104 |
# """
|
105 |
description_text = ""
|
106 |
# Gradio input and output components
|
107 |
+
input_text = gr.Textbox(lines=2, label="Prompt")
|
108 |
+
output_audio = gr.Audio(label="Generated Audio", type="filepath")
|
109 |
denoising_steps = gr.Slider(minimum=100, maximum=200, value=100, step=1, label="Steps", interactive=True)
|
110 |
guidance_scale = gr.Slider(minimum=1, maximum=10, value=3, step=0.1, label="Guidance Scale", interactive=True)
|
111 |
|
|
|
136 |
["A helicopter is in flight"],
|
137 |
["A dog barking and a man talking and a racing car passes by"],
|
138 |
],
|
139 |
+
cache_examples="lazy", # Turn on to cache.
|
140 |
)
|
141 |
|
142 |
# Launch Gradio app
|
143 |
+
gr_interface.queue(10).launch()
|