File size: 3,630 Bytes
29a3552 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# 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/)
|