Reverse-engineering short-form virality with AI.
TrendLens is being built as the ultimate AI copilot for short-form content creators. The long-term goal is to create a complete, multi-platform intelligence tool (Instagram, TikTok, YouTube Shorts) that doesn't just show you vanity metrics, but actually analyzes why a video went viral and gives actionable, AI-driven advice on how to make better content.
Currently, the platform focuses on Instagram Reels. It acts as a modular data pipeline that:
- Identifies True Outliers: Uses statistical Z-scores to find videos that performed exceptionally well relative to a specific creator's baseline (ignoring inflated numbers from mega-influencers).
- Extracts the Hook: Bypasses anti-bot measures to securely download the CDN audio track of viral outliers.
- AI Transcription: Passes the audio through local OpenAI Whisper models to accurately extract the "Hook" (the critical first 3-5 seconds of spoken audio).
The result is a clean dataset of proven viral hooks in your specific niche, ready to be studied or fed into an LLM for content strategy.
Our architecture is fully Object-Oriented and designed to scale. Upcoming features include:
- Multi-Platform Support:
TikTokAnalyzerandYTShortsAnalyzermodules. - Deep Insights Engine: Combining views, likes, and comments into weighted Engagement Z-Scores.
- AI Content Strategist: Passing transcribed hooks into an LLM (e.g., Claude/GPT) to categorize hook psychology (e.g., "Negative Hook", "Curiosity Loop") and suggest scripts.
- Web Interface: A sleek Streamlit/FastAPI frontend for drag-and-drop analysis.
This project is built with scalability in mind, using a modular Object-Oriented architecture.
ai-content-helper/
├── config/ # Centralized settings (AppConfig)
├── core/ # Core services (Downloader, Transcriber, Pipeline)
├── analyzers/ # Platform-specific logic (InstagramAnalyzer)
├── data/ # Local storage for CSVs and temp audio
│ ├── input/ # Drop your Apify CSVs here
│ ├── output/ # Final viral hook CSVs are saved here
│ └── temp/ # Temporary audio files (.m4a) during processing
├── main.py # Entry point to execute the pipeline
└── requirements.txt # Python dependencies
- Python 3.8+ installed.
- FFmpeg installed on your system (Required by OpenAI Whisper for audio processing).
- Windows:
winget install ffmpeg - Mac:
brew install ffmpeg - Linux:
sudo apt update && sudo apt install ffmpeg
- Clone the repository:
git clone git clone https://github.com/walidght/viral-hook-extractor.git
cd viral-hook-extractor
- Create and activate a virtual environment:
python -m venv venv
# Windows: venv\Scripts\activate
# Mac/Linux: source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
Step 1: Get the Data
- Run the Apify Instagram Scraper for your target profiles.
- Export the results as a CSV.
- Place the CSV into the
data/input/folder.
Step 2: Configure
Open main.py and ensure the AppConfig matches your input filename:
config = AppConfig(
input_csv="data/input/your_apify_data.csv",
output_csv="data/output/viral_hooks.csv",
z_score_threshold=1.5
)Step 3: Run the Pipeline
python main.py
- Analyze: Calculates an engagement Z-score for each creator in the CSV.
- Filter: Isolates videos that performed >1.5 standard deviations above that specific creator's average.
- Download: Uses the direct
audioUrlfrom the CDN to download just the audio track (bypassing anti-bot measures). - Transcribe: Feeds the audio into local OpenAI Whisper (
basemodel). - Extract: Parses the AI transcript to grab the first sentences (the hook).
- Clean: Deletes the temporary audio and outputs a clean CSV with the viral hooks.