| # HuggingFace Spaces entry point – must be named app.py | |
| # Imports and re-exports the Gradio demo from gradio_app.py | |
| import os | |
| import sys | |
| from pathlib import Path | |
| # On HF Spaces, SadTalker checkpoints are likely absent → disable video by default | |
| # Users can still enable it with the "Skip video" checkbox. | |
| # If you DO upload checkpoints, remove this env var. | |
| if not (Path(__file__).parent / "sadtalker+wav2lip" / "sadtalker" / "checkpoints").exists(): | |
| os.environ.setdefault("DISABLE_VIDEO", "1") | |
| # HF_TOKEN must be set as a Space Secret for the HF Inference API fallback | |
| # os.environ["HF_TOKEN"] is picked up automatically from Secrets | |
| from gradio_app import demo # noqa: E402 (import after env setup) | |
| demo.queue().launch() | |