Jaward commited on
Commit
9e43606
·
verified ·
1 Parent(s): e215a9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -16
app.py CHANGED
@@ -32,7 +32,6 @@ import markdown
32
  import PyPDF2
33
  import io
34
  import copy
35
- from pathlib import Path
36
 
37
  def get_instructor_name(speaker):
38
  instructor_names = {
@@ -55,16 +54,14 @@ logging.basicConfig(
55
  )
56
  logger = logging.getLogger(__name__)
57
 
58
- # Set up environment with absolute paths
59
- OUTPUT_DIR = os.path.abspath(os.path.join(os.getcwd(), "outputs"))
60
- UPLOAD_DIR = os.path.abspath(os.path.join(os.getcwd(), "uploads"))
61
  os.makedirs(OUTPUT_DIR, exist_ok=True)
62
  os.makedirs(UPLOAD_DIR, exist_ok=True)
63
  logger.info(f"Using output directory: {OUTPUT_DIR}")
64
  logger.info(f"Using upload directory: {UPLOAD_DIR}")
65
-
66
- # Set up static paths for Gradio
67
- gr.set_static_paths(paths=[Path(OUTPUT_DIR).absolute()])
68
 
69
  # Initialize TTS model
70
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -409,12 +406,9 @@ def create_zip_of_files(file_paths):
409
 
410
  # Access local files
411
  def get_gradio_file_url(local_path):
412
- if not local_path:
413
- return None
414
- # Get the relative path from the current working directory
415
  relative_path = os.path.relpath(local_path, os.getcwd())
416
  final_path = f"/gradio_api/file={relative_path}"
417
- print(f"File URL path: {final_path}")
418
  return final_path
419
 
420
  # Async generate lecture materials and audio
@@ -2031,7 +2025,7 @@ with gr.Blocks(
2031
  yield default_slide_html, None, None
2032
  return
2033
 
2034
-
2035
  if not api_key and api_service != "Azure AI Foundry":
2036
  error_html = """
2037
  <div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; min-height: 700px; padding: 20px; text-align: center; border: 1px solid #ddd; border-radius: 8px;">
@@ -2308,11 +2302,8 @@ with gr.Blocks(
2308
  "audience": audience_val or "University"
2309
  }
2310
 
2311
- def show_note_content(evt: dict, notes=None):
2312
  # evt['index'] gives the row index
2313
- if not notes:
2314
- return gr.update(value="Click any button above to generate content...")
2315
-
2316
  idx = evt.get('index', 0)
2317
  if 0 <= idx < len(notes):
2318
  note = notes[idx]
 
32
  import PyPDF2
33
  import io
34
  import copy
 
35
 
36
  def get_instructor_name(speaker):
37
  instructor_names = {
 
54
  )
55
  logger = logging.getLogger(__name__)
56
 
57
+ # Set up environment
58
+ OUTPUT_DIR = os.path.join(os.getcwd(), "outputs")
59
+ UPLOAD_DIR = os.path.join(os.getcwd(), "uploads")
60
  os.makedirs(OUTPUT_DIR, exist_ok=True)
61
  os.makedirs(UPLOAD_DIR, exist_ok=True)
62
  logger.info(f"Using output directory: {OUTPUT_DIR}")
63
  logger.info(f"Using upload directory: {UPLOAD_DIR}")
64
+ os.environ["COQUI_TOS_AGREED"] = "1"
 
 
65
 
66
  # Initialize TTS model
67
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
406
 
407
  # Access local files
408
  def get_gradio_file_url(local_path):
 
 
 
409
  relative_path = os.path.relpath(local_path, os.getcwd())
410
  final_path = f"/gradio_api/file={relative_path}"
411
+ print(f"Full Path: {final_path}")
412
  return final_path
413
 
414
  # Async generate lecture materials and audio
 
2025
  yield default_slide_html, None, None
2026
  return
2027
 
2028
+ # Validate API key or GITHUB_TOKEN for Azure AI Foundry
2029
  if not api_key and api_service != "Azure AI Foundry":
2030
  error_html = """
2031
  <div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; min-height: 700px; padding: 20px; text-align: center; border: 1px solid #ddd; border-radius: 8px;">
 
2302
  "audience": audience_val or "University"
2303
  }
2304
 
2305
+ def show_note_content(evt: dict, notes):
2306
  # evt['index'] gives the row index
 
 
 
2307
  idx = evt.get('index', 0)
2308
  if 0 <= idx < len(notes):
2309
  note = notes[idx]