This project is a Python-based tool for generating vertical videos optimized for platforms like TikTok, Instagram Reels, and YouTube Shorts. It uses AI models for script generation, image creation, audio synthesis, and captioning to automate the video creation process.
- Script Generation: Create engaging video scripts using Llama3 via the Groq Cloud API.
- Image Generation: Generate high-quality images using Together AI's FLUX-1 model.
- Audio Generation: Convert scripts to audio using Kokoro TTS (with fallback to Edge TTS).
- Caption Generation: Transcribe audio to captions using OpenAI's Whisper model.
- Video Composition: Combine images, audio, and captions into a final video using MoviePy.
- User Choice: Choose between generating a full video or just the script, images, and audio.
Before running the project, ensure you have the following:
- Python 3.11: Install Python from python.org.
- API Keys:
- Groq Cloud API key (for script generation). GroqCloud
- Together AI API key (for image generation). Together AI
- FFmpeg: Required for audio and video processing. Download from ffmpeg.org.
- ImageMagick: Required for video processing. Download from ImageMagick.
-
Clone the repository:
git clone https://github.com/GabrielLaxy/TikTokAIVideoGenerator.git cd TikTokAIVideoGenerator
-
Install dependencies:
pip install -r requirements.txt
-
Set up API keys:
- Rename your
config.json
file in the project root formy_config.json
, make sure the archive is with the following structure:{ "groq_api_key": "your-groq-api-key", "together_api_key": "your-together-api-key" }
- Rename your
-
Install FFmpeg:
- Download and install FFmpeg from ffmpeg.org.
- Add FFmpeg to your system PATH.
-
Install ImageMagick:
- Download and install ImageMagick from ImageMagick.
- Make sure ImageMagick's folder is on this path.
C:\Program Files\ImageMagick-7.1.1-Q16-HDRI
Run the program:
python main.py
-
Input Details:
- Enter the project folder name, video topic, style, target audience, and call-to-action (CTA).
-
Generated Files:
- The project folder will contain:
script.json
: Generated script.image_prompts.json
: Image prompts.images/
: Generated images.audio/voiceover.mp3
: Generated audio.captions/captions.json
: Generated captions (if full video is selected).final_video.mp4
: Video without captions (if full video is selected).final_video_with_captions.mp4
: Final video with captions (if full video is selected).
- The project folder will contain:
- Uses Llama3 via the Groq Cloud API to generate a script based on user inputs.
- Saves the script as
script.json
.
- Creates image prompts based on the script.
- Saves the prompts as
image_prompts.json
.
- Uses Together AI's FLUX-1 model to generate images.
- Saves images in the
images/
folder.
- Uses Kokoro TTS to generate audio from the script.
- Falls back to Edge TTS if Kokoro TTS fails.
- Saves the audio as
audio/voiceover.mp3
.
- Uses OpenAI's Whisper model to transcribe audio into captions.
- Saves captions as
captions/captions.json
.
- Combines images, audio, and captions into a final video.
- Saves the video as
final_video_with_captions.mp4
.
- Subtitles are split into a maximum of 5 words per line and truncated into 2 lines.
- Font: Arial-Bold, size 50.
- White text with a black stroke for better contrast.
- Positioned at the bottom center of the video.
- Resolution: 1080x1920 (vertical format).
- Frame rate: 24 FPS.
- Codec: H.264 for video, AAC for audio.
- If Kokoro TTS fails, the program automatically falls back to Edge TTS.
- Ensure FFmpeg is installed and added to your system PATH.
- Verify that your API keys are correct and have sufficient credits.
This project is licensed under the Creative Commons Zero v1.0 Universal license. See the LICENSE file for details.
- Llama3: For script generation.
- Together AI: For image generation.
- Kokoro TTS: For audio synthesis.
- OpenAI Whisper: For caption generation.
- MoviePy: For video composition.
Contributions are welcome! Please open an issue or submit a pull request.
For questions or feedback, contact gabriel_laxy@proton.me.