SteveDigital
commited on
Commit
•
9ec122f
1
Parent(s):
98e3642
Update app.py
Browse files
app.py
CHANGED
@@ -9,27 +9,27 @@ logging.basicConfig(level=logging.INFO)
|
|
9 |
model = whisper.load_model("base")
|
10 |
|
11 |
def get_text(url):
|
12 |
-
try:
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
finally:
|
32 |
-
|
33 |
|
34 |
def get_summary(article):
|
35 |
#try:
|
|
|
9 |
model = whisper.load_model("base")
|
10 |
|
11 |
def get_text(url):
|
12 |
+
#try:
|
13 |
+
if url != '':
|
14 |
+
output_text_transcribe = ''
|
15 |
+
|
16 |
+
yt = YouTube(url)
|
17 |
+
#video_length = yt.length
|
18 |
+
#if video_length < 5400:
|
19 |
+
video = yt.streams.filter(only_audio=True).first()
|
20 |
+
out_file=video.download(output_path=".")
|
21 |
+
base, ext = os.path.splitext(out_file)
|
22 |
+
new_file = base+'.mp3'
|
23 |
+
os.rename(out_file, new_file)
|
24 |
+
a = new_file
|
25 |
+
|
26 |
+
logging.info("Size of audio file: %s", str(len(a)))
|
27 |
+
result = model.transcribe(a)
|
28 |
+
return result['text'].strip()
|
29 |
+
#else:
|
30 |
+
# 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."
|
31 |
+
#finally:
|
32 |
+
# raise gr.Error("Exception: There was a problem transcribing the audio.")
|
33 |
|
34 |
def get_summary(article):
|
35 |
#try:
|