Update webui.py
Browse fileschanged from util to pathlib
webui.py
CHANGED
|
@@ -1,22 +1,26 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
import time
|
| 3 |
-
|
| 4 |
from huggingface_hub import snapshot_download
|
| 5 |
import streamlit as st
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
#
|
| 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"
|
| 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)
|