Jaward commited on
Commit
15ee64a
·
verified ·
1 Parent(s): 90a9901

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -34
app.py CHANGED
@@ -57,36 +57,12 @@ logger = logging.getLogger(__name__)
57
  # Set up environment
58
  OUTPUT_DIR = os.path.join(os.getcwd(), "outputs")
59
  UPLOAD_DIR = os.path.join(os.getcwd(), "uploads")
60
- STATIC_DIR = os.path.join(os.getcwd(), "static")
61
  os.makedirs(OUTPUT_DIR, exist_ok=True)
62
  os.makedirs(UPLOAD_DIR, exist_ok=True)
63
- os.makedirs(STATIC_DIR, exist_ok=True)
64
  logger.info(f"Using output directory: {OUTPUT_DIR}")
65
  logger.info(f"Using upload directory: {UPLOAD_DIR}")
66
- logger.info(f"Using static directory: {STATIC_DIR}")
67
-
68
- # Set environment variable to automatically accept TTS terms of service
69
  os.environ["COQUI_TOS_AGREED"] = "1"
70
 
71
- # Copy default audio files to static directory
72
- DEFAULT_AUDIO_FILES = {
73
- "feynman.mp3": "professor_lectura_male.mp3",
74
- "einstein.mp3": "professor_lectura_male.mp3",
75
- "samantha.mp3": "professor_lectura_male.mp3",
76
- "socrates.mp3": "professor_lectura_male.mp3",
77
- "professor_lectura_male.mp3": "professor_lectura_male.mp3"
78
- }
79
-
80
- # Ensure default audio files exist in static directory
81
- for audio_file in DEFAULT_AUDIO_FILES.values():
82
- static_audio_path = os.path.join(STATIC_DIR, audio_file)
83
- if not os.path.exists(static_audio_path):
84
- # Copy from original location if it exists
85
- original_path = os.path.join(os.path.dirname(__file__), audio_file)
86
- if os.path.exists(original_path):
87
- shutil.copy2(original_path, static_audio_path)
88
- logger.info(f"Copied {audio_file} to static directory")
89
-
90
  # Initialize TTS model
91
  device = "cuda" if torch.cuda.is_available() else "cpu"
92
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
@@ -1577,12 +1553,7 @@ with gr.Blocks(
1577
  label="Select Instructor",
1578
  elem_id="speaker-select"
1579
  )
1580
- speaker_audio = gr.Audio(
1581
- value=os.path.join(STATIC_DIR, "professor_lectura_male.mp3"),
1582
- label="Speaker sample speech (MP3 or WAV)",
1583
- type="filepath",
1584
- elem_id="speaker-audio"
1585
- )
1586
  generate_btn = gr.Button("Generate Lecture")
1587
 
1588
  # Middle column (existing slide display)
@@ -2276,7 +2247,4 @@ with gr.Blocks(
2276
  demo.css += custom_css
2277
 
2278
  if __name__ == "__main__":
2279
- demo.launch(
2280
- allowed_paths=[OUTPUT_DIR, STATIC_DIR],
2281
- share=True
2282
- )
 
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"
68
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
 
1553
  label="Select Instructor",
1554
  elem_id="speaker-select"
1555
  )
1556
+ speaker_audio = gr.Audio(value="professor_lectura_male.mp3", label="Speaker sample speech (MP3 or WAV)", type="filepath", elem_id="speaker-audio")
 
 
 
 
 
1557
  generate_btn = gr.Button("Generate Lecture")
1558
 
1559
  # Middle column (existing slide display)
 
2247
  demo.css += custom_css
2248
 
2249
  if __name__ == "__main__":
2250
+ demo.launch(allowed_paths=[OUTPUT_DIR])