Akseluhr commited on
Commit
c804b71
1 Parent(s): bde7a90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -1,18 +1,18 @@
1
  from transformers import pipeline
2
  import gradio as gr
 
3
 
4
  pipe = pipeline(model="Akseluhr/whisper-small-sv-SE-auhr-v2")
5
 
6
  def get_audio(url):
7
- print(url)
8
  yt = YouTube(url)
9
  video = yt.streams.filter(only_audio=True).first()
10
  out_file=video.download(output_path=".")
11
  base, ext = os.path.splitext(out_file)
12
  new_file = base+'.mp3'
13
  os.rename(out_file, new_file)
14
- a = new_file
15
- return a
16
 
17
  def get_text(url):
18
  result = model.transcribe(get_audio(url))
@@ -24,7 +24,6 @@ def transcribe(rec=None, file=None, url=None):
24
  elif file is not None:
25
  audio = file
26
  elif url is not None:
27
- print(url)
28
  audio = get_audio(url)
29
  else:
30
  return "Provide a recording or a file."
 
1
  from transformers import pipeline
2
  import gradio as gr
3
+ from pytube import YouTube
4
 
5
  pipe = pipeline(model="Akseluhr/whisper-small-sv-SE-auhr-v2")
6
 
7
  def get_audio(url):
 
8
  yt = YouTube(url)
9
  video = yt.streams.filter(only_audio=True).first()
10
  out_file=video.download(output_path=".")
11
  base, ext = os.path.splitext(out_file)
12
  new_file = base+'.mp3'
13
  os.rename(out_file, new_file)
14
+ audio_file = new_file
15
+ return audio_file
16
 
17
  def get_text(url):
18
  result = model.transcribe(get_audio(url))
 
24
  elif file is not None:
25
  audio = file
26
  elif url is not None:
 
27
  audio = get_audio(url)
28
  else:
29
  return "Provide a recording or a file."