Salman11223 commited on
Commit
eacd553
·
verified ·
1 Parent(s): ad48ff9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from translator import translation # Assuming your translation class is in a translator.py file
4
+
5
+ def app(video_path, original_language, target_language):
6
+ # Move to the working directory
7
+ os.chdir('/workspace') # Adjust path based on Hugging Face's working directory
8
+
9
+ # Use the Gradio-provided path to the uploaded file
10
+ video_name = os.path.basename(video_path.name)
11
+
12
+ # Instantiate the translation class with video and language information
13
+ translator = translation(video_name, original_language, target_language)
14
+
15
+ # Translate the video and return the output file path
16
+ video_file = translator.translate_video()
17
+
18
+ return video_file
19
+
20
+ # Gradio interface setup
21
+ interface_video_file = gr.Interface(
22
+ fn=app,
23
+ inputs=[
24
+ gr.Video(label="Upload a Video"),
25
+ gr.Dropdown(["English", "German", "French", "Spanish"], label="Original Language"),
26
+ gr.Dropdown(["English", "German", "French", "Spanish"], label="Target Language"),
27
+ ],
28
+ outputs=gr.Video(label="Translated Video")
29
+ )
30
+
31
+ # Launch Gradio app
32
+ interface_video_file.launch(debug=True)