vsrinivas commited on
Commit
06cc19b
1 Parent(s): 0add541

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -12,6 +12,7 @@ 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
 
@@ -31,7 +32,12 @@ def extract_yt_audio(it, video_url, video_file):
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:
 
12
  import requests
13
  nltk.download('punkt_tab')
14
  from io import BytesIO
15
+ import ffmpeg
16
 
17
  model = whisper.load_model("base")
18
 
 
32
  elif it == 'URL' and ("https://www" in video_url or "https://" in video_url or "www." in video_url):
33
  response = requests.get(video_url)
34
  video_data = BytesIO(response.content)
35
+ output_stream = io.BytesIO()
36
+ stream = ffmpeg.input('pipe:0')
37
+ stream = ffmpeg.output(stream, 'pipe:1', format='wav')
38
+ ffmpeg.run(stream, input=input_stream.read(), stdout=output_stream)
39
+ output_stream.seek(0)
40
+ sample = AudioSegment.from_file(output_stream, format="mp4")
41
  elif it == 'URL':
42
  sample = AudioSegment.from_file(video_url)
43
  else: