# Permanent Deployment to Hugging Face Spaces This guide will help you deploy your FastRTC application permanently to Hugging Face Spaces. ## Prerequisites 1. **Hugging Face Account**: Create a free account at [huggingface.co](https://huggingface.co) 2. **Hugging Face CLI**: Install the CLI tool ```bash pip install huggingface_hub ``` ## Deployment Steps ### Option 1: Using Gradio CLI (Recommended) 1. **Login to Hugging Face**: ```bash huggingface-cli login ``` Enter your Hugging Face token when prompted. 2. **Deploy from your project directory**: ```bash gradio deploy ``` Follow the prompts: - Enter your Space name (e.g., `bizom-voice-assistant`) - Select visibility (public or private) - The CLI will create the Space and push your code ### Option 2: Manual Deployment via Git 1. **Create a new Space on Hugging Face**: - Go to [huggingface.co/spaces](https://huggingface.co/spaces) - Click "Create new Space" - Choose: - **SDK**: Gradio - **Hardware**: CPU (or GPU if you have access) - **Visibility**: Public or Private - Name your Space (e.g., `bizom-voice-assistant`) 2. **Clone your Space repository**: ```bash git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME cd YOUR_SPACE_NAME ``` 3. **Copy your files**: ```bash cp /path/to/fastrtc/app.py . cp /path/to/fastrtc/requirements.txt . cp /path/to/fastrtc/README.md . ``` 4. **Set up environment variables**: - Go to your Space settings on Hugging Face - Navigate to "Variables and secrets" - Add the following secrets: - `HF_TOKEN`: Your Hugging Face token (automatically available, but you can set it explicitly) - `GEMINI_API_KEY`: Your Google Gemini API key (optional) 5. **Commit and push**: ```bash git add . git commit -m "Initial deployment" git push ``` ## Environment Variables in Spaces Hugging Face Spaces automatically provides: - `HF_TOKEN`: Your Hugging Face token (automatically set) - You can add custom secrets in Space settings → Variables and secrets To add `GEMINI_API_KEY`: 1. Go to your Space page 2. Click "Settings" → "Variables and secrets" 3. Add a new secret: `GEMINI_API_KEY` with your API key value ## Your Permanent URL Once deployed, your app will be available at: ``` https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space ``` For example: ``` https://santoshjs-bizom-voice-assistant.hf.space ``` ## Updating Your Deployment To update your deployed app: 1. **If using Git**: ```bash cd YOUR_SPACE_NAME # Make your changes git add . git commit -m "Update app" git push ``` 2. **If using Gradio CLI**: ```bash gradio deploy --update ``` ## Hardware Options - **CPU**: Free tier (may be slower for model loading) - **CPU Basic**: Paid tier for better performance - **GPU**: Available for paid accounts (faster model inference) ## Troubleshooting ### App not loading - Check the "Logs" tab in your Space for errors - Verify all dependencies are in `requirements.txt` - Ensure environment variables are set correctly ### TURN credentials not working - Verify `HF_TOKEN` is set (it should be automatic in Spaces) - Check the logs for credential errors ### Model loading issues - Consider upgrading to GPU hardware if models are too slow - Check that all model dependencies are in `requirements.txt` ## Resources - [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces) - [Gradio Deployment Guide](https://www.gradio.app/guides/sharing-your-app) - [FastRTC Deployment Guide](https://fastrtc.org/deployment/)