m96tkmok commited on
Commit
be4312a
·
verified ·
1 Parent(s): f8d67a0

Update app.py

Browse files

Update ydl_opts by adding cookies

Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -13,7 +13,6 @@ MODEL_NAME = "openai/whisper-large-v3-turbo"
13
  BATCH_SIZE = 8
14
  FILE_LIMIT_MB = 1000
15
  YT_LENGTH_LIMIT_S = 3600 # limit to 1 hour YouTube files
16
- HF_TOKEN = os.environ.get("HF_TOKEN", None)
17
 
18
  device = 0 if torch.cuda.is_available() else "cpu"
19
 
@@ -22,7 +21,6 @@ pipe = pipeline(
22
  model=MODEL_NAME,
23
  chunk_length_s=30,
24
  device=device,
25
- token = HF_TOKEN
26
  )
27
 
28
 
@@ -76,7 +74,10 @@ def download_yt_audio(yt_url, filename):
76
  file_length_hms = time.strftime("%HH:%MM:%SS", time.gmtime(file_length_s))
77
  raise gr.Error(f"Maximum YouTube length is {yt_length_limit_hms}, got {file_length_hms} YouTube video.")
78
 
79
- ydl_opts = {"outtmpl": filename, "format": "worstvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"}
 
 
 
80
 
81
  with youtube_dl.YoutubeDL(ydl_opts) as ydl:
82
  try:
 
13
  BATCH_SIZE = 8
14
  FILE_LIMIT_MB = 1000
15
  YT_LENGTH_LIMIT_S = 3600 # limit to 1 hour YouTube files
 
16
 
17
  device = 0 if torch.cuda.is_available() else "cpu"
18
 
 
21
  model=MODEL_NAME,
22
  chunk_length_s=30,
23
  device=device,
 
24
  )
25
 
26
 
 
74
  file_length_hms = time.strftime("%HH:%MM:%SS", time.gmtime(file_length_s))
75
  raise gr.Error(f"Maximum YouTube length is {yt_length_limit_hms}, got {file_length_hms} YouTube video.")
76
 
77
+ ydl_opts = {"outtmpl": filename,
78
+ "format": "worstvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best",
79
+ "cookies": "cookies-from-browser"
80
+ }
81
 
82
  with youtube_dl.YoutubeDL(ydl_opts) as ydl:
83
  try: