Spaces:
Running
Running
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) | |