A Python tool to find when a specific phrase is spoken in a video using OpenAIโs Whisper.
It transcribes your video once (caching the result) and allows you to search for phrases laterโfast!
- โ Transcribes video audio using Whisper (tiny model for speed)
- ๐ฆ Caches transcript automatically for faster repeated queries
- ๐ Returns precise timestamps (seconds) where your query phrase is said
- ๐ง Supports fuzzy/approximate matching for inexact phrases
- ๐งน Includes utility to clear cached transcripts
- Python 3.x
- openai/whisper
- re (regular expressions)
- difflib
- pickle
- OS
Install required Python packages:
pip install git+https://github.com/openai/whisper.git
pip install torchClone or download this repo, or just copy the script into your project.
1๏ธโฃ First time:
- Loads Whisper โtinyโ model for fast transcription
- Saves the transcript as a
.pklfile for caching
2๏ธโฃ On later runs:
- Loads the cached transcript instantly
- Searches text segments for your query
3๏ธโฃ Matching:
- Exact or substring matches
- Fuzzy matching for long phrases
- Partial word matches for multi-word queries
from your_module_name import get_timestamp_for_query
video_path = "your_video.mp4"
query = "your search phrase"
timestamp = get_timestamp_for_query(video_path, query)
print(f"Found at: {timestamp} seconds")If you want to clear the cached transcript:
from your_module_name import clear_cache
clear_cache("your_video.mp4")โ See it in action (link your video here):
Md Shahriar Rahman Bhuiyan
๐ LinkedIn Profile
If you have feedback or want to collaborate, feel free to reach out via LinkedIn!