trhacknon commited on
Commit
decfec9
·
1 Parent(s): 973d93d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -1,29 +1,29 @@
1
  import whisper
2
  from pytube import YouTube
3
- #from transformers import pipeline
4
  import gradio as gr
5
  import os
6
  import re
7
 
8
  model = whisper.load_model("base")
9
- #summarizer = pipeline("summarization")
10
 
11
- #def get_audio(url):
12
- #try:
13
- #yt = YouTube(url)
14
- #if yt.length < 5400:
15
- #video = yt.streams.filter(only_audio=True).first()
16
- #out_file=video.download(output_path=".")
17
- #base, ext = os.path.splitext(out_file)
18
- #new_file = base+'.mp3'
19
- #os.rename(out_file, new_file)
20
- #a = new_file
21
- #return a
22
- #else:
23
- #raise gr.Error("Videos for transcription on this space are limited to 1.5 hours. Sorry about this limit but some joker thought they could stop this tool from working by transcribing many extremely long videos.")
24
- #return ""
25
- #finally:
26
- #raise gr.Error("Exception: There was a problem getting the video or audio of the URL provided.")
27
 
28
  def get_text(url):
29
  #try:
 
1
  import whisper
2
  from pytube import YouTube
3
+ from transformers import pipeline
4
  import gradio as gr
5
  import os
6
  import re
7
 
8
  model = whisper.load_model("base")
9
+ summarizer = pipeline("summarization")
10
 
11
+ def get_audio(url):
12
+ try:
13
+ yt = YouTube(url)
14
+ if yt.length < 5400:
15
+ video = yt.streams.filter(only_audio=True).first()
16
+ out_file=video.download(output_path=".")
17
+ base, ext = os.path.splitext(out_file)
18
+ new_file = base+'.mp3'
19
+ os.rename(out_file, new_file)
20
+ a = new_file
21
+ return a
22
+ else:
23
+ raise gr.Error("Videos for transcription on this space are limited to 1.5 hours. Sorry about this limit but some joker thought they could stop this tool from working by transcribing many extremely long videos.")
24
+ return ""
25
+ finally:
26
+ raise gr.Error("Exception: There was a problem getting the video or audio of the URL provided.")
27
 
28
  def get_text(url):
29
  #try: