Spaces:
Runtime error
Runtime error
artificialguybr
commited on
Commit
•
d8f2cab
1
Parent(s):
0ff2f1e
Update app.py
Browse files
app.py
CHANGED
@@ -1,57 +1,53 @@
|
|
1 |
-
import gradio as gr
|
2 |
from gradio_client import Client
|
|
|
3 |
|
4 |
-
def process_video(video_url, target_language, translate_video):
|
5 |
-
try:
|
6 |
-
client = Client("https://artificialguybr-video-translation-transcription.hf.space/")
|
7 |
-
result = client.predict(
|
8 |
-
video_url,
|
9 |
-
target_language,
|
10 |
-
translate_video,
|
11 |
-
api_name="/predict"
|
12 |
-
)
|
13 |
-
return result
|
14 |
-
except Exception as e:
|
15 |
-
print(f"Error al llamar a la API: {e}")
|
16 |
-
return "Ocurrió un error al procesar el vídeo."
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
"
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
-
# Interfaz de Gradio
|
43 |
iface = gr.Interface(
|
44 |
-
fn=
|
45 |
-
inputs=[
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
"""),
|
55 |
)
|
56 |
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from gradio_client import Client
|
2 |
+
import gradio as gr
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
def interact_with_api(video_url, target_language, translate_video):
|
6 |
+
client = Client("https://artificialguybr-video-translation-transcription.hf.space/")
|
7 |
+
result = client.predict(
|
8 |
+
video_url,
|
9 |
+
target_language,
|
10 |
+
translate_video,
|
11 |
+
api_name="/predict"
|
12 |
+
)
|
13 |
+
return result
|
14 |
+
|
15 |
+
# Lista de opções de idiomas
|
16 |
+
language_options = [
|
17 |
+
"Afrikaans", "Albanian", "Amharic", "Arabic", "Armenian", "Azerbaijani", "Basque", "Belarusian",
|
18 |
+
"Bengali", "Bosnian", "Bulgarian", "Catalan", "Cebuano", "Chichewa", "Chinese (Simplified)",
|
19 |
+
"Chinese (Traditional)", "Corsican", "Croatian", "Czech", "Danish", "Dutch", "English", "Esperanto",
|
20 |
+
"Estonian", "Filipino", "Finnish", "French", "Frisian", "Galician", "Georgian", "German", "Greek",
|
21 |
+
"Gujarati", "Haitian Creole", "Hausa", "Hawaiian", "Hebrew", "Hindi", "Hmong", "Hungarian", "Icelandic",
|
22 |
+
"Igbo", "Indonesian", "Irish", "Italian", "Japanese", "Javanese", "Kannada", "Kazakh", "Khmer",
|
23 |
+
"Korean", "Kurdish (Kurmanji)", "Kyrgyz", "Lao", "Latin", "Latvian", "Lithuanian", "Luxembourgish",
|
24 |
+
"Macedonian", "Malagasy", "Malay", "Malayalam", "Maltese", "Maori", "Marathi", "Mongolian",
|
25 |
+
"Myanmar (Burmese)", "Nepali", "Norwegian", "Odia", "Pashto", "Persian", "Polish", "Portuguese",
|
26 |
+
"Punjabi", "Romanian", "Russian", "Samoan", "Scots Gaelic", "Serbian", "Sesotho", "Shona", "Sindhi",
|
27 |
+
"Sinhala", "Slovak", "Slovenian", "Somali", "Spanish", "Sundanese", "Swahili", "Swedish", "Tajik",
|
28 |
+
"Tamil", "Telugu", "Thai", "Turkish", "Ukrainian", "Urdu", "Uyghur", "Uzbek", "Vietnamese", "Welsh",
|
29 |
+
"Xhosa", "Yiddish", "Yoruba", "Zulu"
|
30 |
+
]
|
31 |
|
|
|
32 |
iface = gr.Interface(
|
33 |
+
fn=interact_with_api,
|
34 |
+
inputs=[
|
35 |
+
gr.Video(label="Upload Video or Enter URL"),
|
36 |
+
gr.Dropdown(choices=language_options, label="Target Language for Translation", value="English"),
|
37 |
+
gr.Checkbox(label="Translate Video", value=True, info="Check to translate the video to the selected language. Uncheck for transcription only."),
|
38 |
+
],
|
39 |
+
outputs="video",
|
40 |
+
title="VIDEO TRANSCRIPTION AND TRANSLATION",
|
41 |
+
description="""This tool was developed by [@artificialguybr](https://twitter.com/artificialguybr) using entirely open-source tools. Special thanks to Hugging Face for the GPU support. Test the [Video Dubbing](https://huggingface.co/spaces/artificialguybr/video-dubbing) space!""",
|
42 |
+
allow_flagging=False
|
|
|
43 |
)
|
44 |
|
45 |
+
with gr.Blocks() as demo:
|
46 |
+
iface.render()
|
47 |
+
gr.Markdown("""
|
48 |
+
**Note:**
|
49 |
+
- Video limit is 15 minutes. It will do the transcription and translate of subtitles.
|
50 |
+
- The tool uses open-source models for all models. It's an alpha version.
|
51 |
+
""")
|
52 |
+
demo.queue(concurrency_count=1, max_size=15)
|
53 |
+
demo.launch()
|