Spaces:
Runtime error
Runtime error
Fabrice-TIERCELIN
commited on
Commit
•
e491319
1
Parent(s):
8408dd7
Display and information
Browse files
app.py
CHANGED
@@ -90,24 +90,40 @@ def check(
|
|
90 |
if not output_number in [1, 2, 3]:
|
91 |
raise gr.Error("Please ask for 1, 2 or 3 output files.")
|
92 |
|
|
|
|
|
|
|
93 |
def text2audio(
|
94 |
prompt,
|
95 |
output_number,
|
96 |
steps,
|
97 |
guidance
|
98 |
):
|
|
|
99 |
output_wave = tango.generate(prompt, steps, guidance, output_number)
|
100 |
output_wave_1 = gr.make_waveform((16000, output_wave[0]))
|
101 |
output_wave_2 = gr.make_waveform((16000, output_wave[1])) if (2 <= output_number) else None
|
102 |
output_wave_3 = gr.make_waveform((16000, output_wave[2])) if (output_number == 3) else None
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
# Gradio interface
|
106 |
with gr.Blocks() as interface:
|
107 |
gr.Markdown("""
|
108 |
<p style="text-align: center;">
|
109 |
<b><big><big><big>Text-to-Audio</big></big></big></b>
|
110 |
-
<br/>Generates 10 second
|
111 |
</p>
|
112 |
<br/>
|
113 |
<br/>
|
@@ -134,13 +150,20 @@ with gr.Blocks() as interface:
|
|
134 |
output_audio_1 = gr.Audio(label = "Generated Audio #1/3")
|
135 |
output_audio_2 = gr.Audio(label = "Generated Audio #2/3")
|
136 |
output_audio_3 = gr.Audio(label = "Generated Audio #3/3")
|
|
|
137 |
|
138 |
submit.click(fn = check, inputs = [
|
139 |
input_text,
|
140 |
output_number,
|
141 |
denoising_steps,
|
142 |
guidance_scale
|
143 |
-
], outputs = [], queue = False, show_progress = False).success(fn =
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
input_text,
|
145 |
output_number,
|
146 |
denoising_steps,
|
@@ -148,7 +171,8 @@ with gr.Blocks() as interface:
|
|
148 |
], outputs = [
|
149 |
output_audio_1,
|
150 |
output_audio_2,
|
151 |
-
output_audio_3
|
|
|
152 |
], scroll_to_output = True)
|
153 |
|
154 |
gr.Examples(
|
@@ -162,7 +186,8 @@ with gr.Blocks() as interface:
|
|
162 |
outputs = [
|
163 |
output_audio_1,
|
164 |
output_audio_2,
|
165 |
-
output_audio_3
|
|
|
166 |
],
|
167 |
examples = [
|
168 |
["A hammer is hitting a wooden surface", 1, 100, 3],
|
|
|
90 |
if not output_number in [1, 2, 3]:
|
91 |
raise gr.Error("Please ask for 1, 2 or 3 output files.")
|
92 |
|
93 |
+
def update_display(output_number):
|
94 |
+
return [gr.update(visible = True), gr.update(visible = (2 <= output_number)), gr.update(visible = (output_number == 3))]
|
95 |
+
|
96 |
def text2audio(
|
97 |
prompt,
|
98 |
output_number,
|
99 |
steps,
|
100 |
guidance
|
101 |
):
|
102 |
+
start = time.time()
|
103 |
output_wave = tango.generate(prompt, steps, guidance, output_number)
|
104 |
output_wave_1 = gr.make_waveform((16000, output_wave[0]))
|
105 |
output_wave_2 = gr.make_waveform((16000, output_wave[1])) if (2 <= output_number) else None
|
106 |
output_wave_3 = gr.make_waveform((16000, output_wave[2])) if (output_number == 3) else None
|
107 |
+
|
108 |
+
end = time.time()
|
109 |
+
secondes = int(end - start)
|
110 |
+
minutes = secondes // 60
|
111 |
+
secondes = secondes - (minutes * 60)
|
112 |
+
hours = minutes // 60
|
113 |
+
minutes = minutes - (hours * 60)
|
114 |
+
return [
|
115 |
+
output_wave_1,
|
116 |
+
output_wave_2,
|
117 |
+
output_wave_3,
|
118 |
+
"Start again to get a different result. The output have been generated in " + str(hours) + " h, " + str(minutes) + " min, " + str(secondes) + " sec."
|
119 |
+
]
|
120 |
|
121 |
# Gradio interface
|
122 |
with gr.Blocks() as interface:
|
123 |
gr.Markdown("""
|
124 |
<p style="text-align: center;">
|
125 |
<b><big><big><big>Text-to-Audio</big></big></big></b>
|
126 |
+
<br/>Generates 10 second of sound effect from description, freely, without account, without watermark, that you can download.
|
127 |
</p>
|
128 |
<br/>
|
129 |
<br/>
|
|
|
150 |
output_audio_1 = gr.Audio(label = "Generated Audio #1/3")
|
151 |
output_audio_2 = gr.Audio(label = "Generated Audio #2/3")
|
152 |
output_audio_3 = gr.Audio(label = "Generated Audio #3/3")
|
153 |
+
information = gr.Label(label = "Information")
|
154 |
|
155 |
submit.click(fn = check, inputs = [
|
156 |
input_text,
|
157 |
output_number,
|
158 |
denoising_steps,
|
159 |
guidance_scale
|
160 |
+
], outputs = [], queue = False, show_progress = False).success(fn = update_display, inputs = [
|
161 |
+
output_number
|
162 |
+
], outputs = [
|
163 |
+
output_audio_1,
|
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,
|
|
|
171 |
], outputs = [
|
172 |
output_audio_1,
|
173 |
output_audio_2,
|
174 |
+
output_audio_3,
|
175 |
+
information
|
176 |
], scroll_to_output = True)
|
177 |
|
178 |
gr.Examples(
|
|
|
186 |
outputs = [
|
187 |
output_audio_1,
|
188 |
output_audio_2,
|
189 |
+
output_audio_3,
|
190 |
+
information
|
191 |
],
|
192 |
examples = [
|
193 |
["A hammer is hitting a wooden surface", 1, 100, 3],
|