This script automates the creation of YouTube Shorts videos on a given topic. It uses OpenAI's GPT-4o for script generation, ElevenLabs for voiceovers, and Fal AI with Flux Schnell for image generation.
- Script Generation: Leverages GPT-4o-2024-05-13 to create engaging scripts.
- Voiceover Creation: Uses ElevenLabs API for high-quality voiceovers.
- Image Generation: Uses Fal AI with Flux Schnell model for generating relevant images.
- Automated Video Assembly: Combines audio and generated images into a complete YouTube Short.
- Python 3.x
requests
json
python-dotenv
openai
moviepy
Run the installation script:
./install.sh
-
Install Dependencies: Ensure Python 3.x is installed, then run:
pip install -r requirements.txt
Note: We use locked versions to ensure compatibility. The
requirements.txt
includes specific versions that have been tested and confirmed working together. -
Environment Variables: Set up
.env
file with API keys:OPEN_API_KEY
for OpenAI.FAL_API_KEY
for Fal AI.ELVEN_LABS_API_KEY
for ElevenLabs.
Run the script with a topic as an argument: python main.py "Your Topic"
.
- Topic Input: Accepts a topic for the YouTube Short.
- Scenario Generation: Uses GPT-4o-2024-05-13 to generate a video script based on the topic.
- Image Generation: Creates relevant images using Fal AI with Flux Schnell model.
- Audio Generation: Creates a voiceover using ElevenLabs API.
- Video Assembly: Merges audio and generated images into video clips, and outputs the final video.
generate_audio_from_text(text, scene_id, voice_id)
: Generates a voiceover for a given text.generate_images_from_fal(keywords, scene_id)
: Generates images using Fal AI with Flux Schnell model based on provided keywords.create_video_from_images(images, scene_id, duration)
: Creates a video from generated images.generate_scenario(topic)
: Generates the script and scene descriptions using GPT-4o-2024-05-13.
- API Quotas: Be aware of rate limits and quotas for OpenAI, Fal AI, and ElevenLabs APIs.
- Image Quality: The quality of the final video depends on the generated images and TTS quality.
- Error Handling: The script includes basic error handling, which can be expanded for robustness.
- Customization Options: Adding more options for voice and style customization in voiceovers.
- Improved Error Handling: Enhance error detection and handling for more stability.
- User Interface: Develop a GUI for easier interaction and topic input.
- Image Style Control: Add options to control the style and theme of generated images.
- ✅ Updated to GPT-4o-2024-05-13 for improved script generation
- ✅ Replaced Pexels with Fal AI + Flux Schnell for high-quality image generation
- ✅ Added automatic video creation from generated images
- ✅ Fixed compatibility issues between MoviePy and newer Pillow versions
- ✅ Locked dependency versions in
requirements.txt
to prevent compatibility issues
- Dependency Versions: This project uses specific library versions (see
requirements.txt
) that have been tested for compatibility. Using different versions may cause issues, particularly with MoviePy and Pillow. - PIL Compatibility: The code includes a compatibility fix for newer Pillow versions with older MoviePy.
- System Dependencies: Make sure you have the required system libraries for image processing (automatically installed in most environments).
Contributions to improve or extend the script are welcome. Please adhere to standard coding practices and provide documentation for any changes.