File size: 1,124 Bytes
eacd553
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
import os
from translator import translation  # Assuming your translation class is in a translator.py file

def app(video_path, original_language, target_language):
    # Move to the working directory
    os.chdir('/workspace')  # Adjust path based on Hugging Face's working directory

    # Use the Gradio-provided path to the uploaded file
    video_name = os.path.basename(video_path.name)

    # Instantiate the translation class with video and language information
    translator = translation(video_name, original_language, target_language)

    # Translate the video and return the output file path
    video_file = translator.translate_video()

    return video_file

# Gradio interface setup
interface_video_file = gr.Interface(
    fn=app,
    inputs=[
        gr.Video(label="Upload a Video"),
        gr.Dropdown(["English", "German", "French", "Spanish"], label="Original Language"),
        gr.Dropdown(["English", "German", "French", "Spanish"], label="Target Language"),
    ],
    outputs=gr.Video(label="Translated Video")
)

# Launch Gradio app
interface_video_file.launch(debug=True)