SteveDigital
commited on
Commit
•
9817c7c
1
Parent(s):
2186d57
Update app.py
Browse files
app.py
CHANGED
@@ -8,17 +8,17 @@ import re
|
|
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 ""
|
@@ -27,7 +27,8 @@ def get_audio(url):
|
|
27 |
|
28 |
def get_text(url):
|
29 |
#try:
|
30 |
-
if url != ''
|
|
|
31 |
|
32 |
yt = YouTube(url)
|
33 |
if yt.length < 5400:
|
@@ -43,7 +44,7 @@ def get_text(url):
|
|
43 |
else:
|
44 |
return "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. Please visit https://steve.digital to contact me about this space."
|
45 |
#finally:
|
46 |
-
|
47 |
|
48 |
def get_summary(article):
|
49 |
#try:
|
@@ -51,8 +52,8 @@ def get_summary(article):
|
|
51 |
b = summarizer(first_sentences, min_length = 20, max_length = 120, do_sample = False)
|
52 |
b = b[0]['summary_text'].replace(' .', '.').strip()
|
53 |
return b
|
54 |
-
#finally:
|
55 |
-
|
56 |
|
57 |
|
58 |
with gr.Blocks() as demo:
|
|
|
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 ""
|
|
|
27 |
|
28 |
def get_text(url):
|
29 |
#try:
|
30 |
+
if url != '':
|
31 |
+
output_text_transcribe = ''
|
32 |
|
33 |
yt = YouTube(url)
|
34 |
if yt.length < 5400:
|
|
|
44 |
else:
|
45 |
return "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. Please visit https://steve.digital to contact me about this space."
|
46 |
#finally:
|
47 |
+
#raise gr.Error("Exception: There was a problem transcribing the audio after successfully retrieving it from the video/URL.")
|
48 |
|
49 |
def get_summary(article):
|
50 |
#try:
|
|
|
52 |
b = summarizer(first_sentences, min_length = 20, max_length = 120, do_sample = False)
|
53 |
b = b[0]['summary_text'].replace(' .', '.').strip()
|
54 |
return b
|
55 |
+
#finally:
|
56 |
+
#raise gr.Error("Exception: There was a problem summarizing the transcript.")
|
57 |
|
58 |
|
59 |
with gr.Blocks() as demo:
|