divython commited on
Commit
d81deed
·
verified ·
1 Parent(s): 7b9821d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -14,6 +14,10 @@ WHISPER_MODEL_SIZE = "base"
14
  # of performance and size for summarization.
15
  SUMMARIZATION_MODEL = "sshleifer/distilbart-cnn-12-6"
16
 
 
 
 
 
17
  # --- Load Models (once at startup) ---
18
  # Load the Whisper ASR model
19
  print(f"Loading Whisper model: {WHISPER_MODEL_SIZE}...")
@@ -49,6 +53,14 @@ def download_and_extract_audio(youtube_url):
49
  'no_warnings': True,
50
  }
51
 
 
 
 
 
 
 
 
 
52
  try:
53
  print(f"Downloading audio for {youtube_url} to {audio_path}...")
54
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
@@ -126,8 +138,11 @@ iface = gr.Interface(
126
  description=(
127
  "Enter a YouTube video URL, and this tool will download its audio, "
128
  "transcribe it using OpenAI Whisper, and then generate a summary/notes."
129
- "Please note: Processing time depends on video length and Hugging Face Space resources."
130
- "For very long videos or complex audio, results may vary or take a long time."
 
 
 
131
  ),
132
  allow_flagging="auto", # Allows users to flag results for review
133
  examples=[
 
14
  # of performance and size for summarization.
15
  SUMMARIZATION_MODEL = "sshleifer/distilbart-cnn-12-6"
16
 
17
+ # Define the path to the cookies file. Make sure you have uploaded 'cookies.txt'
18
+ # to the root directory of your Hugging Face Space.
19
+ COOKIES_FILE_PATH = "cookies.txt"
20
+
21
  # --- Load Models (once at startup) ---
22
  # Load the Whisper ASR model
23
  print(f"Loading Whisper model: {WHISPER_MODEL_SIZE}...")
 
53
  'no_warnings': True,
54
  }
55
 
56
+ # Add cookies if the file exists
57
+ if os.path.exists(COOKIES_FILE_PATH):
58
+ ydl_opts['cookiefile'] = COOKIES_FILE_PATH
59
+ print(f"Using cookies from {COOKIES_FILE_PATH}")
60
+ else:
61
+ print(f"Cookies file not found at {COOKIES_FILE_PATH}. Proceeding without cookies.")
62
+
63
+
64
  try:
65
  print(f"Downloading audio for {youtube_url} to {audio_path}...")
66
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
 
138
  description=(
139
  "Enter a YouTube video URL, and this tool will download its audio, "
140
  "transcribe it using OpenAI Whisper, and then generate a summary/notes."
141
+ "<br><b>Note:</b> If you encounter download issues (e.g., 'Sign in to confirm you’re not a bot'), "
142
+ "ensure you have uploaded a `cookies.txt` file (exported from your browser) to the root of this Hugging Face Space."
143
+ "<br><b>Performance:</b> Analyzing long videos (e.g., 1 hour+) can take a significant amount of time "
144
+ "and consume considerable resources, especially on CPU-only Hugging Face Spaces. "
145
+ "For faster processing of long videos, consider upgrading your Hugging Face Space to a GPU instance."
146
  ),
147
  allow_flagging="auto", # Allows users to flag results for review
148
  examples=[