Spaces:
Sleeping
Sleeping
harrytarlton commited on
Commit ยท
4170f4a
1
Parent(s): b18b623
Update app.py
Browse files
app.py
CHANGED
|
@@ -594,34 +594,6 @@ body {
|
|
| 594 |
color: #fff !important;
|
| 595 |
user-select: none !important;
|
| 596 |
}
|
| 597 |
-
|
| 598 |
-
/* Import button styling */
|
| 599 |
-
.upload-button {
|
| 600 |
-
width: 100% !important;
|
| 601 |
-
margin-bottom: 10px !important;
|
| 602 |
-
background: linear-gradient(135deg, #4ecdc4 0%, #44a3aa 100%) !important;
|
| 603 |
-
}
|
| 604 |
-
|
| 605 |
-
.upload-button:hover {
|
| 606 |
-
background: linear-gradient(135deg, #44a3aa 0%, #3a8f96 100%) !important;
|
| 607 |
-
}
|
| 608 |
-
|
| 609 |
-
/* File column layout fix */
|
| 610 |
-
.file-column > div {
|
| 611 |
-
display: flex;
|
| 612 |
-
flex-direction: column;
|
| 613 |
-
height: 100%;
|
| 614 |
-
}
|
| 615 |
-
|
| 616 |
-
.file-column .file-panel-container {
|
| 617 |
-
flex: 1 1 auto;
|
| 618 |
-
min-height: 0;
|
| 619 |
-
}
|
| 620 |
-
|
| 621 |
-
.file-column .gr-row:first-child {
|
| 622 |
-
flex: 0 0 auto;
|
| 623 |
-
padding: 10px 10px 0 10px;
|
| 624 |
-
}
|
| 625 |
"""
|
| 626 |
|
| 627 |
# ========== FILE MANAGEMENT JAVASCRIPT ==========
|
|
@@ -728,50 +700,56 @@ function startProcessing() {
|
|
| 728 |
def create_input_file_html(files):
|
| 729 |
"""Create HTML for input files panel"""
|
| 730 |
if not files:
|
| 731 |
-
|
| 732 |
-
<div class='file-panel'>
|
| 733 |
-
<div class='file-panel-header'>
|
| 734 |
-
<span style='font-size: 20px; font-weight: 600;'>Input Files</span>
|
| 735 |
-
</div>
|
| 736 |
-
<div class='file-list' id='input-file-list'>
|
| 737 |
<div style='text-align: center; padding: 40px 20px; color: rgba(255,255,255,0.5);'>
|
| 738 |
<div style='font-size: 48px; opacity: 0.3; margin-bottom: 10px;'>๐</div>
|
| 739 |
<div>No files loaded</div>
|
| 740 |
-
<div style='font-size: 12px; margin-top: 10px;'>
|
| 741 |
</div>
|
| 742 |
-
</div>
|
| 743 |
-
</div>
|
| 744 |
-
<script>inputFiles = [];</script>
|
| 745 |
"""
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
for i, file in enumerate(files):
|
| 751 |
-
file_name = Path(file.name).name
|
| 752 |
-
file_size = os.path.getsize(file.name) / (1024 * 1024) # Convert to MB
|
| 753 |
-
|
| 754 |
-
file_info = {
|
| 755 |
-
'name': file_name,
|
| 756 |
-
'path': file.name,
|
| 757 |
-
'size': f"{file_size:.1f} MB"
|
| 758 |
-
}
|
| 759 |
-
file_data.append(file_info)
|
| 760 |
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 767 |
</div>
|
| 768 |
-
|
| 769 |
-
"""
|
| 770 |
|
| 771 |
return f"""
|
| 772 |
<div class='file-panel'>
|
| 773 |
<div class='file-panel-header'>
|
| 774 |
<span style='font-size: 20px; font-weight: 600;'>Input Files</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 775 |
</div>
|
| 776 |
<div class='file-list' id='input-file-list'>
|
| 777 |
{file_items_html}
|
|
@@ -983,21 +961,19 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
|
| 983 |
with gr.Row():
|
| 984 |
# Left panel - Input files
|
| 985 |
with gr.Column(scale=1, min_width=250, elem_classes="file-column"):
|
| 986 |
-
# Import Audio button at the TOP
|
| 987 |
-
with gr.Row():
|
| 988 |
-
upload_btn = gr.Button(
|
| 989 |
-
"๐ Import Audio",
|
| 990 |
-
elem_classes="upload-button",
|
| 991 |
-
size="sm",
|
| 992 |
-
variant="primary"
|
| 993 |
-
)
|
| 994 |
-
|
| 995 |
# Input files display
|
| 996 |
input_file_panel = gr.HTML(
|
| 997 |
value=create_input_file_html([]),
|
| 998 |
elem_classes="file-panel-container"
|
| 999 |
)
|
| 1000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1001 |
# File upload (hidden)
|
| 1002 |
file_upload = gr.File(
|
| 1003 |
label="Upload Audio Files",
|
|
|
|
| 594 |
color: #fff !important;
|
| 595 |
user-select: none !important;
|
| 596 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
"""
|
| 598 |
|
| 599 |
# ========== FILE MANAGEMENT JAVASCRIPT ==========
|
|
|
|
| 700 |
def create_input_file_html(files):
|
| 701 |
"""Create HTML for input files panel"""
|
| 702 |
if not files:
|
| 703 |
+
file_items_html = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 704 |
<div style='text-align: center; padding: 40px 20px; color: rgba(255,255,255,0.5);'>
|
| 705 |
<div style='font-size: 48px; opacity: 0.3; margin-bottom: 10px;'>๐</div>
|
| 706 |
<div>No files loaded</div>
|
| 707 |
+
<div style='font-size: 12px; margin-top: 10px;'>Import audio files to begin</div>
|
| 708 |
</div>
|
|
|
|
|
|
|
|
|
|
| 709 |
"""
|
| 710 |
+
file_data = []
|
| 711 |
+
else:
|
| 712 |
+
file_items_html = ""
|
| 713 |
+
file_data = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 714 |
|
| 715 |
+
for i, file in enumerate(files):
|
| 716 |
+
file_name = Path(file.name).name
|
| 717 |
+
file_size = os.path.getsize(file.name) / (1024 * 1024) # Convert to MB
|
| 718 |
+
|
| 719 |
+
file_info = {
|
| 720 |
+
'name': file_name,
|
| 721 |
+
'path': file.name,
|
| 722 |
+
'size': f"{file_size:.1f} MB"
|
| 723 |
+
}
|
| 724 |
+
file_data.append(file_info)
|
| 725 |
+
|
| 726 |
+
file_items_html += f"""
|
| 727 |
+
<div class='file-item' id='input-file-{i}' onclick='selectFile("input", {i})'>
|
| 728 |
+
<span style='font-size: 20px;'>๐ต</span>
|
| 729 |
+
<div style='flex: 1;'>
|
| 730 |
+
<div style='font-weight: 500; color: #fff;'>{file_name}</div>
|
| 731 |
+
<div style='font-size: 11px; opacity: 0.7;'>{file_info['size']}</div>
|
| 732 |
+
</div>
|
| 733 |
</div>
|
| 734 |
+
"""
|
|
|
|
| 735 |
|
| 736 |
return f"""
|
| 737 |
<div class='file-panel'>
|
| 738 |
<div class='file-panel-header'>
|
| 739 |
<span style='font-size: 20px; font-weight: 600;'>Input Files</span>
|
| 740 |
+
<div style='margin-left: auto; display: flex; gap: 8px;'>
|
| 741 |
+
<button onclick='document.getElementById("import-btn-trigger").click()' style='
|
| 742 |
+
background: linear-gradient(135deg, #4ecdc4 0%, #44a3aa 100%);
|
| 743 |
+
border: none;
|
| 744 |
+
color: #fff;
|
| 745 |
+
padding: 8px 16px;
|
| 746 |
+
border-radius: 6px;
|
| 747 |
+
cursor: pointer;
|
| 748 |
+
font-weight: 500;
|
| 749 |
+
font-size: 13px;
|
| 750 |
+
min-width: 90px;
|
| 751 |
+
'>Import</button>
|
| 752 |
+
</div>
|
| 753 |
</div>
|
| 754 |
<div class='file-list' id='input-file-list'>
|
| 755 |
{file_items_html}
|
|
|
|
| 961 |
with gr.Row():
|
| 962 |
# Left panel - Input files
|
| 963 |
with gr.Column(scale=1, min_width=250, elem_classes="file-column"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 964 |
# Input files display
|
| 965 |
input_file_panel = gr.HTML(
|
| 966 |
value=create_input_file_html([]),
|
| 967 |
elem_classes="file-panel-container"
|
| 968 |
)
|
| 969 |
|
| 970 |
+
# Hidden upload button (triggered by the Import button in the header)
|
| 971 |
+
upload_btn = gr.Button(
|
| 972 |
+
"Import",
|
| 973 |
+
elem_id="import-btn-trigger",
|
| 974 |
+
visible=False
|
| 975 |
+
)
|
| 976 |
+
|
| 977 |
# File upload (hidden)
|
| 978 |
file_upload = gr.File(
|
| 979 |
label="Upload Audio Files",
|