Spaces:
Running
Running
ui fixes
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import asyncio
|
|
8 |
import logging
|
9 |
import torch
|
10 |
import zipfile
|
|
|
11 |
from serpapi import GoogleSearch
|
12 |
from pydantic import BaseModel
|
13 |
from autogen_agentchat.agents import AssistantAgent
|
@@ -387,6 +388,21 @@ def get_gradio_file_url(local_path):
|
|
387 |
# Async generate lecture materials and audio
|
388 |
async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_description, lecture_type, speaker_audio, num_slides):
|
389 |
model_client = get_model_client(api_service, api_key)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
|
391 |
# Total slides include user-specified content slides plus Introduction and Closing slides
|
392 |
content_slides = num_slides
|
@@ -824,10 +840,10 @@ Example: 'Received {total_slides} slides, {total_slides} scripts, and HTML files
|
|
824 |
{audio_timeline}
|
825 |
</div>
|
826 |
<div style="display: center; justify-content: center; margin-bottom: 10px;">
|
827 |
-
<button id="prev-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer;"><i class="fas fa-step-backward"></i></button>
|
828 |
-
<button id="play-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer;"><i class="fas fa-play"></i></button>
|
829 |
-
<button id="next-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer;"><i class="fas fa-step-forward"></i></button>
|
830 |
-
<button id="fullscreen-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer;"><i class="fas fa-expand"></i></button>
|
831 |
</div>
|
832 |
</div>
|
833 |
</div>
|
@@ -1241,7 +1257,7 @@ with gr.Blocks(
|
|
1241 |
)
|
1242 |
api_key = gr.Textbox(label="Model Provider API Key", type="password", placeholder="Not required for Ollama or Azure AI Foundry (use GITHUB_TOKEN env var)")
|
1243 |
serpapi_key = gr.Textbox(label="SerpApi Key (For Research Agent)", type="password", placeholder="Enter your SerpApi key (optional)")
|
1244 |
-
num_slides = gr.Slider(1, 20, step=1, label="Number of Lecture Slides (
|
1245 |
speaker_audio = gr.Audio(label="Speaker sample speech (MP3 or WAV)", type="filepath", elem_id="speaker-audio")
|
1246 |
generate_btn = gr.Button("Generate Lecture")
|
1247 |
with gr.Column(scale=2):
|
|
|
8 |
import logging
|
9 |
import torch
|
10 |
import zipfile
|
11 |
+
import shutil
|
12 |
from serpapi import GoogleSearch
|
13 |
from pydantic import BaseModel
|
14 |
from autogen_agentchat.agents import AssistantAgent
|
|
|
388 |
# Async generate lecture materials and audio
|
389 |
async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_description, lecture_type, speaker_audio, num_slides):
|
390 |
model_client = get_model_client(api_service, api_key)
|
391 |
+
|
392 |
+
if os.path.exists(OUTPUT_DIR):
|
393 |
+
try:
|
394 |
+
for item in os.listdir(OUTPUT_DIR):
|
395 |
+
item_path = os.path.join(OUTPUT_DIR, item)
|
396 |
+
if os.path.isfile(item_path):
|
397 |
+
os.unlink(item_path)
|
398 |
+
elif os.path.isdir(item_path):
|
399 |
+
shutil.rmtree(item_path)
|
400 |
+
logger.info("Cleared outputs directory: %s", OUTPUT_DIR)
|
401 |
+
except Exception as e:
|
402 |
+
logger.error("Failed to clear outputs directory: %s", str(e))
|
403 |
+
else:
|
404 |
+
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
405 |
+
logger.info("Created outputs directory: %s", OUTPUT_DIR)
|
406 |
|
407 |
# Total slides include user-specified content slides plus Introduction and Closing slides
|
408 |
content_slides = num_slides
|
|
|
840 |
{audio_timeline}
|
841 |
</div>
|
842 |
<div style="display: center; justify-content: center; margin-bottom: 10px;">
|
843 |
+
<button id="prev-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: lightgrey"><i class="fas fa-step-backward" style="color: #000"></i></button>
|
844 |
+
<button id="play-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: lightgrey"><i class="fas fa-play" style="color: #000"></i></button>
|
845 |
+
<button id="next-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: lightgrey"><i class="fas fa-step-forward" style="color: #000"></i></button>
|
846 |
+
<button id="fullscreen-btn" style="border-radius: 50%; width: 40px; height: 40px; margin: 0 5px; font-size: 1.2em; cursor: pointer; background-color: lightgrey"><i style="color: #000" class="fas fa-expand"></i></button>
|
847 |
</div>
|
848 |
</div>
|
849 |
</div>
|
|
|
1257 |
)
|
1258 |
api_key = gr.Textbox(label="Model Provider API Key", type="password", placeholder="Not required for Ollama or Azure AI Foundry (use GITHUB_TOKEN env var)")
|
1259 |
serpapi_key = gr.Textbox(label="SerpApi Key (For Research Agent)", type="password", placeholder="Enter your SerpApi key (optional)")
|
1260 |
+
num_slides = gr.Slider(1, 20, step=1, label="Number of Lecture Slides (will add intro and closing slides)", value=3)
|
1261 |
speaker_audio = gr.Audio(label="Speaker sample speech (MP3 or WAV)", type="filepath", elem_id="speaker-audio")
|
1262 |
generate_btn = gr.Button("Generate Lecture")
|
1263 |
with gr.Column(scale=2):
|