Mei000 commited on
Commit
e0dd3a0
1 Parent(s): f0841f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -2,15 +2,21 @@ import gradio as gr
2
  import whisper
3
  from pytube import YouTube
4
 
 
5
 
6
  class GradioInference():
7
  def __init__(self):
8
  self.yt = None
9
-
10
- def __call__(self, link, lang, size, subs):
 
11
  if self.yt is None:
12
- self.yt = YouTube(link)
13
  path = self.yt.streams.filter(only_audio=True)[0].download(filename="tmp.mp4")
 
 
 
 
14
 
15
  def populate_metadata(self, link):
16
  self.yt = YouTube(link)
 
2
  import whisper
3
  from pytube import YouTube
4
 
5
+ pipe = pipeline(model="Mei000/whisper-small-sv-SE")
6
 
7
  class GradioInference():
8
  def __init__(self):
9
  self.yt = None
10
+ self.loaded_model = pipe
11
+
12
+ def __call__(self, link, subs):
13
  if self.yt is None:
14
+ self.yt = YouTube(link)
15
  path = self.yt.streams.filter(only_audio=True)[0].download(filename="tmp.mp4")
16
+ results = self.loaded_model.transcribe(path)
17
+
18
+ if subs == "None":
19
+ return results["text"]
20
 
21
  def populate_metadata(self, link):
22
  self.yt = YouTube(link)