SteveDigital commited on
Commit
2186d57
1 Parent(s): a63bdf7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -28,8 +28,20 @@ def get_audio(url):
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
 
 
28
  def get_text(url):
29
  #try:
30
  if url != '' : output_text_transcribe = ''
31
+
32
+ yt = YouTube(url)
33
+ if yt.length < 5400:
34
+ video = yt.streams.filter(only_audio=True).first()
35
+ out_file=video.download(output_path=".")
36
+ base, ext = os.path.splitext(out_file)
37
+ new_file = base+'.mp3'
38
+ os.rename(out_file, new_file)
39
+ a = new_file
40
+
41
+ result = model.transcribe(a)
42
+ return result['text'].strip()
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
  #raise gr.Error("Exception: There was a problem transcribing the audio after successfully retrieving it from the video/URL.")
47