ASesYusuf1 commited on
Commit
390f3f3
·
verified ·
1 Parent(s): 47427b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -355,8 +355,11 @@ def download_audio(url, cookie_file=None):
355
  # Check if it's a Google Drive link
356
  if 'drive.google.com' in url or 'https://drive.google.com' in url:
357
  try:
 
 
 
358
  output_path = 'ytdl/gdrive_audio.wav'
359
- gdown.download(url, output_path, quiet=False)
360
  if not os.path.exists(output_path):
361
  return None, "Downloaded file not found", None
362
  sample_rate, data = wavfile.read(output_path)
@@ -364,7 +367,7 @@ def download_audio(url, cookie_file=None):
364
  return output_path, "Download successful", audio_data
365
  except Exception as e:
366
  return None, f"Google Drive download failed: {str(e)}", None
367
-
368
  # Handle YouTube link
369
  else:
370
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
@@ -386,7 +389,7 @@ def download_audio(url, cookie_file=None):
386
  return None, "Download failed: HTTP Error 403. This format requires a GVS PO Token, or the cookies are invalid. Please upload fresh cookies. See https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide for advanced troubleshooting.", None
387
  return None, f"Download failed: {str(e)}", None
388
  except Exception as e:
389
- return None, f"Unexpected error: {str(e)}", None
390
 
391
  @spaces.GPU
392
  def roformer_separator(audio, model_key, seg_size, override_seg_size, overlap, pitch_shift, model_dir, output_dir, out_format, norm_thresh, amp_thresh, batch_size, exclude_stems="", progress=gr.Progress(track_tqdm=True)):
 
355
  # Check if it's a Google Drive link
356
  if 'drive.google.com' in url or 'https://drive.google.com' in url:
357
  try:
358
+ # Extract file ID from the URL
359
+ file_id = url.split('/d/')[1].split('/')[0]
360
+ download_url = f'https://drive.google.com/uc?id={file_id}'
361
  output_path = 'ytdl/gdrive_audio.wav'
362
+ gdown.download(download_url, output_path, quiet=False)
363
  if not os.path.exists(output_path):
364
  return None, "Downloaded file not found", None
365
  sample_rate, data = wavfile.read(output_path)
 
367
  return output_path, "Download successful", audio_data
368
  except Exception as e:
369
  return None, f"Google Drive download failed: {str(e)}", None
370
+
371
  # Handle YouTube link
372
  else:
373
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
 
389
  return None, "Download failed: HTTP Error 403. This format requires a GVS PO Token, or the cookies are invalid. Please upload fresh cookies. See https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide for advanced troubleshooting.", None
390
  return None, f"Download failed: {str(e)}", None
391
  except Exception as e:
392
+ return None, f"Unexpected error: {str(e)}", None
393
 
394
  @spaces.GPU
395
  def roformer_separator(audio, model_key, seg_size, override_seg_size, overlap, pitch_shift, model_dir, output_dir, out_format, norm_thresh, amp_thresh, batch_size, exclude_stems="", progress=gr.Progress(track_tqdm=True)):