vsrinivas commited on
Commit
46b00b0
1 Parent(s): 644c545

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -11,6 +11,7 @@ import ast
11
  from IPython.display import Audio, display
12
  import requests
13
  nltk.download('punkt_tab')
 
14
 
15
  model = whisper.load_model("base")
16
 
@@ -27,10 +28,12 @@ def extract_yt_audio(it, video_url, video_file):
27
  a = yt.streams.filter(only_audio=True).first()
28
  audio_file = a.download()
29
  sample = AudioSegment.from_file(audio_file, format="mp4")
30
- elif it == 'URL':
31
  response = requests.get(video_url)
32
  video_data = BytesIO(response.content)
33
- sample = AudioSegment.from_file(video_data, format="mp4")
 
 
34
  else:
35
  sample = AudioSegment.from_file(video_file)
36
  audio_path = 'audio.wav'
 
11
  from IPython.display import Audio, display
12
  import requests
13
  nltk.download('punkt_tab')
14
+ from io import BytesIO
15
 
16
  model = whisper.load_model("base")
17
 
 
28
  a = yt.streams.filter(only_audio=True).first()
29
  audio_file = a.download()
30
  sample = AudioSegment.from_file(audio_file, format="mp4")
31
+ elif it == 'URL' and ("https://www" in video_url or "https://" in video_url or "www." in video_url):
32
  response = requests.get(video_url)
33
  video_data = BytesIO(response.content)
34
+ sample = AudioSegment.from_file(video_data, format="mp4")
35
+ elif it == 'URL'
36
+ sample = AudioSegment.from_file(video_url)
37
  else:
38
  sample = AudioSegment.from_file(video_file)
39
  audio_path = 'audio.wav'