Spaces:
Sleeping
Sleeping
| """Create/update the public Hugging Face ZeroGPU Space from this folder. | |
| Run this script only after reviewing the model and access scope. It uploads the | |
| app and the bundled ``benienma`` model but excludes caches and local test output. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import os | |
| from pathlib import Path | |
| from huggingface_hub import HfApi | |
| APP_DIR = Path(__file__).parent | |
| DEFAULT_SPACE_ID = "alrab222/benienma-tts-api" | |
| IGNORE_PATTERNS = [ | |
| "**/__pycache__/**", | |
| "**/*.py[cod]", | |
| "**/*.pickle", | |
| ".cache/**", | |
| "output.wav", | |
| "test_output.wav", | |
| "space/**", | |
| ] | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Deploy the benienma CPU TTS Space") | |
| parser.add_argument( | |
| "--space-id", | |
| default=os.environ.get("HF_SPACE_ID", DEFAULT_SPACE_ID), | |
| help=f"Hugging Face Space ID (default: {DEFAULT_SPACE_ID})", | |
| ) | |
| parser.add_argument( | |
| "--token", | |
| default=os.environ.get("HF_TOKEN"), | |
| help="Hugging Face write token (or set HF_TOKEN)", | |
| ) | |
| parser.add_argument( | |
| "--private", | |
| action="store_true", | |
| help="Create a private Space instead of the public ZeroGPU Space.", | |
| ) | |
| args = parser.parse_args() | |
| api = HfApi(token=args.token) | |
| api.create_repo( | |
| repo_id=args.space_id, | |
| repo_type="space", | |
| space_sdk="gradio", | |
| space_hardware="zero-a10g", | |
| private=args.private, | |
| exist_ok=True, | |
| ) | |
| api.upload_folder( | |
| repo_id=args.space_id, | |
| repo_type="space", | |
| folder_path=APP_DIR, | |
| ignore_patterns=IGNORE_PATTERNS, | |
| delete_patterns="**/*.pickle", | |
| commit_message="Deploy public ZeroGPU benienma TTS API", | |
| ) | |
| print(f"https://huggingface.co/spaces/{args.space_id}") | |
| if __name__ == "__main__": | |
| main() | |