Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

"L'ARROGANCE!" Meme Generator ๐ŸŽฌ

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.

Meme Example

๐Ÿ“‘ Table of Contents

๐Ÿš€ Features

  • โœจ 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

๐Ÿ“‚ Project Structure

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

๐Ÿ“‹ Prerequisites

  • Python 3.12
  • OpenAI API key (for punchline generation)
  • Telegram Bot (for sending memes to Telegram, optional)

๐Ÿ”ง Installation

  1. Clone this repository

    git clone https://github.com/helios-code/arrogance-meme-creator.git
    cd arrogance-meme-creator
  2. Install dependencies:

    pip install -r requirements.txt
  3. Copy the example environment file:

    cp .env.example .env
  4. Edit the .env file and add your OpenAI API key and Telegram parameters.

โš™๏ธ Configuration

The .env file contains all the necessary configurations for the meme generator. Here are the main options:

General Configuration

SERVICE_PORT=8000
SERVICE_HOST=0.0.0.0
LOG_LEVEL=info

OpenAI API

OPENAI_API_KEY=your_openai_api_key_here

Meme Generator Configuration

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

Token Economy Mode

ECONOMY_MODE=false  # Uses GPT-3.5-turbo instead of GPT-4

Telegram Configuration

TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_CHAT_ID=your_telegram_chat_id_here
TELEGRAM_AUTO_SEND=false

Quality Pipeline Configuration

USE_QUALITY_PIPELINE=true
QUALITY_THRESHOLD=0.7
NUM_PUNCHLINE_CANDIDATES=3

๐ŸŽฎ Usage

Simple Generation

cd src
python generate_meme.py

With Custom Text

cd src
python generate_meme.py -t "When the intern pushes to prod on Friday at 5pm"

With a Specific Subject

cd src
python generate_meme.py -s "Swiss banks"

Token Economy Mode

cd src
python generate_meme.py -e

Send to Telegram

cd src
python generate_meme.py -s "The media" --telegram

Using the Shell Script

The run-meme.sh script makes it easier to use the generator:

./run-meme.sh --help

๐Ÿ” Quality Pipeline

The quality pipeline significantly improves the relevance and impact of generated punchlines by following these steps:

  1. Multiple Generation: Generates multiple candidate punchlines for each subject
  2. 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
  3. Intelligent Filtering: Eliminates punchlines that don't exceed a configurable quality threshold
  4. Optimal Selection: Chooses the best punchline for meme generation
  5. Continuous Analysis: Stores evaluations in a database to improve future generations

Pipeline Configuration

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

๐Ÿ“ฆ Batch Generation

You can generate multiple memes from a JSON file containing subjects:

cd src
python generate_meme.py -b "test_subjects.json" -l 5

JSON file format:

{
  "subjects": [
    "Politicians",
    "Influencers",
    "Developers"
  ]
}

๐Ÿ”ง Troubleshooting

Common Issues

  1. OpenAI API Error: Check that your API key is valid and that you have available credits.

  2. Video Generation Error: Make sure the template.mp4 file exists in the src folder.

  3. Telegram Sending Error: Check that your bot token and chat ID are correct.

Logs

Logs are available in the console and can help diagnose problems.


Created by Loic Mancino - GitHub

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages