SteveDigital
commited on
Commit
•
3a36dd7
1
Parent(s):
fe55d4b
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,9 @@ model = whisper.load_model("large")
|
|
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)
|
@@ -19,28 +19,28 @@ def get_audio(url):
|
|
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:
|
30 |
if url != '' : output_text_transcribe = ''
|
31 |
result = model.transcribe(get_audio(url))
|
32 |
return result['text'].strip()
|
33 |
-
finally:
|
34 |
-
raise gr.Error("Exception: There was a problem transcribing the audio after successfully retrieving it from the video/URL.")
|
35 |
|
36 |
def get_summary(article):
|
37 |
-
try:
|
38 |
first_sentences = ' '.join(re.split(r'(?<=[.:;])\s', article)[:5])
|
39 |
b = summarizer(first_sentences, min_length = 20, max_length = 120, do_sample = False)
|
40 |
b = b[0]['summary_text'].replace(' .', '.').strip()
|
41 |
return b
|
42 |
-
finally:
|
43 |
-
raise gr.Error("Exception: There was a problem summarizing the transcript.")
|
44 |
|
45 |
|
46 |
with gr.Blocks() as demo:
|
|
|
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)
|
|
|
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:
|
30 |
if url != '' : output_text_transcribe = ''
|
31 |
result = model.transcribe(get_audio(url))
|
32 |
return result['text'].strip()
|
33 |
+
#finally:
|
34 |
+
#raise gr.Error("Exception: There was a problem transcribing the audio after successfully retrieving it from the video/URL.")
|
35 |
|
36 |
def get_summary(article):
|
37 |
+
#try:
|
38 |
first_sentences = ' '.join(re.split(r'(?<=[.:;])\s', article)[:5])
|
39 |
b = summarizer(first_sentences, min_length = 20, max_length = 120, do_sample = False)
|
40 |
b = b[0]['summary_text'].replace(' .', '.').strip()
|
41 |
return b
|
42 |
+
#finally:
|
43 |
+
#raise gr.Error("Exception: There was a problem summarizing the transcript.")
|
44 |
|
45 |
|
46 |
with gr.Blocks() as demo:
|