mlkorra commited on
Commit
6ec5436
·
1 Parent(s): 83f94aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -7,6 +7,7 @@ from pytube import YouTube
7
  import os
8
  import sys
9
  import subprocess
 
10
 
11
  loaded_model = whisper.load_model("base")
12
  current_size = 'base'
@@ -14,17 +15,20 @@ current_size = 'base'
14
  def download_video(link):
15
 
16
  yt = YouTube(link)
 
 
17
 
18
- return yt.streams.filter(file_extension='mp4')[0].download(filename='video.mp4')
19
 
20
  def inference(link):
21
 
22
  yt = YouTube(link)
23
-
24
- audio_path = yt.streams.filter(only_audio=True)[0].download(filename="audio.mp4")
 
25
  print(f'audio path : {audio_path}')
26
  video_path = download_video(link)
27
-
28
  #video_path = yt.streams.filter(file_extension='mp4')[0].download(filename='video.mp4'
29
 
30
  options = dict(beam_size=5, best_of=5, fp16 = False)
@@ -86,7 +90,7 @@ with block:
86
 
87
  input_video = gr.Video()
88
  output_video = gr.Video()
89
-
90
  btn = gr.Button("Generate Captions")
91
 
92
  # Events
 
7
  import os
8
  import sys
9
  import subprocess
10
+ import re
11
 
12
  loaded_model = whisper.load_model("base")
13
  current_size = 'base'
 
15
  def download_video(link):
16
 
17
  yt = YouTube(link)
18
+ vid = yt.thumbnail_url.split('vi/')[1].split('/')[0]
19
+ print(vid)
20
 
21
+ return yt.streams.filter(file_extension='mp4')[0].download(filename=f"{vid}.mp4")
22
 
23
  def inference(link):
24
 
25
  yt = YouTube(link)
26
+ vid = yt.thumbnail_url.split('vi/')[1].split('/')[0]
27
+
28
+ audio_path = yt.streams.filter(only_audio=True)[0].download(filename= f"{vid}.mp3")
29
  print(f'audio path : {audio_path}')
30
  video_path = download_video(link)
31
+
32
  #video_path = yt.streams.filter(file_extension='mp4')[0].download(filename='video.mp4'
33
 
34
  options = dict(beam_size=5, best_of=5, fp16 = False)
 
90
 
91
  input_video = gr.Video()
92
  output_video = gr.Video()
93
+
94
  btn = gr.Button("Generate Captions")
95
 
96
  # Events