Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,6 @@ import soundfile as sf
|
|
| 22 |
from pydub import AudioSegment
|
| 23 |
import math
|
| 24 |
import json
|
| 25 |
-
import time
|
| 26 |
|
| 27 |
# Load the emotion prediction model
|
| 28 |
def load_emotion_model(model_path):
|
|
@@ -405,18 +404,13 @@ with gr.Blocks(title="Affective Virtual Environments - Chunked Processing") as i
|
|
| 405 |
process_btn = gr.Button("Process Audio", variant="primary")
|
| 406 |
clear_btn = gr.Button("Clear All", variant="secondary")
|
| 407 |
|
| 408 |
-
# Add a loading indicator
|
| 409 |
loading_indicator = gr.HTML("""
|
| 410 |
<div id="loading" style="display: none; text-align: center; margin: 20px;">
|
| 411 |
<p style="font-size: 18px; color: #4a4a4a;">Processing audio chunks...</p>
|
| 412 |
<div style="border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 2s linear infinite; margin: 0 auto;"></div>
|
|
|
|
| 413 |
</div>
|
| 414 |
-
<style>
|
| 415 |
-
@keyframes spin {
|
| 416 |
-
0% { transform: rotate(0deg); }
|
| 417 |
-
100% { transform: rotate(360deg); }
|
| 418 |
-
}
|
| 419 |
-
</style>
|
| 420 |
""")
|
| 421 |
|
| 422 |
# Create output components for each chunk type
|
|
@@ -450,19 +444,14 @@ with gr.Blocks(title="Affective Virtual Environments - Chunked Processing") as i
|
|
| 450 |
if chunk_duration is None or chunk_duration <= 0:
|
| 451 |
chunk_duration = 10
|
| 452 |
|
| 453 |
-
# Show loading indicator
|
| 454 |
-
yield [gr.HTML("""
|
| 455 |
<div style="text-align: center; margin: 20px;">
|
| 456 |
-
<p style="font-size: 18px; color: #4a4a4a;">Processing audio in {}-second chunks...</p>
|
| 457 |
<div style="border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 2s linear infinite; margin: 0 auto;"></div>
|
|
|
|
| 458 |
</div>
|
| 459 |
-
|
| 460 |
-
@keyframes spin {
|
| 461 |
-
0% { transform: rotate(0deg); }
|
| 462 |
-
100% { transform: rotate(360deg); }
|
| 463 |
-
}
|
| 464 |
-
</style>
|
| 465 |
-
""".format(chunk_duration))] + [gr.Group(visible=False)] * len(group_components) + [None] * (len(output_containers) * 5)
|
| 466 |
|
| 467 |
results = get_predictions(audio_input, generate_audio, chunk_duration)
|
| 468 |
|
|
|
|
| 22 |
from pydub import AudioSegment
|
| 23 |
import math
|
| 24 |
import json
|
|
|
|
| 25 |
|
| 26 |
# Load the emotion prediction model
|
| 27 |
def load_emotion_model(model_path):
|
|
|
|
| 404 |
process_btn = gr.Button("Process Audio", variant="primary")
|
| 405 |
clear_btn = gr.Button("Clear All", variant="secondary")
|
| 406 |
|
| 407 |
+
# Add a loading indicator - Fixed CSS syntax error by escaping % signs
|
| 408 |
loading_indicator = gr.HTML("""
|
| 409 |
<div id="loading" style="display: none; text-align: center; margin: 20px;">
|
| 410 |
<p style="font-size: 18px; color: #4a4a4a;">Processing audio chunks...</p>
|
| 411 |
<div style="border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 2s linear infinite; margin: 0 auto;"></div>
|
| 412 |
+
<style>@keyframes spin { 0%% { transform: rotate(0deg); } 100%% { transform: rotate(360deg); } }</style>
|
| 413 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
""")
|
| 415 |
|
| 416 |
# Create output components for each chunk type
|
|
|
|
| 444 |
if chunk_duration is None or chunk_duration <= 0:
|
| 445 |
chunk_duration = 10
|
| 446 |
|
| 447 |
+
# Show loading indicator - Fixed CSS syntax error by escaping % signs
|
| 448 |
+
yield [gr.HTML(f"""
|
| 449 |
<div style="text-align: center; margin: 20px;">
|
| 450 |
+
<p style="font-size: 18px; color: #4a4a4a;">Processing audio in {chunk_duration}-second chunks...</p>
|
| 451 |
<div style="border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 2s linear infinite; margin: 0 auto;"></div>
|
| 452 |
+
<style>@keyframes spin {{ 0%% {{ transform: rotate(0deg); }} 100%% {{ transform: rotate(360deg); }} }}</style>
|
| 453 |
</div>
|
| 454 |
+
""")] + [gr.Group(visible=False)] * len(group_components) + [None] * (len(output_containers) * 5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
|
| 456 |
results = get_predictions(audio_input, generate_audio, chunk_duration)
|
| 457 |
|