Spaces:
Running
Running
fixed audio paths
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
# Lectūra Research Demo: A Multi-Agent Tool for Self-taught Mastery.
|
2 |
# Author: Jaward Sesay
|
3 |
-
# ©
|
4 |
import os
|
5 |
import json
|
6 |
import re
|
@@ -32,6 +32,11 @@ import markdown
|
|
32 |
import PyPDF2
|
33 |
import io
|
34 |
import copy
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
def get_instructor_name(speaker):
|
37 |
instructor_names = {
|
@@ -423,6 +428,7 @@ async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_
|
|
423 |
instructor_name = get_instructor_name(speaker)
|
424 |
logger.info(f"Using instructor: {instructor_name}")
|
425 |
|
|
|
426 |
if os.path.exists(OUTPUT_DIR):
|
427 |
try:
|
428 |
for item in os.listdir(OUTPUT_DIR):
|
@@ -431,13 +437,15 @@ async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_
|
|
431 |
os.unlink(item_path)
|
432 |
elif os.path.isdir(item_path):
|
433 |
shutil.rmtree(item_path)
|
434 |
-
logger.info("Cleared outputs directory: %s", OUTPUT_DIR)
|
435 |
except Exception as e:
|
436 |
-
logger.error("
|
|
|
437 |
else:
|
438 |
-
os.makedirs(OUTPUT_DIR
|
439 |
-
|
440 |
-
|
|
|
|
|
441 |
# Total slides include user-specified content slides plus Introduction and Closing slides
|
442 |
content_slides = num_slides
|
443 |
total_slides = content_slides + 2
|
|
|
1 |
# Lectūra Research Demo: A Multi-Agent Tool for Self-taught Mastery.
|
2 |
# Author: Jaward Sesay
|
3 |
+
# © Lectūra Labs. All rights reserved.
|
4 |
import os
|
5 |
import json
|
6 |
import re
|
|
|
32 |
import PyPDF2
|
33 |
import io
|
34 |
import copy
|
35 |
+
from pathlib import Path
|
36 |
+
import time
|
37 |
+
|
38 |
+
# Set static paths for Gradio
|
39 |
+
gr.set_static_paths(paths=[Path.cwd().absolute()])
|
40 |
|
41 |
def get_instructor_name(speaker):
|
42 |
instructor_names = {
|
|
|
428 |
instructor_name = get_instructor_name(speaker)
|
429 |
logger.info(f"Using instructor: {instructor_name}")
|
430 |
|
431 |
+
# Clear output directory and cache
|
432 |
if os.path.exists(OUTPUT_DIR):
|
433 |
try:
|
434 |
for item in os.listdir(OUTPUT_DIR):
|
|
|
437 |
os.unlink(item_path)
|
438 |
elif os.path.isdir(item_path):
|
439 |
shutil.rmtree(item_path)
|
|
|
440 |
except Exception as e:
|
441 |
+
logger.error(f"Error clearing output directory: {e}")
|
442 |
+
raise gr.Error(f"Failed to clear output directory: {str(e)}")
|
443 |
else:
|
444 |
+
os.makedirs(OUTPUT_DIR)
|
445 |
+
|
446 |
+
# Clear browser cache by adding timestamp to file URLs
|
447 |
+
cache_buster = int(time.time())
|
448 |
+
|
449 |
# Total slides include user-specified content slides plus Introduction and Closing slides
|
450 |
content_slides = num_slides
|
451 |
total_slides = content_slides + 2
|