Spaces:
Running
on
Zero
Running
on
Zero
fix: resolve problem with the url sign up
Browse files- __pycache__/inference.cpython-310.pyc +0 -0
- __pycache__/utils.cpython-310.pyc +0 -0
- app.py +76 -33
- cookies.txt +24 -0
- models/bs_roformer/__pycache__/__init__.cpython-311.pyc +0 -0
- models/bs_roformer/__pycache__/attend.cpython-311.pyc +0 -0
- models/bs_roformer/__pycache__/bs_roformer.cpython-311.pyc +0 -0
- models/bs_roformer/__pycache__/mel_band_roformer.cpython-311.pyc +0 -0
- models/scnet/__pycache__/__init__.cpython-311.pyc +0 -0
- models/scnet/__pycache__/scnet.cpython-311.pyc +0 -0
- models/scnet/__pycache__/separation.cpython-311.pyc +0 -0
- requirements.txt +2 -1
__pycache__/inference.cpython-310.pyc
CHANGED
Binary files a/__pycache__/inference.cpython-310.pyc and b/__pycache__/inference.cpython-310.pyc differ
|
|
__pycache__/utils.cpython-310.pyc
CHANGED
Binary files a/__pycache__/utils.cpython-310.pyc and b/__pycache__/utils.cpython-310.pyc differ
|
|
app.py
CHANGED
@@ -12,8 +12,6 @@ from pathlib import Path
|
|
12 |
import spaces
|
13 |
from pydub.exceptions import CouldntEncodeError
|
14 |
from transformers import pipeline
|
15 |
-
import requests
|
16 |
-
from bs4 import BeautifulSoup
|
17 |
|
18 |
# Initialize text generation model
|
19 |
model = pipeline('text-generation', model='EleutherAI/gpt-neo-125M')
|
@@ -23,6 +21,28 @@ OUTPUT_FOLDER = "separation_results/"
|
|
23 |
INPUT_FOLDER = "input"
|
24 |
download_path = ""
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
def sanitize_filename(filename):
|
27 |
"""
|
28 |
Remove special characters from filename to ensure it's valid across different file systems.
|
@@ -92,10 +112,27 @@ def standardize_title(input_title):
|
|
92 |
|
93 |
return standardized_output.strip()
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
def download_youtube_audio(youtube_url: str, output_dir: str = './download', delete_existing: bool = True, simulate: bool = False) -> str:
|
96 |
"""
|
97 |
Downloads audio from a YouTube URL and saves it as an MP3 file with specified yt-dlp options.
|
98 |
-
|
99 |
Args:
|
100 |
youtube_url (str): URL of the YouTube video.
|
101 |
output_dir (str): Directory to save the downloaded audio file.
|
@@ -108,40 +145,40 @@ def download_youtube_audio(youtube_url: str, output_dir: str = './download', del
|
|
108 |
if not os.path.exists(output_dir):
|
109 |
os.makedirs(output_dir)
|
110 |
|
111 |
-
|
112 |
-
soup = BeautifulSoup(r.text)
|
113 |
|
114 |
-
link = soup.find_all(name="title")[0]
|
115 |
-
title = str(link)
|
116 |
-
title = title.replace("<title>","")
|
117 |
-
title = title.replace("</title>","")
|
118 |
-
|
119 |
audio_file = os.path.join(output_dir, title)
|
120 |
|
121 |
# Remove existing file if requested
|
122 |
if delete_existing and os.path.exists(audio_file + '.mp3'):
|
123 |
os.remove(audio_file + '.mp3')
|
124 |
-
|
125 |
-
# Prepare yt-dlp
|
126 |
-
|
127 |
-
'
|
128 |
-
'
|
129 |
-
'
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
if simulate:
|
133 |
-
|
134 |
|
135 |
-
#
|
136 |
-
|
|
|
|
|
|
|
137 |
|
138 |
-
for line in iter(process.stdout.readline, ''):
|
139 |
-
print(line, end='') # Print download progress
|
140 |
-
|
141 |
-
process.stdout.close()
|
142 |
-
process.wait()
|
143 |
-
|
144 |
-
return audio_file + '.mp3'
|
145 |
|
146 |
|
147 |
def handle_file_upload(file):
|
@@ -149,7 +186,7 @@ def handle_file_upload(file):
|
|
149 |
Handle file upload, standardize the filename, change extension to .wav, and copy it to the input folder.
|
150 |
|
151 |
Args:
|
152 |
-
file: Uploaded file object
|
153 |
|
154 |
Returns:
|
155 |
tuple: (input_path, formatted_title) or (None, error_message)
|
@@ -157,9 +194,15 @@ def handle_file_upload(file):
|
|
157 |
if file is None:
|
158 |
return None, "No file uploaded"
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
formatted_title = standardize_title(os.path.splitext(filename)[0]) # Removing extension
|
164 |
formatted_title = sanitize_filename(formatted_title.strip())
|
165 |
|
@@ -168,7 +211,7 @@ def handle_file_upload(file):
|
|
168 |
os.makedirs(os.path.dirname(input_path), exist_ok=True)
|
169 |
|
170 |
# Convert the input file to .wav if it's not already
|
171 |
-
audio = AudioSegment.from_file(
|
172 |
audio.export(input_path, format="wav")
|
173 |
|
174 |
return input_path, formatted_title
|
|
|
12 |
import spaces
|
13 |
from pydub.exceptions import CouldntEncodeError
|
14 |
from transformers import pipeline
|
|
|
|
|
15 |
|
16 |
# Initialize text generation model
|
17 |
model = pipeline('text-generation', model='EleutherAI/gpt-neo-125M')
|
|
|
21 |
INPUT_FOLDER = "input"
|
22 |
download_path = ""
|
23 |
|
24 |
+
class MyLogger:
|
25 |
+
def debug(self, msg):
|
26 |
+
# For compatibility with youtube-dl, both debug and info are passed into debug
|
27 |
+
if msg.startswith('[debug] '):
|
28 |
+
pass
|
29 |
+
else:
|
30 |
+
self.info(msg)
|
31 |
+
|
32 |
+
def info(self, msg):
|
33 |
+
pass
|
34 |
+
|
35 |
+
def warning(self, msg):
|
36 |
+
pass
|
37 |
+
|
38 |
+
def error(self, msg):
|
39 |
+
print(msg)
|
40 |
+
|
41 |
+
def my_hook(d):
|
42 |
+
if d['status'] == 'finished':
|
43 |
+
print('Done downloading, now post-processing ...')
|
44 |
+
|
45 |
+
|
46 |
def sanitize_filename(filename):
|
47 |
"""
|
48 |
Remove special characters from filename to ensure it's valid across different file systems.
|
|
|
112 |
|
113 |
return standardized_output.strip()
|
114 |
|
115 |
+
def get_video_title(video_url):
|
116 |
+
ydl_opts = {
|
117 |
+
'logger': MyLogger(),
|
118 |
+
'progress_hooks': [my_hook],
|
119 |
+
'cookiefile': 'cookies.txt',
|
120 |
+
'quiet': True, # Suppress output
|
121 |
+
}
|
122 |
+
|
123 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
124 |
+
# Extract video info using the provided URL
|
125 |
+
video_info = ydl.extract_info(video_url, download=False)
|
126 |
+
|
127 |
+
# Get the video title
|
128 |
+
video_title = video_info['title'] # Get the video title
|
129 |
+
|
130 |
+
return video_title
|
131 |
+
|
132 |
def download_youtube_audio(youtube_url: str, output_dir: str = './download', delete_existing: bool = True, simulate: bool = False) -> str:
|
133 |
"""
|
134 |
Downloads audio from a YouTube URL and saves it as an MP3 file with specified yt-dlp options.
|
135 |
+
|
136 |
Args:
|
137 |
youtube_url (str): URL of the YouTube video.
|
138 |
output_dir (str): Directory to save the downloaded audio file.
|
|
|
145 |
if not os.path.exists(output_dir):
|
146 |
os.makedirs(output_dir)
|
147 |
|
148 |
+
title = get_video_title(youtube_url)
|
|
|
149 |
|
|
|
|
|
|
|
|
|
|
|
150 |
audio_file = os.path.join(output_dir, title)
|
151 |
|
152 |
# Remove existing file if requested
|
153 |
if delete_existing and os.path.exists(audio_file + '.mp3'):
|
154 |
os.remove(audio_file + '.mp3')
|
155 |
+
|
156 |
+
# Prepare yt-dlp options
|
157 |
+
ydl_opts = {
|
158 |
+
'logger': MyLogger(),
|
159 |
+
'progress_hooks': [my_hook],
|
160 |
+
'format': 'bestaudio',
|
161 |
+
'outtmpl': audio_file,
|
162 |
+
'postprocessors': [{
|
163 |
+
'key': 'FFmpegExtractAudio',
|
164 |
+
'preferredcodec': 'wav',
|
165 |
+
}],
|
166 |
+
'extractor_retries': 10,
|
167 |
+
'force_overwrites': True,
|
168 |
+
'cookiefile': 'cookies.txt',
|
169 |
+
'verbose': True,
|
170 |
+
}
|
171 |
+
|
172 |
+
|
173 |
if simulate:
|
174 |
+
ydl_opts['simulate'] = True
|
175 |
|
176 |
+
# Download the audio using yt-dlp
|
177 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
178 |
+
ydl.download([youtube_url])
|
179 |
+
|
180 |
+
return audio_file + '.wav'
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
|
184 |
def handle_file_upload(file):
|
|
|
186 |
Handle file upload, standardize the filename, change extension to .wav, and copy it to the input folder.
|
187 |
|
188 |
Args:
|
189 |
+
file: Uploaded file object or file path string
|
190 |
|
191 |
Returns:
|
192 |
tuple: (input_path, formatted_title) or (None, error_message)
|
|
|
194 |
if file is None:
|
195 |
return None, "No file uploaded"
|
196 |
|
197 |
+
# Check if 'file' is an instance of a file object or a string
|
198 |
+
if isinstance(file, str):
|
199 |
+
filename = os.path.basename(file) # If it's a string, use it directly
|
200 |
+
file_path = file # The string itself is the file path
|
201 |
+
else:
|
202 |
+
filename = os.path.basename(file.name) # If it's a file object
|
203 |
+
file_path = file.name
|
204 |
+
|
205 |
+
|
206 |
formatted_title = standardize_title(os.path.splitext(filename)[0]) # Removing extension
|
207 |
formatted_title = sanitize_filename(formatted_title.strip())
|
208 |
|
|
|
211 |
os.makedirs(os.path.dirname(input_path), exist_ok=True)
|
212 |
|
213 |
# Convert the input file to .wav if it's not already
|
214 |
+
audio = AudioSegment.from_file(file_path)
|
215 |
audio.export(input_path, format="wav")
|
216 |
|
217 |
return input_path, formatted_title
|
cookies.txt
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Netscape HTTP Cookie File
|
2 |
+
# http://curl.haxx.se/rfc/cookie_spec.html
|
3 |
+
# This is a generated file! Do not edit.
|
4 |
+
|
5 |
+
.youtube.com TRUE / TRUE 0 YSC 7nJSJzFobwo
|
6 |
+
.youtube.com TRUE / TRUE 1761392077 __Secure-YEC Cgtpckt1M25BSHZ1NCiF9s-3BjIiCgJGUhIcEhgSFhMLFBUWFwwYGRobHB0eHw4PIBAREiEgVA%3D%3D
|
7 |
+
.youtube.com TRUE / TRUE 1764879120 PREF f4=4000000&f6=40000000&tz=Europe.Paris&f5=20000&f7=100
|
8 |
+
.youtube.com TRUE / FALSE 1764876802 HSID AuFfOOSaK_BDmLYBM
|
9 |
+
.youtube.com TRUE / TRUE 1764876802 SSID AJufaIAV7L5xI7IZG
|
10 |
+
.youtube.com TRUE / FALSE 1764876802 APISID -K6RGlr9VwFUMBl9/AtYYpBGnmMzDFOfFb
|
11 |
+
.youtube.com TRUE / TRUE 1764876802 SAPISID -eI2tTs085wmtRwX/AuP4Ex_mjgNsvPdhz
|
12 |
+
.youtube.com TRUE / TRUE 1764876802 __Secure-1PAPISID -eI2tTs085wmtRwX/AuP4Ex_mjgNsvPdhz
|
13 |
+
.youtube.com TRUE / TRUE 1764876802 __Secure-3PAPISID -eI2tTs085wmtRwX/AuP4Ex_mjgNsvPdhz
|
14 |
+
.youtube.com TRUE / TRUE 1764876802 LOGIN_INFO AFmmF2swRgIhAMj8ifOeygBSr75_78gkYO4MBYuQGOatR6JgShhq7OqbAiEAmTb0D_nGF2knbj5BhNbrFAXldPZpofmO-C_233c-OEs:QUQ3MjNmeE9ES0pjT3R6TGtZaERHOGhQamZFX1JkZzB2cUE3VmVPV0kzTmk3QVZQNTE4T3ozMG5XZXpxMm1qd3RscS1zdk92b0t1LU96dnV3X3Y5MGN5dnBRV28weXcyV1hsRGEyX1A4RWkza1ZzVkhyc0h3VkxILVBhZjJDSnB6YWt2czNFcVFkUE1OQlRoY20zNnlmdE1LOHF2ckROSHd3
|
15 |
+
.youtube.com TRUE / FALSE 1764876802 SID g.a000pghKW7HghO8DASpX11UdgeavxJzTkvkX0EEb_Tq3dG4M01z8F6EqmjMaxmCKBnVVeubZIgACgYKAYkSARESFQHGX2Mi89Z1jk1Q6ttIiCfGTAwemBoVAUF8yKqtk2by-PRBc4le2Q-T9djF0076
|
16 |
+
.youtube.com TRUE / TRUE 1764876802 __Secure-1PSID g.a000pghKW7HghO8DASpX11UdgeavxJzTkvkX0EEb_Tq3dG4M01z8m-E1zyyDeV7mbmGrJECBLQACgYKAXUSARESFQHGX2MictGrh1xU6oa65-Th4ABj7BoVAUF8yKpJ6cGV1gdUs0WqSCOL2uYY0076
|
17 |
+
.youtube.com TRUE / TRUE 1764876802 __Secure-3PSID g.a000pghKW7HghO8DASpX11UdgeavxJzTkvkX0EEb_Tq3dG4M01z8jr2VQE5yWKqnaouJW3XchQACgYKAYwSARESFQHGX2MiNzYWKdfei_hqLUOJWdWY1BoVAUF8yKr3WvYxsYfDW6msQqi4arWF0076
|
18 |
+
.youtube.com TRUE / TRUE 1745870521 VISITOR_PRIVACY_METADATA CgJGUhIcEhgSFhMLFBUWFwwYGRobHB0eHw4PIBAREiEgNw%3D%3D
|
19 |
+
.youtube.com TRUE / TRUE 1746128009 NID 518=amrdfkufp86-FwA22dILcalS8OtzR48UdrK9cx5CqoZUwpYhd5G2lt8pY2qqQ4_6Ommx_y1gmjVKaOijgoStqmyhXD7rEbhwpUHtIndYZ713pnBaCaPDWmyNBYNeta6zOJtv6uLYCPzK_fA0UjpNGJHXqTErGZjRYIOtZN9c68FDxwWz3EBwyUn3Gsnkfwq7kHSgC3QNLGUSjY24ndwEnnaM8opinQ0d9pWcMbkZCrpZ2e9W4mnOdK_E29WqcKz7czlZ738WFwspYW-s1e62TvaUbsm3G9R1K7BG4Q
|
20 |
+
.youtube.com TRUE / TRUE 1761856347 __Secure-1PSIDTS sidts-CjIBQT4rX_Sn5aNOtmawkPePf_mf7nCRzOSq5E1N9Eaf54yS2LqlA4UOrs21BRUtT9Dp5RAA
|
21 |
+
.youtube.com TRUE / TRUE 1761856347 __Secure-3PSIDTS sidts-CjIBQT4rX_Sn5aNOtmawkPePf_mf7nCRzOSq5E1N9Eaf54yS2LqlA4UOrs21BRUtT9Dp5RAA
|
22 |
+
.youtube.com TRUE / FALSE 1761856599 SIDCC AKEyXzVGGEoO2_ENgIKoZV9xMDuS02kb8VvffhPnD59YMriuUHwYUmkMtBxr5nR9euTg4mQEJNA
|
23 |
+
.youtube.com TRUE / TRUE 1761856599 __Secure-1PSIDCC AKEyXzV8MMEEcTezw9GXyXnSlODcrGes3gNcmMZRTEUUQMRWQ1TRTCA2H6Fs7lfuBF6yELgQJz0
|
24 |
+
.youtube.com TRUE / TRUE 1761856599 __Secure-3PSIDCC AKEyXzWkWpktP9VxK07V1AvAm6XODApfSbB1OT3WYrQ0nCvcghfdXzhIZyoHgYrvJswicG_3gg
|
models/bs_roformer/__pycache__/__init__.cpython-311.pyc
DELETED
Binary file (347 Bytes)
|
|
models/bs_roformer/__pycache__/attend.cpython-311.pyc
DELETED
Binary file (6.14 kB)
|
|
models/bs_roformer/__pycache__/bs_roformer.cpython-311.pyc
DELETED
Binary file (25.4 kB)
|
|
models/bs_roformer/__pycache__/mel_band_roformer.cpython-311.pyc
DELETED
Binary file (26.9 kB)
|
|
models/scnet/__pycache__/__init__.cpython-311.pyc
DELETED
Binary file (219 Bytes)
|
|
models/scnet/__pycache__/scnet.cpython-311.pyc
DELETED
Binary file (20.7 kB)
|
|
models/scnet/__pycache__/separation.cpython-311.pyc
DELETED
Binary file (8.43 kB)
|
|
requirements.txt
CHANGED
@@ -34,4 +34,5 @@ gradio
|
|
34 |
transformers
|
35 |
datasets
|
36 |
accelerate
|
37 |
-
spaces
|
|
|
|
34 |
transformers
|
35 |
datasets
|
36 |
accelerate
|
37 |
+
spaces
|
38 |
+
bitsandbytes
|