Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -329,6 +329,7 @@ button:hover {
|
|
| 329 |
|
| 330 |
import os
|
| 331 |
import yt_dlp
|
|
|
|
| 332 |
from scipy.io import wavfile
|
| 333 |
|
| 334 |
def download_audio(url, cookie_file=None):
|
|
@@ -355,6 +356,9 @@ 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 |
# 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}'
|
|
@@ -370,6 +374,9 @@ def download_audio(url, cookie_file=None):
|
|
| 370 |
|
| 371 |
# Handle YouTube link
|
| 372 |
else:
|
|
|
|
|
|
|
|
|
|
| 373 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 374 |
try:
|
| 375 |
info_dict = ydl.extract_info(url, download=True)
|
|
@@ -389,7 +396,7 @@ def download_audio(url, cookie_file=None):
|
|
| 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)):
|
|
|
|
| 329 |
|
| 330 |
import os
|
| 331 |
import yt_dlp
|
| 332 |
+
import gdown
|
| 333 |
from scipy.io import wavfile
|
| 334 |
|
| 335 |
def download_audio(url, cookie_file=None):
|
|
|
|
| 356 |
# Check if it's a Google Drive link
|
| 357 |
if 'drive.google.com' in url or 'https://drive.google.com' in url:
|
| 358 |
try:
|
| 359 |
+
# Create the 'ytdl' directory if it doesn't exist
|
| 360 |
+
os.makedirs('ytdl', exist_ok=True)
|
| 361 |
+
|
| 362 |
# Extract file ID from the URL
|
| 363 |
file_id = url.split('/d/')[1].split('/')[0]
|
| 364 |
download_url = f'https://drive.google.com/uc?id={file_id}'
|
|
|
|
| 374 |
|
| 375 |
# Handle YouTube link
|
| 376 |
else:
|
| 377 |
+
# Create the 'ytdl' directory for YouTube downloads as well
|
| 378 |
+
os.makedirs('ytdl', exist_ok=True)
|
| 379 |
+
|
| 380 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 381 |
try:
|
| 382 |
info_dict = ydl.extract_info(url, download=True)
|
|
|
|
| 396 |
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
|
| 397 |
return None, f"Download failed: {str(e)}", None
|
| 398 |
except Exception as e:
|
| 399 |
+
return None, f"Unexpected error: {str(e)}", None
|
| 400 |
|
| 401 |
@spaces.GPU
|
| 402 |
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)):
|