--- title: AI Video Generator emoji: 🎬 colorFrom: blue colorTo: purple sdk: gradio sdk_version: 4.0.0 app_file: app.py pinned: false --- # 🎬 AI Video Generator An AI-powered video generator that creates engaging videos with text-to-speech voiceovers, animated subtitles, and professional transitions. ## ✨ Features - **Text-to-Speech**: Convert text to natural-sounding speech using Google's Gemini TTS - **Multiple Voices**: Choose from 5 different AI voices - **Audio Upload**: Upload your own voiceover audio - **Automatic Subtitles**: Word-by-word highlighted subtitles generated automatically - **Video Transitions**: Multiple transition effects (Smooth Blend, Ken Burns Zoom, Whip Pan, etc.) - **Background Music**: Add background music to your videos - **Custom Titles**: Add animated title overlays ## 🚀 Setup Instructions ### 1. Initial Setup on Hugging Face 1. Go to [Hugging Face Spaces](https://huggingface.co/spaces) 2. Click "Create new Space" 3. Choose a name (e.g., "my-video-generator") 4. Select **Gradio** as the SDK 5. Choose hardware (CPU is free, GPU recommended) 6. Click "Create Space" ### 2. Add Your Google API Key 1. Go to Space Settings → Repository secrets 2. Click "New secret" 3. Name: `GOOGLE_API_KEY` 4. Value: Your Google API key (get one from [Google AI Studio](https://aistudio.google.com/app/apikey)) 5. Click "Add" ### 3. Upload Required Files Upload these files to your Space: - `app.py` (main application) - `requirements.txt` (Python dependencies) - `packages.txt` (system dependencies) - `README.md` (this file) ### 4. Add Video Clips **IMPORTANT**: You need to add video clips for the generator to work! 1. In your Space, click "Files and versions" 2. Click "Add file" → "Create a new file" 3. Create a folder called `video_clips` 4. Upload at least 5-10 video clips (`.mp4`, `.avi`, `.mkv`, or `.mov`) **Tips for video clips:** - Use clips that are 5-30 seconds long - HD quality (1080p or 720p) works best - Nature, city, abstract, or stock footage works great - More clips = more variety in your videos ### 5. Optional: Add Background Music 1. Create a folder called `background_music` 2. Upload `.mp3` or `.wav` files 3. Music will be automatically added at low volume ## 📖 How to Use 1. **Enter Text**: Type or paste the text you want converted to speech 2. **Choose Voice**: Select from 5 AI voices 3. **OR Upload Audio**: Upload your own voiceover (instead of TTS) 4. **Add Title** (optional): Enter a title to display at the start 5. **Set Duration**: Only used if no audio is provided 6. **Choose Quality**: High (1080p), Standard (720p), or Preview (480p) 7. **Select Transition**: Choose your preferred transition effect 8. **Click Generate**: Wait for your video to be created! ## 🎥 Output The generated video will include: - Your selected video clips with transitions - Voiceover audio (TTS or uploaded) - Animated word-by-word subtitles - Optional title overlay - Optional background music ## 🔧 Troubleshooting **"Video clips folder not found"** - Make sure you've uploaded videos to the `video_clips` folder **"TTS failed"** - Check that your Google API key is correctly set in Space settings - Verify the API key has the Gemini API enabled **Slow generation** - Consider upgrading to GPU hardware in Space settings - Reduce video quality to "Preview" for faster processing **Out of memory** - Use fewer/shorter video clips - Reduce video quality setting - Upgrade to larger hardware ## 📝 File Structure ``` your-space/ ├── app.py # Main application ├── requirements.txt # Python dependencies ├── packages.txt # System dependencies ├── README.md # This file ├── video_clips/ # Your video files (REQUIRED) │ ├── clip1.mp4 │ ├── clip2.mp4 │ └── ... ├── background_music/ # Optional music files │ └── music.mp3 ├── voice_over/ # Generated voiceovers (auto-created) └── exports/ # Generated videos (auto-created) ``` ## 🎨 Customization You can customize the app by editing `app.py`: - Change subtitle styling - Modify transition effects - Adjust video processing settings - Add new features ## 📄 License This project uses various open-source libraries. Please ensure compliance with their licenses. ## 🙋 Support If you encounter issues: 1. Check the Space logs for error messages 2. Verify all setup steps are completed 3. Ensure video clips are uploaded 4. Check that API key is correctly set ## 🌟 Credits Built with: - Gradio - MoviePy - OpenAI Whisper - Google Generative AI - Pillow --- Made with ❤️ using Hugging Face Spaces