Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,12 @@ import gradio as gr
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import torch
|
| 5 |
import ffmpeg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# --- Model Loading ---
|
| 8 |
# We load the model once when the app starts, not on every function call.
|
|
@@ -121,7 +127,8 @@ def translate_local(text_to_translate, target_lang='ta-IN', device=None):
|
|
| 121 |
def main_run(video_path):
|
| 122 |
original_audio_file = extract_audio_from_video(video_path)
|
| 123 |
original_text = transcribe_audio(original_audio_file)
|
| 124 |
-
|
|
|
|
| 125 |
|
| 126 |
# --- Gradio Interface Definition ---
|
| 127 |
# Title and description for the new Space
|
|
@@ -141,7 +148,7 @@ app_interface = gr.Interface(
|
|
| 141 |
inputs=gr.Video(
|
| 142 |
label="Upload Video"
|
| 143 |
),
|
| 144 |
-
outputs=gr.Textbox(label="
|
| 145 |
title=title,
|
| 146 |
description=description,
|
| 147 |
article=article,
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import torch
|
| 5 |
import ffmpeg
|
| 6 |
+
import nltk
|
| 7 |
+
import re
|
| 8 |
+
from deep_translator import MyMemoryTranslator
|
| 9 |
+
|
| 10 |
+
# You only need to run this download command once
|
| 11 |
+
nltk.download('punkt')
|
| 12 |
|
| 13 |
# --- Model Loading ---
|
| 14 |
# We load the model once when the app starts, not on every function call.
|
|
|
|
| 127 |
def main_run(video_path):
|
| 128 |
original_audio_file = extract_audio_from_video(video_path)
|
| 129 |
original_text = transcribe_audio(original_audio_file)
|
| 130 |
+
translated_text = translate_local(original_text)
|
| 131 |
+
return translated_text
|
| 132 |
|
| 133 |
# --- Gradio Interface Definition ---
|
| 134 |
# Title and description for the new Space
|
|
|
|
| 148 |
inputs=gr.Video(
|
| 149 |
label="Upload Video"
|
| 150 |
),
|
| 151 |
+
outputs=gr.Textbox(label="Translation Result"),
|
| 152 |
title=title,
|
| 153 |
description=description,
|
| 154 |
article=article,
|