Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -116,9 +116,9 @@ mic_translate = gr.Interface(
|
|
116 |
)
|
117 |
|
118 |
# File translation using uploaded files as input
|
119 |
-
|
120 |
fn=speech_to_speech_translation,
|
121 |
-
inputs=gr.Audio(source="upload", type="filepath"),
|
122 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
123 |
examples=[["./english.wav"], ["./chinese.wav"]],
|
124 |
title=title,
|
@@ -134,7 +134,65 @@ text_translate = gr.Interface(
|
|
134 |
description=description
|
135 |
)
|
136 |
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
with gr.Column(elem_id="col-container"):
|
140 |
gr.Markdown(f"""
|
@@ -221,16 +279,23 @@ with gr.Blocks(css=css) as image:
|
|
221 |
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
222 |
outputs = [result]
|
223 |
)
|
|
|
224 |
|
225 |
# Text to Image interface
|
226 |
image_generation = gr.Interface(
|
227 |
fn=infer,
|
228 |
inputs=[prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
229 |
-
outputs=[result]
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
)
|
231 |
|
232 |
# Showcase the demo using different tabs of the different features
|
233 |
with demo:
|
234 |
-
gr.TabbedInterface([
|
235 |
|
236 |
demo.launch()
|
|
|
116 |
)
|
117 |
|
118 |
# File translation using uploaded files as input
|
119 |
+
audio_translate = gr.Interface(
|
120 |
fn=speech_to_speech_translation,
|
121 |
+
inputs=[[gr.Audio(source="microphone", type="filepath")], [gr.Audio(source="upload", type="filepath")]],
|
122 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
123 |
examples=[["./english.wav"], ["./chinese.wav"]],
|
124 |
title=title,
|
|
|
134 |
description=description
|
135 |
)
|
136 |
|
137 |
+
# Inputs for Image Generation
|
138 |
+
prompt = gr.Text(
|
139 |
+
label="Prompt",
|
140 |
+
show_label=False,
|
141 |
+
max_lines=1,
|
142 |
+
placeholder="Enter your prompt",
|
143 |
+
container=False,
|
144 |
+
)
|
145 |
+
|
146 |
+
negative_prompt = gr.Text(
|
147 |
+
label="Negative prompt",
|
148 |
+
max_lines=1,
|
149 |
+
placeholder="Enter a negative prompt",
|
150 |
+
visible=False,
|
151 |
+
)
|
152 |
+
|
153 |
+
seed = gr.Slider(
|
154 |
+
label="Seed",
|
155 |
+
minimum=0,
|
156 |
+
maximum=MAX_SEED,
|
157 |
+
step=1,
|
158 |
+
value=0,
|
159 |
+
)
|
160 |
+
|
161 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
162 |
+
|
163 |
+
width = gr.Slider(
|
164 |
+
label="Width",
|
165 |
+
minimum=256,
|
166 |
+
maximum=MAX_IMAGE_SIZE,
|
167 |
+
step=32,
|
168 |
+
value=512,
|
169 |
+
)
|
170 |
+
|
171 |
+
height = gr.Slider(
|
172 |
+
label="Height",
|
173 |
+
minimum=256,
|
174 |
+
maximum=MAX_IMAGE_SIZE,
|
175 |
+
step=32,
|
176 |
+
value=512,
|
177 |
+
)
|
178 |
+
|
179 |
+
guidance_scale = gr.Slider(
|
180 |
+
label="Guidance scale",
|
181 |
+
minimum=0.0,
|
182 |
+
maximum=10.0,
|
183 |
+
step=0.1,
|
184 |
+
value=0.0,
|
185 |
+
)
|
186 |
+
|
187 |
+
num_inference_steps = gr.Slider(
|
188 |
+
label="Number of inference steps",
|
189 |
+
minimum=1,
|
190 |
+
maximum=12,
|
191 |
+
step=1,
|
192 |
+
value=2,
|
193 |
+
)
|
194 |
+
|
195 |
+
'''with gr.Blocks(css=css) as image:
|
196 |
|
197 |
with gr.Column(elem_id="col-container"):
|
198 |
gr.Markdown(f"""
|
|
|
279 |
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
280 |
outputs = [result]
|
281 |
)
|
282 |
+
'''
|
283 |
|
284 |
# Text to Image interface
|
285 |
image_generation = gr.Interface(
|
286 |
fn=infer,
|
287 |
inputs=[prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
288 |
+
outputs=[result],
|
289 |
+
examples=gr.Examples(
|
290 |
+
examples = examples,
|
291 |
+
inputs = [prompt]
|
292 |
+
),
|
293 |
+
title=title,
|
294 |
+
description=description,
|
295 |
)
|
296 |
|
297 |
# Showcase the demo using different tabs of the different features
|
298 |
with demo:
|
299 |
+
gr.TabbedInterface([audio_translate, file_translate, text_translate, image_generation], ["Speech to Text", "Audio File", "Text to Speech", "Text to Image"])
|
300 |
|
301 |
demo.launch()
|