DavidCombei commited on
Commit
8d20888
·
verified ·
1 Parent(s): ceaa1bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -39,7 +39,26 @@ model3 = joblib.load('model3_ensemble.pkl')
39
  model4 = joblib.load('model4_ensemble.pkl')
40
  final_model = joblib.load('final_model_ensemble.pkl')
41
 
42
- def download_audio_from_youtube(youtube_url, output_path='.'):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  ydl_opts = {
44
  'format': 'bestaudio/best',
45
  'outtmpl': f'{output_path}/%(title)s.%(ext)s',
@@ -52,9 +71,12 @@ def download_audio_from_youtube(youtube_url, output_path='.'):
52
  'prefer_ffmpeg': True,
53
  }
54
 
 
 
 
55
  with youtube_dl.YoutubeDL(ydl_opts) as ydl:
56
  info_dict = ydl.extract_info(youtube_url, download=True)
57
- #i have issues with the .webm extension, force replace with .wav
58
  audio_file = ydl.prepare_filename(info_dict).replace('.webm', '.wav')
59
  return audio_file
60
 
 
39
  model4 = joblib.load('model4_ensemble.pkl')
40
  final_model = joblib.load('final_model_ensemble.pkl')
41
 
42
+ # def download_audio_from_youtube(youtube_url, output_path='.'):
43
+ # ydl_opts = {
44
+ # 'format': 'bestaudio/best',
45
+ # 'outtmpl': f'{output_path}/%(title)s.%(ext)s',
46
+ # 'postprocessors': [{
47
+ # 'key': 'FFmpegExtractAudio',
48
+ # 'preferredcodec': 'wav',
49
+ # 'preferredquality': '192',
50
+ # }],
51
+ # 'postprocessor_args': ['-ar', '16000'],
52
+ # 'prefer_ffmpeg': True,
53
+ # }
54
+
55
+ # with youtube_dl.YoutubeDL(ydl_opts) as ydl:
56
+ # info_dict = ydl.extract_info(youtube_url, download=True)
57
+ # #i have issues with the .webm extension, force replace with .wav
58
+ # audio_file = ydl.prepare_filename(info_dict).replace('.webm', '.wav')
59
+ # return audio_file
60
+
61
+ def download_audio_from_youtube(youtube_url, output_path='.', cookies_file='cookies.txt'):
62
  ydl_opts = {
63
  'format': 'bestaudio/best',
64
  'outtmpl': f'{output_path}/%(title)s.%(ext)s',
 
71
  'prefer_ffmpeg': True,
72
  }
73
 
74
+ if cookies_file:
75
+ ydl_opts['cookiefile'] = cookies_file
76
+
77
  with youtube_dl.YoutubeDL(ydl_opts) as ydl:
78
  info_dict = ydl.extract_info(youtube_url, download=True)
79
+ # Force replace with .wav
80
  audio_file = ydl.prepare_filename(info_dict).replace('.webm', '.wav')
81
  return audio_file
82