Spaces:
Runtime error
Runtime error
| import os | |
| import subprocess | |
| def ensure_sadtalker(): | |
| # Clone repo if missing | |
| if not os.path.isdir("SadTalker"): | |
| print("Cloning SadTalker...") | |
| subprocess.run( | |
| ["git", "clone", "https://github.com/OpenTalker/SadTalker.git"], | |
| check=True | |
| ) | |
| ckpt_dir = os.path.join("SadTalker", "checkpoints") | |
| if not os.path.isdir(ckpt_dir) or not os.listdir(ckpt_dir): | |
| # Only try to download if checkpoints folder is empty | |
| script_path = os.path.join("SadTalker", "scripts", "download_models.sh") | |
| if os.path.exists(script_path): | |
| print("Downloading SadTalker model weights...") | |
| # IMPORTANT: cwd is SadTalker, script path is relative inside that folder | |
| subprocess.run( | |
| ["bash", "scripts/download_models.sh"], | |
| cwd="SadTalker", | |
| check=True | |
| ) | |
| else: | |
| print("Warning: SadTalker download script not found at", script_path) | |
| else: | |
| print("SadTalker checkpoints already present, skipping download.") | |
| if __name__ == "__main__": | |
| ensure_sadtalker() | |