Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -224,55 +224,56 @@ with playground:
|
|
224 |
## Speech Translator
|
225 |
## ================================================================================================================================
|
226 |
with gr.TabItem("Speech Translator"):
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
)
|
239 |
-
|
240 |
-
|
241 |
-
choices=["en", "de", "es", "fr"], value="fr", label="Target Language"
|
242 |
-
)
|
243 |
-
|
244 |
-
with gr.Row():
|
245 |
-
with gr.Column():
|
246 |
-
input_audio = gr.Audio(sources=["microphone"], type="filepath", label="Input Audio")
|
247 |
-
with gr.Column():
|
248 |
-
translated_speech = gr.Audio(type="filepath", label="Generated Speech")
|
249 |
-
|
250 |
-
with gr.Row():
|
251 |
-
with gr.Column():
|
252 |
-
transcipted_text = gr.Textbox(label="Transcription")
|
253 |
-
with gr.Column():
|
254 |
-
translated_text = gr.Textbox(label="Translation")
|
255 |
-
|
256 |
-
with gr.Row():
|
257 |
-
with gr.Column():
|
258 |
-
submit_button = gr.Button(value="Start Process", variant="primary")
|
259 |
-
with gr.Column():
|
260 |
-
clear_button = gr.ClearButton(components=[input_audio, source_lang, target_lang, transcipted_text, translated_text, translated_speech], value="Clear")
|
261 |
-
|
262 |
-
with gr.Row():
|
263 |
-
gr.Examples(
|
264 |
-
examples=[
|
265 |
-
["audio/sample_en.wav","en","fr"],
|
266 |
-
["audio/sample_fr.wav","fr","de"],
|
267 |
-
["audio/sample_de.wav","de","es"],
|
268 |
-
["audio/sample_es.wav","es","en"]
|
269 |
-
],
|
270 |
-
inputs=[input_audio, source_lang, target_lang],
|
271 |
-
outputs=[transcipted_text, translated_text, translated_speech],
|
272 |
-
run_on_click=True, cache_examples=True, fn=start_process
|
273 |
-
)
|
274 |
-
|
275 |
-
submit_button.click(start_process, inputs=[input_audio, source_lang, target_lang], outputs=[transcipted_text, translated_text, translated_speech])
|
276 |
|
277 |
|
278 |
|
|
|
224 |
## Speech Translator
|
225 |
## ================================================================================================================================
|
226 |
with gr.TabItem("Speech Translator"):
|
227 |
+
with gr.Row():
|
228 |
+
gr.Markdown("""
|
229 |
+
## Your AI Translate Assistant
|
230 |
+
### Gets input audio from user, transcribe and translate it. Convert back to speech.
|
231 |
+
- category: [Automatic Speech Recognition](https://huggingface.co/models?pipeline_tag=automatic-speech-recognition), model: [nvidia/canary-1b](https://huggingface.co/nvidia/canary-1b)
|
232 |
+
- category: [Text-to-Speech](https://huggingface.co/models?pipeline_tag=text-to-speech), model: [facebook/mms-tts](https://huggingface.co/facebook/mms-tts)
|
233 |
+
""")
|
234 |
+
|
235 |
+
with gr.Row():
|
236 |
+
with gr.Column():
|
237 |
+
source_lang = gr.Dropdown(
|
238 |
+
choices=["en", "de", "es", "fr"], value="en", label="Source Language"
|
239 |
+
)
|
240 |
+
with gr.Column():
|
241 |
+
target_lang = gr.Dropdown(
|
242 |
+
choices=["en", "de", "es", "fr"], value="fr", label="Target Language"
|
243 |
+
)
|
244 |
+
|
245 |
+
with gr.Row():
|
246 |
+
with gr.Column():
|
247 |
+
input_audio = gr.Audio(sources=["microphone"], type="filepath", label="Input Audio")
|
248 |
+
with gr.Column():
|
249 |
+
translated_speech = gr.Audio(type="filepath", label="Generated Speech")
|
250 |
+
|
251 |
+
with gr.Row():
|
252 |
+
with gr.Column():
|
253 |
+
transcipted_text = gr.Textbox(label="Transcription")
|
254 |
+
with gr.Column():
|
255 |
+
translated_text = gr.Textbox(label="Translation")
|
256 |
|
257 |
+
with gr.Row():
|
258 |
+
with gr.Column():
|
259 |
+
submit_button = gr.Button(value="Start Process", variant="primary")
|
260 |
+
with gr.Column():
|
261 |
+
clear_button = gr.ClearButton(components=[input_audio, source_lang, target_lang, transcipted_text, translated_text, translated_speech], value="Clear")
|
262 |
+
|
263 |
+
with gr.Row():
|
264 |
+
gr.Examples(
|
265 |
+
examples=[
|
266 |
+
["audio/sample_en.wav","en","fr"],
|
267 |
+
["audio/sample_fr.wav","fr","de"],
|
268 |
+
["audio/sample_de.wav","de","es"],
|
269 |
+
["audio/sample_es.wav","es","en"]
|
270 |
+
],
|
271 |
+
inputs=[input_audio, source_lang, target_lang],
|
272 |
+
outputs=[transcipted_text, translated_text, translated_speech],
|
273 |
+
run_on_click=True, cache_examples=True, fn=start_process
|
274 |
)
|
275 |
+
|
276 |
+
submit_button.click(start_process, inputs=[input_audio, source_lang, target_lang], outputs=[transcipted_text, translated_text, translated_speech])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
|
279 |
|