Spaces:
Runtime error
Runtime error
Fabrice-TIERCELIN
commited on
Commit
β’
98fe6bf
1
Parent(s):
a9fdbcf
.wav or .mp3
Browse files
app.py
CHANGED
@@ -82,20 +82,28 @@ tango.model.to(device_type)
|
|
82 |
|
83 |
def check(
|
84 |
prompt,
|
|
|
85 |
output_number,
|
86 |
steps,
|
87 |
guidance
|
88 |
):
|
89 |
if prompt is None or prompt == "":
|
90 |
raise gr.Error("Please provide a prompt input.")
|
|
|
|
|
91 |
if not output_number in [1, 2, 3]:
|
92 |
raise gr.Error("Please ask for 1, 2 or 3 output files.")
|
93 |
|
94 |
-
def
|
95 |
-
return [
|
|
|
|
|
|
|
|
|
96 |
|
97 |
def text2audio(
|
98 |
prompt,
|
|
|
99 |
output_number,
|
100 |
steps,
|
101 |
guidance
|
@@ -141,30 +149,34 @@ with gr.Blocks() as interface:
|
|
141 |
"""
|
142 |
)
|
143 |
input_text = gr.Textbox(label = "Prompt", value = "Snort of a horse", lines = 2, autofocus = True)
|
|
|
144 |
with gr.Accordion("Advanced options", open = False):
|
145 |
output_number = gr.Slider(label = "Number of generations", info = "1, 2 or 3 output files", minimum = 1, maximum = 3, value = 3, step = 1, interactive = True)
|
146 |
denoising_steps = gr.Slider(label = "Steps", info = "lower=faster & variant, higher=audio quality & similar", minimum = 100, maximum = 200, value = 100, step = 1, interactive = True)
|
147 |
guidance_scale = gr.Slider(label = "Guidance Scale", info = "lower=audio quality, higher=follow the prompt", minimum = 1, maximum = 10, value = 3, step = 0.1, interactive = True)
|
148 |
|
149 |
-
submit = gr.Button("Generate
|
150 |
|
151 |
-
output_audio_1 = gr.Audio(label = "Generated Audio #1/3")
|
152 |
-
output_audio_2 = gr.Audio(label = "Generated Audio #2/3")
|
153 |
-
output_audio_3 = gr.Audio(label = "Generated Audio #3/3")
|
154 |
information = gr.Label(label = "Information")
|
155 |
|
156 |
submit.click(fn = check, inputs = [
|
157 |
input_text,
|
|
|
158 |
output_number,
|
159 |
denoising_steps,
|
160 |
guidance_scale
|
161 |
-
], outputs = [], queue = False, show_progress = False).success(fn =
|
162 |
output_number
|
163 |
], outputs = [
|
|
|
164 |
output_audio_2,
|
165 |
output_audio_3
|
166 |
], queue = False, show_progress = False).success(fn = text2audio, inputs = [
|
167 |
input_text,
|
|
|
168 |
output_number,
|
169 |
denoising_steps,
|
170 |
guidance_scale
|
@@ -179,6 +191,7 @@ with gr.Blocks() as interface:
|
|
179 |
fn = text2audio,
|
180 |
inputs = [
|
181 |
input_text,
|
|
|
182 |
output_number,
|
183 |
denoising_steps,
|
184 |
guidance_scale
|
@@ -190,11 +203,11 @@ with gr.Blocks() as interface:
|
|
190 |
information
|
191 |
],
|
192 |
examples = [
|
193 |
-
["A hammer is hitting a wooden surface", 3, 100, 3],
|
194 |
-
["Peaceful and calming ambient music with singing bowl and other instruments.", 3, 100, 3],
|
195 |
-
["A man is speaking in a small room.",
|
196 |
-
["A female is speaking followed by footstep sound",
|
197 |
-
["Wooden table tapping sound followed by water pouring sound.", 3,
|
198 |
],
|
199 |
cache_examples = "lazy",
|
200 |
)
|
|
|
82 |
|
83 |
def check(
|
84 |
prompt,
|
85 |
+
output_format,
|
86 |
output_number,
|
87 |
steps,
|
88 |
guidance
|
89 |
):
|
90 |
if prompt is None or prompt == "":
|
91 |
raise gr.Error("Please provide a prompt input.")
|
92 |
+
if not output_format in ["wav", "mp3"]:
|
93 |
+
raise gr.Error("Please choose an allowed output format (.wav or .mp3).")
|
94 |
if not output_number in [1, 2, 3]:
|
95 |
raise gr.Error("Please ask for 1, 2 or 3 output files.")
|
96 |
|
97 |
+
def update_output(output_format, output_number):
|
98 |
+
return [
|
99 |
+
gr.update(format = output_format),
|
100 |
+
gr.update(format = output_format, visible = (2 <= output_number)),
|
101 |
+
gr.update(format = output_format, visible = (output_number == 3))
|
102 |
+
]
|
103 |
|
104 |
def text2audio(
|
105 |
prompt,
|
106 |
+
output_format,
|
107 |
output_number,
|
108 |
steps,
|
109 |
guidance
|
|
|
149 |
"""
|
150 |
)
|
151 |
input_text = gr.Textbox(label = "Prompt", value = "Snort of a horse", lines = 2, autofocus = True)
|
152 |
+
output_format = gr.Radio(label = "Output format", info = "The file you can dowload", ["mp3", "wav"], value = "mp3")
|
153 |
with gr.Accordion("Advanced options", open = False):
|
154 |
output_number = gr.Slider(label = "Number of generations", info = "1, 2 or 3 output files", minimum = 1, maximum = 3, value = 3, step = 1, interactive = True)
|
155 |
denoising_steps = gr.Slider(label = "Steps", info = "lower=faster & variant, higher=audio quality & similar", minimum = 100, maximum = 200, value = 100, step = 1, interactive = True)
|
156 |
guidance_scale = gr.Slider(label = "Guidance Scale", info = "lower=audio quality, higher=follow the prompt", minimum = 1, maximum = 10, value = 3, step = 0.1, interactive = True)
|
157 |
|
158 |
+
submit = gr.Button("π Generate", variant = "primary")
|
159 |
|
160 |
+
output_audio_1 = gr.Audio(label = "Generated Audio #1/3", format = "mp3", autoplay = True)
|
161 |
+
output_audio_2 = gr.Audio(label = "Generated Audio #2/3", format = "mp3")
|
162 |
+
output_audio_3 = gr.Audio(label = "Generated Audio #3/3", format = "mp3")
|
163 |
information = gr.Label(label = "Information")
|
164 |
|
165 |
submit.click(fn = check, inputs = [
|
166 |
input_text,
|
167 |
+
output_format,
|
168 |
output_number,
|
169 |
denoising_steps,
|
170 |
guidance_scale
|
171 |
+
], outputs = [], queue = False, show_progress = False).success(fn = update_output, inputs = [
|
172 |
output_number
|
173 |
], outputs = [
|
174 |
+
output_audio_1,
|
175 |
output_audio_2,
|
176 |
output_audio_3
|
177 |
], queue = False, show_progress = False).success(fn = text2audio, inputs = [
|
178 |
input_text,
|
179 |
+
output_format,
|
180 |
output_number,
|
181 |
denoising_steps,
|
182 |
guidance_scale
|
|
|
191 |
fn = text2audio,
|
192 |
inputs = [
|
193 |
input_text,
|
194 |
+
output_format,
|
195 |
output_number,
|
196 |
denoising_steps,
|
197 |
guidance_scale
|
|
|
203 |
information
|
204 |
],
|
205 |
examples = [
|
206 |
+
["A hammer is hitting a wooden surface", "mp3", 3, 100, 3],
|
207 |
+
["Peaceful and calming ambient music with singing bowl and other instruments.", "wav", 3, 100, 3],
|
208 |
+
["A man is speaking in a small room.", "mp3", 2, 100, 3],
|
209 |
+
["A female is speaking followed by footstep sound", "mp3", 1, 100, 3],
|
210 |
+
["Wooden table tapping sound followed by water pouring sound.", "mp3", 3, 200, 3],
|
211 |
],
|
212 |
cache_examples = "lazy",
|
213 |
)
|