Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -83,35 +83,68 @@ def generate_audio(text, length,
|
|
83 |
return params['autoencoder']['sr'], pred
|
84 |
|
85 |
|
86 |
-
#
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
return params['autoencoder']['sr'], pred
|
84 |
|
85 |
|
86 |
+
# Examples (if needed for the demo)
|
87 |
+
examples = [
|
88 |
+
"the sound of rain falling softly",
|
89 |
+
"a dog barking in the distance",
|
90 |
+
"light guitar music is playing",
|
91 |
+
]
|
92 |
+
|
93 |
+
# CSS styling (optional)
|
94 |
+
css = """
|
95 |
+
#col-container {
|
96 |
+
margin: 0 auto;
|
97 |
+
max-width: 1280px;
|
98 |
+
}
|
99 |
+
"""
|
100 |
+
|
101 |
+
# Gradio Blocks layout
|
102 |
+
with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
103 |
+
with gr.Column(elem_id="col-container"):
|
104 |
+
gr.Markdown("""
|
105 |
+
# EzAudio Text-to-Audio Generator
|
106 |
+
Generate audio from text using a diffusion transformer. Adjust advanced settings for more control.
|
107 |
+
""")
|
108 |
+
|
109 |
+
# Basic Input: Text prompt and Audio Length
|
110 |
+
with gr.Row():
|
111 |
+
text_input = gr.Textbox(
|
112 |
+
label="Text Prompt",
|
113 |
+
show_label=False,
|
114 |
+
max_lines=2,
|
115 |
+
placeholder="Enter your prompt",
|
116 |
+
container=False,
|
117 |
+
value="a dog barking in the distance"
|
118 |
+
)
|
119 |
+
length_input = gr.Slider(minimum=1, maximum=10, step=1, value=10, label="Audio Length (in seconds)")
|
120 |
+
|
121 |
+
# Output Component
|
122 |
+
result = gr.Audio(label="Result", type="numpy")
|
123 |
+
|
124 |
+
# Advanced settings in an Accordion
|
125 |
+
with gr.Accordion("Advanced Settings", open=False):
|
126 |
+
guidance_scale = gr.Slider(minimum=1.0, maximum=10, step=0.1, value=5.0, label="Guidance Scale")
|
127 |
+
guidance_rescale = gr.Slider(minimum=0.0, maximum=1, step=0.05, value=0.75, label="Guidance Rescale")
|
128 |
+
ddim_steps = gr.Slider(minimum=25, maximum=200, step=5, value=100, label="DDIM Steps")
|
129 |
+
eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=1.0, label="Eta")
|
130 |
+
seed = gr.Slider(minimum=0, maximum=MAX_SEED, step=1, value=0, label="Seed")
|
131 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=False)
|
132 |
+
|
133 |
+
# Examples block
|
134 |
+
gr.Examples(
|
135 |
+
examples=examples,
|
136 |
+
inputs=[text_input]
|
137 |
+
)
|
138 |
+
|
139 |
+
# Run button
|
140 |
+
run_button = gr.Button("Generate")
|
141 |
+
|
142 |
+
# Define the trigger and input-output linking
|
143 |
+
run_button.click(
|
144 |
+
fn=generate_audio,
|
145 |
+
inputs=[text_input, length_input, guidance_scale, guidance_rescale, ddim_steps, eta, seed, randomize_seed],
|
146 |
+
outputs=[result]
|
147 |
+
)
|
148 |
+
|
149 |
+
# Launch the Gradio demo
|
150 |
+
demo.launch()
|