A video meme generator that uses Ludovic Magnin's template shouting "L'ARROGANCE!" (THE ARROGANCE!). The tool automatically adds custom text or GPT-4 generated content to the top of the video, and can send it directly to Telegram.
- Features
- Project Structure
- Prerequisites
- Installation
- Configuration
- Usage
- Quality Pipeline
- Batch Generation
- Troubleshooting
- โจ Automatic generation of humorous punchlines with OpenAI GPT-4
- ๐ Quality pipeline to evaluate and select the best punchlines
- ๐ Custom text overlay on the template video
- ๐ฅ Export of the video with embedded text
- ๐ฐ Token economy mode (uses GPT-3.5-turbo instead of GPT-4)
- ๐ฆ Batch generation from a JSON file of subjects
- ๐ฑ Automatic sending of memes to Telegram
- ๐ท๏ธ Automatic generation of relevant hashtags
- ๐ Generation of engaging descriptions for social media
- ๐ Analysis and statistics on the quality of generated punchlines
arrogance-meme-creator/
โโโ .env # Environment variables (create from .env.example)
โโโ .env.example # Example environment variables file
โโโ README.md # Project documentation
โโโ requirements.txt # Python dependencies
โโโ run-meme.sh # Shell script to run the meme generator
โโโ data/ # Persistent data
โ โโโ quality_data.db # Database of punchlines and evaluations
โโโ docs/ # Additional documentation
โ โโโ images/ # Images for documentation
โโโ output/ # Folder where generated files are stored
โ โโโ videos/ # Generated meme videos
โ โโโ reports/ # Batch generation reports and tests
โ โโโ exports/ # Exported files (punchlines, etc.)
โโโ src/ # Source code
โโโ __init__.py # Package initialization
โโโ main.py # Main entry point
โโโ generate_meme.py # Meme generation script
โโโ core/ # Main classes
โ โโโ meme_generator.py # Main meme generator class
โ โโโ quality_pipeline.py # Quality pipeline for punchlines
โ โโโ video_processor.py # Video processing with MoviePy
โโโ clients/ # Clients for external APIs
โ โโโ openai_client.py # Client for OpenAI API
โ โโโ telegram_client.py # Client for Telegram API
โโโ data/ # Data used by the generator
โ โโโ template.mp4 # "L'ARROGANCE!" template video
โ โโโ test_subjects.json # Example subjects for generation
โ โโโ json.json # Default JSON file for batch generation
โโโ utils/ # Various utilities
โ โโโ export_punchlines.py # Utility to export punchlines
โ โโโ punchlines_stats.py # Utility to display punchline statistics
โโโ tests/ # Unit tests
โโโ test_quality_pipeline.py # Tests for the quality pipeline
โโโ test_quality_pipeline_mock.py # Tests with mocks for the quality pipeline
- Python 3.12
- OpenAI API key (for punchline generation)
- Telegram Bot (for sending memes to Telegram, optional)
-
Clone this repository
git clone https://github.com/helios-code/arrogance-meme-creator.git cd arrogance-meme-creator -
Install dependencies:
pip install -r requirements.txt
-
Copy the example environment file:
cp .env.example .env
-
Edit the
.envfile and add your OpenAI API key and Telegram parameters.
The .env file contains all the necessary configurations for the meme generator. Here are the main options:
SERVICE_PORT=8000
SERVICE_HOST=0.0.0.0
LOG_LEVEL=info
OPENAI_API_KEY=your_openai_api_key_here
TEMPLATE_VIDEO_PATH=src/template.mp4
OUTPUT_DIRECTORY=output
FONT_PATH=Arial
FONT_SIZE=40
TEXT_COLOR=white
TEXT_POSITION_Y=0.35 # 35% from the top (about 250px on a 720p video)
TEXT_MARGIN_X=0.01 # 1% margin on each side
TEXT_BACKGROUND=black
ECONOMY_MODE=false # Uses GPT-3.5-turbo instead of GPT-4
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_CHAT_ID=your_telegram_chat_id_here
TELEGRAM_AUTO_SEND=false
USE_QUALITY_PIPELINE=true
QUALITY_THRESHOLD=0.7
NUM_PUNCHLINE_CANDIDATES=3
cd src
python generate_meme.pycd src
python generate_meme.py -t "When the intern pushes to prod on Friday at 5pm"cd src
python generate_meme.py -s "Swiss banks"cd src
python generate_meme.py -ecd src
python generate_meme.py -s "The media" --telegramThe run-meme.sh script makes it easier to use the generator:
./run-meme.sh --helpThe quality pipeline significantly improves the relevance and impact of generated punchlines by following these steps:
- Multiple Generation: Generates multiple candidate punchlines for each subject
- Automatic Evaluation: Analyzes each punchline according to 5 key criteria:
- Originality: Uniqueness and freshness of the punchline
- Humor: Comic potential and humorous impact
- Relevance: Appropriateness to the requested subject
- Conciseness: Optimal formulation and appropriate length
- Impact: Viral potential and memorability
- Intelligent Filtering: Eliminates punchlines that don't exceed a configurable quality threshold
- Optimal Selection: Chooses the best punchline for meme generation
- Continuous Analysis: Stores evaluations in a database to improve future generations
You can configure the quality pipeline in the .env file:
# Enable/disable the quality pipeline
USE_QUALITY_PIPELINE=true
# Quality threshold (between 0 and 1)
QUALITY_THRESHOLD=0.7
# Number of candidate punchlines to generate
NUM_PUNCHLINE_CANDIDATES=3
You can generate multiple memes from a JSON file containing subjects:
cd src
python generate_meme.py -b "test_subjects.json" -l 5JSON file format:
{
"subjects": [
"Politicians",
"Influencers",
"Developers"
]
}-
OpenAI API Error: Check that your API key is valid and that you have available credits.
-
Video Generation Error: Make sure the template.mp4 file exists in the src folder.
-
Telegram Sending Error: Check that your bot token and chat ID are correct.
Logs are available in the console and can help diagnose problems.
Created by Loic Mancino - GitHub
