Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,11 @@ def diffuse(prompt, guidance_scale, nb_iterations, seed):
|
|
36 |
|
37 |
generator = torch.Generator(device=device).manual_seed(int(seed))
|
38 |
|
39 |
-
print("
|
|
|
|
|
|
|
|
|
40 |
print("prompt: " + prompt)
|
41 |
print("guidance scale: " + str(guidance_scale))
|
42 |
print("inference steps: " + str(nb_iterations))
|
@@ -63,6 +67,11 @@ def diffuse(prompt, guidance_scale, nb_iterations, seed):
|
|
63 |
return images
|
64 |
|
65 |
def translate(audio):
|
|
|
|
|
|
|
|
|
|
|
66 |
audio = whisper.load_audio(audio)
|
67 |
audio = whisper.pad_or_trim(audio)
|
68 |
|
@@ -77,8 +86,8 @@ def translate(audio):
|
|
77 |
translation = whisper.decode(whisper_model, mel, translate_options)
|
78 |
|
79 |
print("language spoken: " + transcription.language)
|
80 |
-
print(transcription.text)
|
81 |
-
print(translation.text)
|
82 |
|
83 |
return transcription.language, transcription.text, translation.text
|
84 |
|
@@ -144,8 +153,11 @@ css = """
|
|
144 |
padding: 20px;
|
145 |
height: 160px;
|
146 |
}
|
147 |
-
#
|
148 |
-
|
|
|
|
|
|
|
149 |
}
|
150 |
div#spoken_lang textarea {
|
151 |
font-size: 4em;
|
@@ -197,7 +209,7 @@ with gr.Blocks(css=css) as demo:
|
|
197 |
</p>
|
198 |
|
199 |
<p style='text-align: center;'>
|
200 |
-
This demo is running on π’ CPU
|
201 |
β
|
202 |
</p>
|
203 |
|
@@ -222,14 +234,19 @@ with gr.Blocks(css=css) as demo:
|
|
222 |
)
|
223 |
with gr.Row():
|
224 |
audio_r_translate = gr.Button("Check Whisper first ? π")
|
225 |
-
audio_r_direct_sd = gr.Button("Magic Whisper
|
226 |
|
227 |
with gr.Tab(label="Upload audio input", elem_id="upload_tab"):
|
228 |
with gr.Column():
|
229 |
-
upload_input = gr.Audio(
|
|
|
|
|
|
|
|
|
|
|
230 |
with gr.Row():
|
231 |
-
audio_u_translate = gr.Button("Check Whisper first ?")
|
232 |
-
audio_u_direct_sd = gr.Button("Magic Whisper
|
233 |
|
234 |
with gr.Accordion(label="Stable Diffusion Settings", elem_id="sd_settings"):
|
235 |
with gr.Row():
|
|
|
36 |
|
37 |
generator = torch.Generator(device=device).manual_seed(int(seed))
|
38 |
|
39 |
+
print("""
|
40 |
+
β
|
41 |
+
Sending prompt to Stable Diffusion ...
|
42 |
+
β
|
43 |
+
""")
|
44 |
print("prompt: " + prompt)
|
45 |
print("guidance scale: " + str(guidance_scale))
|
46 |
print("inference steps: " + str(nb_iterations))
|
|
|
67 |
return images
|
68 |
|
69 |
def translate(audio):
|
70 |
+
print("""
|
71 |
+
β
|
72 |
+
Sending audio to Whisper ...
|
73 |
+
β
|
74 |
+
""")
|
75 |
audio = whisper.load_audio(audio)
|
76 |
audio = whisper.pad_or_trim(audio)
|
77 |
|
|
|
86 |
translation = whisper.decode(whisper_model, mel, translate_options)
|
87 |
|
88 |
print("language spoken: " + transcription.language)
|
89 |
+
print("transcript: " + transcription.text)
|
90 |
+
print("translated: " + translation.text)
|
91 |
|
92 |
return transcription.language, transcription.text, translation.text
|
93 |
|
|
|
153 |
padding: 20px;
|
154 |
height: 160px;
|
155 |
}
|
156 |
+
div#upload_area {
|
157 |
+
height: 11.1rem;
|
158 |
+
}
|
159 |
+
div#upload_area > div.w-full > div {
|
160 |
+
min-height: 9rem;
|
161 |
}
|
162 |
div#spoken_lang textarea {
|
163 |
font-size: 4em;
|
|
|
209 |
</p>
|
210 |
|
211 |
<p style='text-align: center;'>
|
212 |
+
This demo is running on π’ CPU β’ Offered by Sylvain <a href='https://twitter.com/fffiloni' target='_blank'>@fffiloni</a> β’ <img id='visitor-badge' alt='visitor badge' src='https://visitor-badge.glitch.me/badge?page_id=gradio-blocks.whisper-to-stable-diffusion' style='display: inline-block' /><br />
|
213 |
β
|
214 |
</p>
|
215 |
|
|
|
234 |
)
|
235 |
with gr.Row():
|
236 |
audio_r_translate = gr.Button("Check Whisper first ? π")
|
237 |
+
audio_r_direct_sd = gr.Button("Magic Whisper βΊ SD right now! π€ ")
|
238 |
|
239 |
with gr.Tab(label="Upload audio input", elem_id="upload_tab"):
|
240 |
with gr.Column():
|
241 |
+
upload_input = gr.Audio(
|
242 |
+
source="upload",
|
243 |
+
type="filepath",
|
244 |
+
show_label=False,
|
245 |
+
elem_id="upload_area"
|
246 |
+
)
|
247 |
with gr.Row():
|
248 |
+
audio_u_translate = gr.Button("Check Whisper first ? π")
|
249 |
+
audio_u_direct_sd = gr.Button("Magic Whisper βΊ SD right now! π€ ")
|
250 |
|
251 |
with gr.Accordion(label="Stable Diffusion Settings", elem_id="sd_settings"):
|
252 |
with gr.Row():
|