Spaces:
Sleeping
Sleeping
younes21000
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -178,13 +178,11 @@ def write_ppt(transcription, output_file, tokenizer=None, translation_model=None
|
|
178 |
ppt.save(output_file)
|
179 |
|
180 |
# Transcribing video and generating output
|
181 |
-
def transcribe_video(video_file,
|
182 |
-
if
|
183 |
-
video_file_path = download_youtube_video(video_url)
|
184 |
-
elif video_file is not None: # Ensure the video_file is not None
|
185 |
video_file_path = video_file.name
|
186 |
else:
|
187 |
-
raise ValueError("No video file provided. Please upload a video file
|
188 |
|
189 |
result = model.transcribe(video_file_path, language=language)
|
190 |
video_name = os.path.splitext(video_file_path)[0]
|
@@ -222,22 +220,20 @@ def transcribe_video(video_file, video_url, language, target_language, output_fo
|
|
222 |
return ppt_file
|
223 |
|
224 |
|
225 |
-
# Gradio interface
|
226 |
iface = gr.Interface(
|
227 |
fn=transcribe_video,
|
228 |
inputs=[
|
229 |
-
gr.File(label="Upload Video File
|
230 |
-
gr.Textbox(label="YouTube Video URL (optional)", placeholder="https://www.youtube.com/watch?v=..."),
|
231 |
gr.Dropdown(label="Select Original Video Language", choices=["en", "es", "fr", "de", "it", "pt"], value="en"),
|
232 |
gr.Dropdown(label="Select Subtitle Translation Language", choices=["en", "fa", "es", "de", "fr", "it", "pt"], value="fa"),
|
233 |
gr.Radio(label="Choose Output Format", choices=["SRT", "Video with Hardsub", "Word", "PDF", "PowerPoint"], value="Video with Hardsub")
|
234 |
],
|
235 |
outputs=gr.File(label="Download File"),
|
236 |
-
title="Video Subtitle Generator with Translation & Multi-Format Output
|
237 |
description=(
|
238 |
-
"This tool allows you to generate subtitles from a video file
|
239 |
-
"
|
240 |
-
"in various formats including SRT, hardcoded subtitles in video, Word, PDF, or PowerPoint."
|
241 |
),
|
242 |
theme="compact",
|
243 |
live=False
|
@@ -245,4 +241,3 @@ iface = gr.Interface(
|
|
245 |
|
246 |
if __name__ == "__main__":
|
247 |
iface.launch()
|
248 |
-
|
|
|
178 |
ppt.save(output_file)
|
179 |
|
180 |
# Transcribing video and generating output
|
181 |
+
def transcribe_video(video_file, language, target_language, output_format):
|
182 |
+
if video_file is not None: # Ensure the video_file is not None
|
|
|
|
|
183 |
video_file_path = video_file.name
|
184 |
else:
|
185 |
+
raise ValueError("No video file provided. Please upload a video file.")
|
186 |
|
187 |
result = model.transcribe(video_file_path, language=language)
|
188 |
video_name = os.path.splitext(video_file_path)[0]
|
|
|
220 |
return ppt_file
|
221 |
|
222 |
|
223 |
+
# Gradio interface without YouTube URL
|
224 |
iface = gr.Interface(
|
225 |
fn=transcribe_video,
|
226 |
inputs=[
|
227 |
+
gr.File(label="Upload Video File"),
|
|
|
228 |
gr.Dropdown(label="Select Original Video Language", choices=["en", "es", "fr", "de", "it", "pt"], value="en"),
|
229 |
gr.Dropdown(label="Select Subtitle Translation Language", choices=["en", "fa", "es", "de", "fr", "it", "pt"], value="fa"),
|
230 |
gr.Radio(label="Choose Output Format", choices=["SRT", "Video with Hardsub", "Word", "PDF", "PowerPoint"], value="Video with Hardsub")
|
231 |
],
|
232 |
outputs=gr.File(label="Download File"),
|
233 |
+
title="Video Subtitle Generator with Translation & Multi-Format Output",
|
234 |
description=(
|
235 |
+
"This tool allows you to generate subtitles from a video file, translate the subtitles into multiple languages using M2M100, "
|
236 |
+
"and export them in various formats including SRT, hardcoded subtitles in video, Word, PDF, or PowerPoint."
|
|
|
237 |
),
|
238 |
theme="compact",
|
239 |
live=False
|
|
|
241 |
|
242 |
if __name__ == "__main__":
|
243 |
iface.launch()
|
|