Spaces:
Running
Running
Update gui.py
Browse files
gui.py
CHANGED
|
@@ -158,7 +158,7 @@ ROFORMER_MODELS = {
|
|
| 158 |
|
| 159 |
OUTPUT_FORMATS = ['wav', 'flac', 'mp3', 'ogg', 'opus', 'm4a', 'aiff', 'ac3']
|
| 160 |
|
| 161 |
-
# CSS
|
| 162 |
CSS = """
|
| 163 |
/* Modern ve Etkileลimli Tema */
|
| 164 |
#app-container {
|
|
@@ -173,7 +173,7 @@ CSS = """
|
|
| 173 |
min-height: 100vh;
|
| 174 |
background: linear-gradient(135deg, #1a0b2e, #2e1a47);
|
| 175 |
position: relative;
|
| 176 |
-
overflow:
|
| 177 |
}
|
| 178 |
body {
|
| 179 |
background: none;
|
|
@@ -229,6 +229,8 @@ body::after {
|
|
| 229 |
box-shadow: 0 5px 20px rgba(255, 107, 107, 0.3);
|
| 230 |
width: 100%;
|
| 231 |
transition: transform 0.3s ease;
|
|
|
|
|
|
|
| 232 |
}
|
| 233 |
.dubbing-theme:hover {
|
| 234 |
transform: translateY(-5px);
|
|
@@ -316,10 +318,47 @@ button:hover {
|
|
| 316 |
color: #e0e0e0 !important;
|
| 317 |
width: 100%;
|
| 318 |
font-size: 1rem !important;
|
| 319 |
-
transition: border-color 0.3s ease !important;
|
|
|
|
|
|
|
| 320 |
}
|
| 321 |
.compact-dropdown:hover {
|
| 322 |
border-color: #ff8787 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
}
|
| 324 |
.gr-slider input[type="range"] {
|
| 325 |
-webkit-appearance: none !important;
|
|
@@ -369,6 +408,9 @@ button:hover {
|
|
| 369 |
.footer {
|
| 370 |
max-width: 100%;
|
| 371 |
}
|
|
|
|
|
|
|
|
|
|
| 372 |
}
|
| 373 |
"""
|
| 374 |
|
|
@@ -382,7 +424,7 @@ def download_audio(url, cookies_file=None, out_dir="ytdl"):
|
|
| 382 |
os.makedirs(out_dir, exist_ok=True)
|
| 383 |
|
| 384 |
ydl_opts = {
|
| 385 |
-
'format': 'bestaudio/best/best',
|
| 386 |
'postprocessors': [{'key': 'FFmpegExtractAudio', 'preferredcodec': 'wav', 'preferredquality': '192'}],
|
| 387 |
'outtmpl': os.path.join(out_dir, '%(title)s.%(ext)s'),
|
| 388 |
'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
|
@@ -391,14 +433,13 @@ def download_audio(url, cookies_file=None, out_dir="ytdl"):
|
|
| 391 |
'referer': 'https://www.youtube.com/',
|
| 392 |
'noplaylist': True,
|
| 393 |
'cookiefile': cookies_file if cookies_file else None,
|
| 394 |
-
'extractor_retries': 5,
|
| 395 |
-
'ignoreerrors': False,
|
| 396 |
'no_check_certificate': True,
|
| 397 |
-
'verbose': True,
|
| 398 |
}
|
| 399 |
try:
|
| 400 |
with YoutubeDL(ydl_opts) as ydl:
|
| 401 |
-
# Log available formats if download fails
|
| 402 |
try:
|
| 403 |
info_dict = ydl.extract_info(url, download=True)
|
| 404 |
return ydl.prepare_filename(info_dict).rsplit('.', 1)[0] + '.wav'
|
|
@@ -530,13 +571,13 @@ def update_roformer_models(category):
|
|
| 530 |
"""Update Roformer model dropdown based on selected category."""
|
| 531 |
choices = list(ROFORMER_MODELS.get(category, {}).keys()) or []
|
| 532 |
logger.debug(f"Updating roformer models for category {category}: {choices}")
|
| 533 |
-
return gr.update(choices=choices)
|
| 534 |
|
| 535 |
def update_ensemble_models(category):
|
| 536 |
"""Update ensemble model dropdown based on selected category."""
|
| 537 |
choices = list(ROFORMER_MODELS.get(category, {}).keys()) or []
|
| 538 |
logger.debug(f"Updating ensemble models for category {category}: {choices}")
|
| 539 |
-
return gr.update(choices=choices)
|
| 540 |
|
| 541 |
def create_interface():
|
| 542 |
"""Create the Gradio interface for music source separation."""
|
|
@@ -568,7 +609,7 @@ def create_interface():
|
|
| 568 |
roformer_exclude_stems = gr.Textbox(label="๐ซ Exclude Stems", placeholder="e.g., vocals, drums (comma-separated)", interactive=True)
|
| 569 |
with gr.Row():
|
| 570 |
roformer_category = gr.Dropdown(label="๐ Category", choices=list(ROFORMER_MODELS.keys()), value="General Purpose", interactive=True)
|
| 571 |
-
roformer_model = gr.Dropdown(label="๐ ๏ธ Model", choices=list(ROFORMER_MODELS["General Purpose"].keys()), interactive=True)
|
| 572 |
with gr.Row():
|
| 573 |
roformer_seg_size = gr.Slider(32, 4000, value=256, step=32, label="๐ Segment Size", interactive=True)
|
| 574 |
roformer_overlap = gr.Slider(2, 10, value=8, step=1, label="๐ Overlap", interactive=True)
|
|
@@ -592,7 +633,7 @@ def create_interface():
|
|
| 592 |
ensemble_exclude_stems = gr.Textbox(label="๐ซ Exclude Stems", placeholder="e.g., vocals, drums (comma-separated)", interactive=True)
|
| 593 |
with gr.Row():
|
| 594 |
ensemble_category = gr.Dropdown(label="๐ Category", choices=list(ROFORMER_MODELS.keys()), value="Instrumentals", interactive=True)
|
| 595 |
-
ensemble_models = gr.Dropdown(label="๐ ๏ธ Models", choices=list(ROFORMER_MODELS["Instrumentals"].keys()), multiselect=True, interactive=True)
|
| 596 |
with gr.Row():
|
| 597 |
ensemble_seg_size = gr.Slider(32, 4000, value=256, step=32, label="๐ Segment Size", interactive=True)
|
| 598 |
ensemble_overlap = gr.Slider(2, 10, value=8, step=1, label="๐ Overlap", interactive=True)
|
|
@@ -623,7 +664,7 @@ def create_interface():
|
|
| 623 |
fn=auto_ensemble_process,
|
| 624 |
inputs=[
|
| 625 |
ensemble_audio, ensemble_models, ensemble_seg_size, ensemble_overlap,
|
| 626 |
-
output_format, ensemble_use_tta,
|
| 627 |
norm_threshold, amp_threshold, batch_size, ensemble_method,
|
| 628 |
ensemble_exclude_stems, ensemble_weights
|
| 629 |
],
|
|
@@ -639,8 +680,7 @@ if __name__ == "__main__":
|
|
| 639 |
|
| 640 |
app = create_interface()
|
| 641 |
try:
|
| 642 |
-
|
| 643 |
-
app.launch(server_name="0.0.0.0", server_port=args.port, share=True)
|
| 644 |
except Exception as e:
|
| 645 |
logger.error(f"Failed to launch app: {e}")
|
| 646 |
raise
|
|
|
|
| 158 |
|
| 159 |
OUTPUT_FORMATS = ['wav', 'flac', 'mp3', 'ogg', 'opus', 'm4a', 'aiff', 'ac3']
|
| 160 |
|
| 161 |
+
# Updated CSS with dropdown fixes
|
| 162 |
CSS = """
|
| 163 |
/* Modern ve Etkileลimli Tema */
|
| 164 |
#app-container {
|
|
|
|
| 173 |
min-height: 100vh;
|
| 174 |
background: linear-gradient(135deg, #1a0b2e, #2e1a47);
|
| 175 |
position: relative;
|
| 176 |
+
overflow: visible; /* Changed from hidden to allow dropdowns */
|
| 177 |
}
|
| 178 |
body {
|
| 179 |
background: none;
|
|
|
|
| 229 |
box-shadow: 0 5px 20px rgba(255, 107, 107, 0.3);
|
| 230 |
width: 100%;
|
| 231 |
transition: transform 0.3s ease;
|
| 232 |
+
position: relative;
|
| 233 |
+
z-index: 10; /* Ensure container is above other elements */
|
| 234 |
}
|
| 235 |
.dubbing-theme:hover {
|
| 236 |
transform: translateY(-5px);
|
|
|
|
| 318 |
color: #e0e0e0 !important;
|
| 319 |
width: 100%;
|
| 320 |
font-size: 1rem !important;
|
| 321 |
+
transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
|
| 322 |
+
position: relative;
|
| 323 |
+
z-index: 100; /* High z-index for dropdown */
|
| 324 |
}
|
| 325 |
.compact-dropdown:hover {
|
| 326 |
border-color: #ff8787 !important;
|
| 327 |
+
box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4) !important;
|
| 328 |
+
}
|
| 329 |
+
.compact-dropdown select, .compact-dropdown .gr-dropdown {
|
| 330 |
+
background: transparent !important;
|
| 331 |
+
color: #e0e0e0 !important;
|
| 332 |
+
border: none !important;
|
| 333 |
+
width: 100% !important;
|
| 334 |
+
padding: 8px !important;
|
| 335 |
+
font-size: 1rem !important;
|
| 336 |
+
appearance: none !important;
|
| 337 |
+
-webkit-appearance: none !important;
|
| 338 |
+
-moz-appearance: none !important;
|
| 339 |
+
}
|
| 340 |
+
.compact-dropdown .gr-dropdown-menu {
|
| 341 |
+
background: rgba(46, 26, 71, 0.95) !important;
|
| 342 |
+
border: 2px solid #ff6b6b !important;
|
| 343 |
+
border-radius: 8px !important;
|
| 344 |
+
color: #e0e0e0 !important;
|
| 345 |
+
max-height: 300px !important; /* Increased for more options */
|
| 346 |
+
overflow-y: auto !important;
|
| 347 |
+
z-index: 200 !important; /* Ensure menu is above other elements */
|
| 348 |
+
width: 100% !important;
|
| 349 |
+
opacity: 1 !important; /* Always visible */
|
| 350 |
+
visibility: visible !important;
|
| 351 |
+
position: absolute !important;
|
| 352 |
+
top: 100% !important;
|
| 353 |
+
left: 0 !important;
|
| 354 |
+
}
|
| 355 |
+
.compact-dropdown .gr-dropdown-menu option {
|
| 356 |
+
padding: 8px !important;
|
| 357 |
+
color: #e0e0e0 !important;
|
| 358 |
+
background: transparent !important;
|
| 359 |
+
}
|
| 360 |
+
.compact-dropdown .gr-dropdown-menu option:hover {
|
| 361 |
+
background: rgba(255, 107, 107, 0.3) !important;
|
| 362 |
}
|
| 363 |
.gr-slider input[type="range"] {
|
| 364 |
-webkit-appearance: none !important;
|
|
|
|
| 408 |
.footer {
|
| 409 |
max-width: 100%;
|
| 410 |
}
|
| 411 |
+
.compact-dropdown .gr-dropdown-menu {
|
| 412 |
+
max-height: 200px !important; /* Smaller for mobile */
|
| 413 |
+
}
|
| 414 |
}
|
| 415 |
"""
|
| 416 |
|
|
|
|
| 424 |
os.makedirs(out_dir, exist_ok=True)
|
| 425 |
|
| 426 |
ydl_opts = {
|
| 427 |
+
'format': 'bestaudio/best/best',
|
| 428 |
'postprocessors': [{'key': 'FFmpegExtractAudio', 'preferredcodec': 'wav', 'preferredquality': '192'}],
|
| 429 |
'outtmpl': os.path.join(out_dir, '%(title)s.%(ext)s'),
|
| 430 |
'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
|
|
|
| 433 |
'referer': 'https://www.youtube.com/',
|
| 434 |
'noplaylist': True,
|
| 435 |
'cookiefile': cookies_file if cookies_file else None,
|
| 436 |
+
'extractor_retries': 5,
|
| 437 |
+
'ignoreerrors': False,
|
| 438 |
'no_check_certificate': True,
|
| 439 |
+
'verbose': True,
|
| 440 |
}
|
| 441 |
try:
|
| 442 |
with YoutubeDL(ydl_opts) as ydl:
|
|
|
|
| 443 |
try:
|
| 444 |
info_dict = ydl.extract_info(url, download=True)
|
| 445 |
return ydl.prepare_filename(info_dict).rsplit('.', 1)[0] + '.wav'
|
|
|
|
| 571 |
"""Update Roformer model dropdown based on selected category."""
|
| 572 |
choices = list(ROFORMER_MODELS.get(category, {}).keys()) or []
|
| 573 |
logger.debug(f"Updating roformer models for category {category}: {choices}")
|
| 574 |
+
return gr.update(choices=choices, value=choices[0] if choices else None)
|
| 575 |
|
| 576 |
def update_ensemble_models(category):
|
| 577 |
"""Update ensemble model dropdown based on selected category."""
|
| 578 |
choices = list(ROFORMER_MODELS.get(category, {}).keys()) or []
|
| 579 |
logger.debug(f"Updating ensemble models for category {category}: {choices}")
|
| 580 |
+
return gr.update(choices=choices, value=[])
|
| 581 |
|
| 582 |
def create_interface():
|
| 583 |
"""Create the Gradio interface for music source separation."""
|
|
|
|
| 609 |
roformer_exclude_stems = gr.Textbox(label="๐ซ Exclude Stems", placeholder="e.g., vocals, drums (comma-separated)", interactive=True)
|
| 610 |
with gr.Row():
|
| 611 |
roformer_category = gr.Dropdown(label="๐ Category", choices=list(ROFORMER_MODELS.keys()), value="General Purpose", interactive=True)
|
| 612 |
+
roformer_model = gr.Dropdown(label="๐ ๏ธ Model", choices=list(ROFORMER_MODELS["General Purpose"].keys()), interactive=True, allow_custom_value=True, elem_classes="compact-dropdown")
|
| 613 |
with gr.Row():
|
| 614 |
roformer_seg_size = gr.Slider(32, 4000, value=256, step=32, label="๐ Segment Size", interactive=True)
|
| 615 |
roformer_overlap = gr.Slider(2, 10, value=8, step=1, label="๐ Overlap", interactive=True)
|
|
|
|
| 633 |
ensemble_exclude_stems = gr.Textbox(label="๐ซ Exclude Stems", placeholder="e.g., vocals, drums (comma-separated)", interactive=True)
|
| 634 |
with gr.Row():
|
| 635 |
ensemble_category = gr.Dropdown(label="๐ Category", choices=list(ROFORMER_MODELS.keys()), value="Instrumentals", interactive=True)
|
| 636 |
+
ensemble_models = gr.Dropdown(label="๐ ๏ธ Models", choices=list(ROFORMER_MODELS["Instrumentals"].keys()), multiselect=True, interactive=True, allow_custom_value=True, elem_classes="compact-dropdown")
|
| 637 |
with gr.Row():
|
| 638 |
ensemble_seg_size = gr.Slider(32, 4000, value=256, step=32, label="๐ Segment Size", interactive=True)
|
| 639 |
ensemble_overlap = gr.Slider(2, 10, value=8, step=1, label="๐ Overlap", interactive=True)
|
|
|
|
| 664 |
fn=auto_ensemble_process,
|
| 665 |
inputs=[
|
| 666 |
ensemble_audio, ensemble_models, ensemble_seg_size, ensemble_overlap,
|
| 667 |
+
output_format, ensemble_use_tta, model_dir, output_dir,
|
| 668 |
norm_threshold, amp_threshold, batch_size, ensemble_method,
|
| 669 |
ensemble_exclude_stems, ensemble_weights
|
| 670 |
],
|
|
|
|
| 680 |
|
| 681 |
app = create_interface()
|
| 682 |
try:
|
| 683 |
+
app.launch(server_name="0.0.0.0", server_port=args.port, share=False)
|
|
|
|
| 684 |
except Exception as e:
|
| 685 |
logger.error(f"Failed to launch app: {e}")
|
| 686 |
raise
|