MPCIRCLE commited on
Commit
b2ef099
·
verified ·
1 Parent(s): f222c6c

Update webui.py

Browse files

changed from util to pathlib

Files changed (1) hide show
  1. webui.py +14 -10
webui.py CHANGED
@@ -1,22 +1,26 @@
1
  import os
 
2
  import time
3
- import shutil # Added shutil for potentially cleaning old files if needed, though not used in this version
4
  from huggingface_hub import snapshot_download
5
  import streamlit as st
6
 
7
- # Imports from your package
8
- # Ensure 'indextts' is correctly installed or available in your environment/requirements.txt
9
- from indextts.infer import IndexTTS
 
 
10
 
11
- # ------------------------------------------------------------------------------
12
- # Configuration
13
- # ------------------------------------------------------------------------------
 
 
14
 
15
- # Where to store model checkpoints and outputs
16
- # These paths are relative to the root directory of your Spaces repository
17
  CHECKPOINT_DIR = "checkpoints"
18
  OUTPUT_DIR = "outputs"
19
- PROMPTS_DIR = "prompts" # Directory to save uploaded reference audio
20
 
21
  # Ensure necessary directories exist. Hugging Face Spaces provides a writable filesystem.
22
  os.makedirs(CHECKPOINT_DIR, exist_ok=True)
 
1
  import os
2
+ import sys
3
  import time
4
+ from pathlib import Path
5
  from huggingface_hub import snapshot_download
6
  import streamlit as st
7
 
8
+ # ----------------------- Critical Path Configuration --------------------------
9
+ current_dir = Path(__file__).parent.resolve() # Get absolute path to current file
10
+ sys.path.insert(0, str(current_dir)) # Add current directory to Python path
11
+ sys.path.insert(1, str(current_dir / "indextts")) # Add indextts package
12
+ sys.path.insert(2, str(current_dir.parent)) # Add parent directory for utils
13
 
14
+ try:
15
+ from indextts.infer import IndexTTS
16
+ except ModuleNotFoundError as e:
17
+ st.error(f"Module import error: {str(e)}")
18
+ st.stop()
19
 
20
+ # ----------------------- Rest of Your Original Code ---------------------------
 
21
  CHECKPOINT_DIR = "checkpoints"
22
  OUTPUT_DIR = "outputs"
23
+ PROMPTS_DIR = "prompts"
24
 
25
  # Ensure necessary directories exist. Hugging Face Spaces provides a writable filesystem.
26
  os.makedirs(CHECKPOINT_DIR, exist_ok=True)