Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -769,8 +769,145 @@ def load_example_audio(example_name):
|
|
| 769 |
# Return the path to the example audio file based on the example_name
|
| 770 |
return None
|
| 771 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 772 |
# Create the Gradio interface with proper output handling
|
| 773 |
-
with gr.Blocks(title="Affective Virtual Environments - Chunked Processing") as interface:
|
| 774 |
gr.Markdown("# Affective Virtual Environments")
|
| 775 |
gr.Markdown("Create an AVE using your voice. Audio is split into chunks, with separate predictions and generations for each segment.")
|
| 776 |
|
|
@@ -847,12 +984,70 @@ with gr.Blocks(title="Affective Virtual Environments - Chunked Processing") as i
|
|
| 847 |
'music': audio_output
|
| 848 |
})
|
| 849 |
|
| 850 |
-
#
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 856 |
|
| 857 |
# Add a hidden HTML component for JavaScript execution
|
| 858 |
js_output = gr.HTML(visible=False)
|
|
@@ -905,5 +1100,4 @@ with gr.Blocks(title="Affective Virtual Environments - Chunked Processing") as i
|
|
| 905 |
is_spaces = os.getenv('SPACE_ID') is not None
|
| 906 |
|
| 907 |
# Launch with appropriate settings
|
| 908 |
-
interface.launch(share=True) # Only share when not on Spaces
|
| 909 |
-
|
|
|
|
| 769 |
# Return the path to the example audio file based on the example_name
|
| 770 |
return None
|
| 771 |
|
| 772 |
+
# Custom CSS for enhanced styling
|
| 773 |
+
custom_css = """
|
| 774 |
+
.download-section {
|
| 775 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 776 |
+
padding: 25px;
|
| 777 |
+
border-radius: 15px;
|
| 778 |
+
border: 3px solid #764ba2;
|
| 779 |
+
text-align: center;
|
| 780 |
+
margin: 25px 0;
|
| 781 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.15);
|
| 782 |
+
position: relative;
|
| 783 |
+
overflow: hidden;
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
.download-section::before {
|
| 787 |
+
content: "";
|
| 788 |
+
position: absolute;
|
| 789 |
+
top: -50%;
|
| 790 |
+
left: -50%;
|
| 791 |
+
width: 200%;
|
| 792 |
+
height: 200%;
|
| 793 |
+
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
|
| 794 |
+
animation: shimmer 3s infinite linear;
|
| 795 |
+
pointer-events: none;
|
| 796 |
+
}
|
| 797 |
+
|
| 798 |
+
@keyframes shimmer {
|
| 799 |
+
0% { transform: rotate(0deg); }
|
| 800 |
+
100% { transform: rotate(360deg); }
|
| 801 |
+
}
|
| 802 |
+
|
| 803 |
+
.download-section h2 {
|
| 804 |
+
color: white;
|
| 805 |
+
font-size: 24px;
|
| 806 |
+
margin-bottom: 15px;
|
| 807 |
+
text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
.download-section p {
|
| 811 |
+
color: rgba(255,255,255,0.9);
|
| 812 |
+
font-size: 16px;
|
| 813 |
+
margin-bottom: 20px;
|
| 814 |
+
line-height: 1.5;
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
.download-button {
|
| 818 |
+
background: linear-gradient(45deg, #ff7e5f, #feb47b) !important;
|
| 819 |
+
color: white !important;
|
| 820 |
+
border: none !important;
|
| 821 |
+
padding: 12px 30px !important;
|
| 822 |
+
border-radius: 50px !important;
|
| 823 |
+
font-weight: bold !important;
|
| 824 |
+
font-size: 16px !important;
|
| 825 |
+
margin-top: 15px !important;
|
| 826 |
+
transition: all 0.3s ease !important;
|
| 827 |
+
box-shadow: 0 5px 15px rgba(255,126,95,0.4) !important;
|
| 828 |
+
cursor: pointer !important;
|
| 829 |
+
display: inline-block !important;
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
.download-button:hover {
|
| 833 |
+
transform: translateY(-3px) !important;
|
| 834 |
+
box-shadow: 0 8px 20px rgba(255,126,95,0.6) !important;
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
.download-button:active {
|
| 838 |
+
transform: translateY(1px) !important;
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
.download-icon {
|
| 842 |
+
margin-right: 8px;
|
| 843 |
+
font-size: 18px;
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
+
.feature-list {
|
| 847 |
+
display: flex;
|
| 848 |
+
justify-content: center;
|
| 849 |
+
flex-wrap: wrap;
|
| 850 |
+
gap: 15px;
|
| 851 |
+
margin: 20px 0;
|
| 852 |
+
}
|
| 853 |
+
|
| 854 |
+
.feature-item {
|
| 855 |
+
background: rgba(255,255,255,0.15);
|
| 856 |
+
padding: 10px 15px;
|
| 857 |
+
border-radius: 8px;
|
| 858 |
+
display: flex;
|
| 859 |
+
align-items: center;
|
| 860 |
+
gap: 8px;
|
| 861 |
+
color: white;
|
| 862 |
+
font-size: 14px;
|
| 863 |
+
}
|
| 864 |
+
|
| 865 |
+
.feature-icon {
|
| 866 |
+
font-size: 16px;
|
| 867 |
+
}
|
| 868 |
+
|
| 869 |
+
.viewer-preview {
|
| 870 |
+
margin-top: 20px;
|
| 871 |
+
border-radius: 10px;
|
| 872 |
+
overflow: hidden;
|
| 873 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
| 874 |
+
max-width: 400px;
|
| 875 |
+
margin-left: auto;
|
| 876 |
+
margin-right: auto;
|
| 877 |
+
}
|
| 878 |
+
|
| 879 |
+
.viewer-preview img {
|
| 880 |
+
width: 100%;
|
| 881 |
+
display: block;
|
| 882 |
+
}
|
| 883 |
+
|
| 884 |
+
.instructions {
|
| 885 |
+
background: rgba(255,255,255,0.1);
|
| 886 |
+
padding: 15px;
|
| 887 |
+
border-radius: 8px;
|
| 888 |
+
margin-top: 20px;
|
| 889 |
+
text-align: left;
|
| 890 |
+
}
|
| 891 |
+
|
| 892 |
+
.instructions h3 {
|
| 893 |
+
color: white;
|
| 894 |
+
margin-top: 0;
|
| 895 |
+
font-size: 16px;
|
| 896 |
+
}
|
| 897 |
+
|
| 898 |
+
.instructions ol {
|
| 899 |
+
color: rgba(255,255,255,0.9);
|
| 900 |
+
padding-left: 20px;
|
| 901 |
+
margin-bottom: 0;
|
| 902 |
+
}
|
| 903 |
+
|
| 904 |
+
.instructions li {
|
| 905 |
+
margin-bottom: 8px;
|
| 906 |
+
}
|
| 907 |
+
"""
|
| 908 |
+
|
| 909 |
# Create the Gradio interface with proper output handling
|
| 910 |
+
with gr.Blocks(title="Affective Virtual Environments - Chunked Processing", css=custom_css) as interface:
|
| 911 |
gr.Markdown("# Affective Virtual Environments")
|
| 912 |
gr.Markdown("Create an AVE using your voice. Audio is split into chunks, with separate predictions and generations for each segment.")
|
| 913 |
|
|
|
|
| 984 |
'music': audio_output
|
| 985 |
})
|
| 986 |
|
| 987 |
+
# Enhanced Download 360 Viewer Section
|
| 988 |
+
with gr.Group(visible=True, elem_classes="download-section") as download_group:
|
| 989 |
+
gr.Markdown("""
|
| 990 |
+
# π Immersive 360 Experience Ready! π
|
| 991 |
+
|
| 992 |
+
Your personalized virtual environment has been generated. Download the interactive 360Β° viewer to explore your creation!
|
| 993 |
+
""")
|
| 994 |
+
|
| 995 |
+
with gr.Row():
|
| 996 |
+
with gr.Column():
|
| 997 |
+
gr.Markdown("""
|
| 998 |
+
### π― Features:
|
| 999 |
+
""")
|
| 1000 |
+
|
| 1001 |
+
with gr.Row(elem_classes="feature-list"):
|
| 1002 |
+
with gr.Column(scale=1, min_width=150):
|
| 1003 |
+
gr.Markdown("""
|
| 1004 |
+
<div class="feature-item">
|
| 1005 |
+
<span class="feature-icon">π</span> 360Β° Panoramic View
|
| 1006 |
+
</div>
|
| 1007 |
+
""")
|
| 1008 |
+
|
| 1009 |
+
with gr.Column(scale=1, min_width=150):
|
| 1010 |
+
gr.Markdown("""
|
| 1011 |
+
<div class="feature-item">
|
| 1012 |
+
<span class="feature-icon">π΅</span> Synchronized Audio
|
| 1013 |
+
</div>
|
| 1014 |
+
""")
|
| 1015 |
+
|
| 1016 |
+
with gr.Column(scale=1, min_width=150):
|
| 1017 |
+
gr.Markdown("""
|
| 1018 |
+
<div class="feature-item">
|
| 1019 |
+
<span class="feature-icon">π</span> Interactive Navigation
|
| 1020 |
+
</div>
|
| 1021 |
+
""")
|
| 1022 |
+
|
| 1023 |
+
gr.Markdown("""
|
| 1024 |
+
<div class="instructions">
|
| 1025 |
+
<h3>π How to use:</h3>
|
| 1026 |
+
<ol>
|
| 1027 |
+
<li>Download the HTML file using the button below</li>
|
| 1028 |
+
<li>Open the file in your web browser (Chrome, Firefox, Edge)</li>
|
| 1029 |
+
<li>Use your mouse to drag and explore the 360Β° environment</li>
|
| 1030 |
+
<li>Switch between different chunks using the dropdown menu</li>
|
| 1031 |
+
<li>Enjoy the synchronized audio experience!</li>
|
| 1032 |
+
</ol>
|
| 1033 |
+
</div>
|
| 1034 |
+
""")
|
| 1035 |
+
|
| 1036 |
+
with gr.Column(scale=1, min_width=300):
|
| 1037 |
+
# Preview image (placeholder - you could add a function to generate a preview)
|
| 1038 |
+
gr.Markdown("""
|
| 1039 |
+
<div class="viewer-preview">
|
| 1040 |
+
<img src="https://img.freepik.com/free-vector/abstract-360-degree-panorama-virtual-reality-background_1048-14629.jpg" alt="360 Viewer Preview">
|
| 1041 |
+
</div>
|
| 1042 |
+
""")
|
| 1043 |
+
|
| 1044 |
+
# Enhanced download button
|
| 1045 |
+
viewer_html_output = gr.File(
|
| 1046 |
+
label="π Download Immersive 360 Viewer π",
|
| 1047 |
+
type="filepath",
|
| 1048 |
+
interactive=False,
|
| 1049 |
+
elem_classes="download-button"
|
| 1050 |
+
)
|
| 1051 |
|
| 1052 |
# Add a hidden HTML component for JavaScript execution
|
| 1053 |
js_output = gr.HTML(visible=False)
|
|
|
|
| 1100 |
is_spaces = os.getenv('SPACE_ID') is not None
|
| 1101 |
|
| 1102 |
# Launch with appropriate settings
|
| 1103 |
+
interface.launch(share=True) # Only share when not on Spaces
|
|
|