This tool allows you to transcribe videos, create searchable embeddings, and perform semantic search through video transcripts. It uses OpenAI's Whisper for transcription and sentence transformers for semantic search capabilities.
Key libraries used:
openai-whisper: For accurate video transcriptionsentence-transformers: For creating semantic embeddingsfaiss-cpu: For efficient similarity searchtorch: Required for ML modelsffmpeg-python: For video processing- Additional dependencies are listed in
requirements.txt
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtmy_project/
├── videos/ # Place your .mp4 videos here
├── transcripts/ # Generated transcripts (JSON)
├── index/ # Generated FAISS index and metadata
├── src/ # Source code
└── run.py # Main script
The tool provides three main commands:
Place your .mp4 videos in the videos/ directory, then run:
python run.py transcribeThis will:
- Load the Whisper model
- Process all new videos in the
videos/directory - Save transcripts as JSON files in
transcripts/ - Skip already transcribed videos
After transcription, create the search index:
python run.py embedThis will:
- Process all transcripts in
transcripts/ - Create embeddings using sentence transformers
- Build a FAISS index for efficient similarity search
- Save the index and metadata in
index/
To search through your video transcripts:
python run.py queryThis will start an interactive query interface where you can:
- Type natural language queries to find relevant video segments
- See timestamps, video sources, and relevance scores
- Get quick access to specific moments in your videos
To exit the query interface:
- Type
:qor:quit - Or use Ctrl+C
Example query session:
> what did obama say about hope
[Results showing relevant transcript segments...]
> how many people were injured
[Results showing relevant transcript segments...]
Each search result shows:
- 🎥 Source video file
- ⏱️ Timestamp (MM:SS format)
- 💬 Transcript text
- 📊 Relevance score
The tool provides timing breakdowns for searches:
- Embedding time: Converting query to vector
- FAISS search time: Finding similar segments
- Result formatting: Preparing output
- Total processing time
- Supports
.mp4video files - Uses Whisper's base model (can be configured to small/medium)
- Provides semantic search (meaning-based, not just keyword matching)
- Maintains original video files untouched