Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,28 +4,31 @@ import os
|
|
4 |
|
5 |
model = whisper.load_model("medium")
|
6 |
|
7 |
-
# main
|
8 |
def main(URL):
|
9 |
video_path = youtube_dl(URL)
|
10 |
text = transcript(video_path)
|
11 |
return text
|
12 |
|
13 |
-
# Whisper
|
14 |
def transcript(video_path):
|
15 |
result = model.transcribe(video_path)
|
16 |
return result["text"]
|
17 |
|
18 |
-
#
|
19 |
def youtube_dl(URL):
|
20 |
-
#
|
21 |
os.system(f"yt-dlp -f best -v {URL} -o target.mp4")
|
22 |
-
#
|
23 |
video_path = os.path.join(os.path.dirname(__file__), "target.mp4")
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
|
26 |
demo = gr.Interface(fn = main,
|
27 |
-
inputs = "text",
|
28 |
-
outputs = "text")
|
29 |
|
30 |
if __name__ == "__main__":
|
31 |
demo.launch()
|
|
|
4 |
|
5 |
model = whisper.load_model("medium")
|
6 |
|
7 |
+
# main processing
|
8 |
def main(URL):
|
9 |
video_path = youtube_dl(URL)
|
10 |
text = transcript(video_path)
|
11 |
return text
|
12 |
|
13 |
+
# Transcribe text using Whisper
|
14 |
def transcript(video_path):
|
15 |
result = model.transcribe(video_path)
|
16 |
return result["text"]
|
17 |
|
18 |
+
# Download the video
|
19 |
def youtube_dl(URL):
|
20 |
+
# Download the video
|
21 |
os.system(f"yt-dlp -f best -v {URL} -o target.mp4")
|
22 |
+
# Path of downloaded video
|
23 |
video_path = os.path.join(os.path.dirname(__file__), "target.mp4")
|
24 |
+
# Check if the video is downloaded successfully
|
25 |
+
if os.path.exists(video_path):
|
26 |
+
return video_path
|
27 |
+
else:
|
28 |
+
raise ValueError("Video download failed")
|
29 |
|
30 |
demo = gr.Interface(fn = main,
|
31 |
+
inputs = "text", outputs = "text")
|
|
|
32 |
|
33 |
if __name__ == "__main__":
|
34 |
demo.launch()
|