abdullah637 commited on
Commit
8ca66cd
·
verified ·
1 Parent(s): 3c5a675

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,10 +1,10 @@
1
- import whisper
2
- model = whisper.load_model("base")
3
-
4
  import gradio as gr
5
  from moviepy.editor import VideoFileClip
6
  import os
7
 
 
 
 
8
  def generate_subtitles(video_path):
9
  # Extract audio from video
10
  video = VideoFileClip(video_path)
@@ -41,4 +41,22 @@ def generate_subtitles(video_path):
41
  with open(srt_filename, "w", encoding="utf-8") as srt_file:
42
  srt_file.write(srt_content)
43
 
44
- return srt_content, srt_filename
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from moviepy.editor import VideoFileClip
3
  import os
4
 
5
+ import whisper
6
+ model = whisper.load_model("base")
7
+
8
  def generate_subtitles(video_path):
9
  # Extract audio from video
10
  video = VideoFileClip(video_path)
 
41
  with open(srt_filename, "w", encoding="utf-8") as srt_file:
42
  srt_file.write(srt_content)
43
 
44
+ return srt_content, srt_filename
45
+
46
+
47
+ def video_to_subtitles(video):
48
+ subtitles, srt_filename = generate_subtitles(video)
49
+ return subtitles, srt_filename # Just return the file path directly
50
+
51
+ iface = gr.Interface(
52
+ fn=video_to_subtitles,
53
+ inputs=gr.Video(label="Upload Video"),
54
+ outputs=[
55
+ gr.Textbox(label="Subtitles", lines=10),
56
+ gr.DownloadButton(label="Download .srt File") # No file_name needed
57
+ ],
58
+ title="Video to Subtitles",
59
+ description="Upload a video to generate subtitles using Whisper AI and download the .srt file."
60
+ )
61
+
62
+ iface.launch(share=True)