Captions perfectly sync kaise hote hain
Reel mein promise kiya tha: free caption sync setup, local Whisper code ke saath. Ye raha. Download karo, apni awaaz daalo, aur har word ka exact time nikalo. Na API key, na paisa.
Caption wahi, jo tum bol rahe ho 🎙️
AI se video kaise banaye
Ye guide part 4 ka hai. Pehle reel dekho, phir yahan se step by step karo.
- 1Poora setup: Claude Code + exact prompt + free voice clone
- 2Apna 2D character kaise banaye
- 3Animation kaise kaam karta hai (code se video)
- 4Captions perfectly sync kaise hote haintum yahan ho
- 5Ek reel ka asli kharcha, aur free mein kaise banayejaldi aa raha
Whisper har word ka time deta hai
Whisper OpenAI ka speech-to-text model hai. Awaaz sunke text likhta hai, aur word timestamps on karo toh har word ke saath ye bhi batata hai: kab shuru hua, kab khatam. Seconds mein.
[
{ "word": "Ye", "start": 0.00, "end": 0.20 },
{ "word": "captions", "start": 0.20, "end": 0.66 },
{ "word": "mere", "start": 0.66, "end": 0.88 }
]Hum faster-whisper use karenge: Whisper ka tez version, jo tumhare laptop pe chalta hai. Free hai, awaaz kahin upload nahi hoti, aur CPU pe bhi 45 second ka voiceover ek minute se kam leta hai. Docs: faster-whisper aur OpenAI Whisper.
Hindi mein problem: Whisper skip karta hai
English mein Whisper kamaal hai. Hindi aur Hinglish mein 3 cheezein hoti hain:
- Alag spelling. Tumne
videolikha, Whisper neवीडियो. Dono sahi hain, par caption mein tumhare words chahiye, uske nahi. - Galat sune words.
keywordban gayaवर्ट. Reel pe ye ajeeb dikhta hai. - Poore hisse skip. Tez bolne ya music ke upar ka hissa kabhi kabhi bilkul gayab. Wahan caption ruk jaata hai ya aage bhaag jaata hai.
Apni captions file + Whisper ka time
Tum ek captions.txt likhte ho: jo words screen pe chahiye, jis order mein bolte ho. align.py dono ko sound ke hisaab se milata hai (video aur वीडियो ek jaise sunai dete hain) aur tumhare word pe Whisper ka time laga deta hai.
[
{ "word": "video", "start": 4.86, "end": 5.14 },
{ "word": "kaise", "start": 5.14, "end": 5.38 },
{ "word": "banaye", "start": 5.38, "end": 5.92 }
]Format wahi hai jo words.json ka hai, toh part 3 ka scene template (atWord, CaptionStrip) bina badlaav ke use kar sakte ho.
Gap? Khamoshi se bharo
Jahan Whisper kuch nahi sun paya, wahan tumhare words ko time kaise milega? Andaza nahi, awaaz dekhte hain:
- Pehle anchor. Gap ke pehle aur baad wala matched word. Gap inke beech hai.
- Khamoshi dhundo. Audio ki energy naapte hain. Jahan awaaz hai wahi "bolne ka time" hai, khamoshi nikaal do.
- Words baanto. Bolne ke time ko words mein baanto, lambe word ko zyada time. Kuch na mile toh barabar spacing.
Captions words : 125 Matched : 112 (90%) (time taken from Whisper) Filled : 13 (10%) (time estimated from the gaps) Filled stretches (check these by ear): words 34-36 13.22s to 13.88s [silence] "word ka time"
Report mein Filled wale hisse ek baar sun lo. Baaki sab Whisper ke time pe hai.
Caption sync kit
⬇ caption-sync-kit.zip ~15 KB, MIT licence
Andar kya hai
words.py: awaaz sewords.json(local faster-whisper,--lang hi|en|auto).align.py: tumharicaptions.txtko Whisper ke time se milata hai, gaps khamoshi se bharta hai, report deta hai.karaoke/Karaoke.tsx: Remotion component, bola hua word solid, aage wale grey, ek keyword highlight.PROMPT.md: Claude Code ke liye "meri captions align karo" prompt.README.md: install aur tips.
Install (ek baar)
Python 3.11 ya 3.12 aur ffmpeg chahiye. Zip kholo, us folder mein terminal kholo:
python3.12 -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt
Mac pe ffmpeg: brew install ffmpeg. Pehli baar Whisper model download hota hai (small, ~480 MB), uske baad offline chalta hai.
Chalao
python words.py vo.wav --lang hi --out words.json python align.py --words words.json --captions captions.txt --audio vo.wav
Result: captions.words.json aur report. Hindi voiceover pe --prompt-file captions.txt bhi try karo: Whisper tumhari spelling ke kareeb likhta hai aur zyada words match hote hain. Humare test mein 90% se 97%.
Claude Code se karwao
Apne Remotion project mein Claude Code kholo, kit ka folder paas rakho, aur ye paste karo. Brackets [ ] bharo:
I want my reel captions to sync perfectly with my voiceover, using the caption-sync-kit I downloaded (free, local, no API). MY FILES (fill these in) - Voiceover audio: [path, e.g. public/vo.wav] - Captions text, the exact words I want on screen in spoken order: [path to captions.txt, or paste it here] - Language: [hi, en or auto] - Kit folder: [path to caption-sync-kit] - Keyword(s) to highlight: [e.g. sync, or none] - Karaoke look: [colours, font, or "use my brand file"] WHAT TO DO 1. Read the kit's README.md, words.py, align.py and karaoke/Karaoke.tsx first. 2. Set up the kit: create a venv with python 3.11 or 3.12, run `pip install -r requirements.txt`. Check that ffmpeg exists (`ffmpeg -version`); if not, tell me how to install it. 3. Run words.py on my audio with my language to make words.json. If the language is Hindi or Hinglish, also try it again with `--prompt-file` pointing at my captions.txt, and keep whichever run matches more words. 4. Run align.py with --words, --captions and --audio to make captions.words.json. 5. Read the report. Tell me matched vs filled counts. If fewer than 70 percent matched, stop and check that captions.txt really matches what is spoken (missing or extra words, wrong order) and tell me what you found instead of guessing. 6. For every "Filled stretch", look at its times next to the audio length and the words around it. Fix anything wrong: words stuck in under 0.1 second, words placed over silence, or a gap that is far too long. Fix by editing captions.txt (word count must match what is spoken), changing `--silence-db`, or re-running, not by hand-editing the JSON unless nothing else works. Re-run until the report looks sane. Never change the spoken words to match Whisper's spelling. 7. Copy captions.words.json into my project's public/ folder and karaoke/Karaoke.tsx into src/. Wire <Karaoke> into my scene with my keyword(s) and look. Keep it inside my safe zones (Instagram covers the top, the bottom and the right edge). Set the composition length from the last word's end plus 0.8 seconds. Use my existing brand colours and font, do not hard-code new ones. 8. Run the typecheck, then render a test still with `npx remotion still` at a frame in the middle of a caption chunk, and one near a keyword. Look at the images yourself and fix: text overflow, wrong highlight, low contrast, overlap with other elements. 9. Show me the stills and the final report. Do not render the full video until I say ok. Do not upload my audio anywhere.
PROMPT.md mein bhi hai.Karaoke captions in Remotion
captions.words.json ko public/ mein daalo, Karaoke.tsx ko src/ mein, aur:
import captions from "../public/captions.words.json";
import { Karaoke } from "./Karaoke";
<Karaoke
words={captions}
keywords={["sync"]} // ye word highlight hoga
perChunk={4} // ek baar mein 2 se 5 words
spokenColor="#111111" // bola hua: solid
upcomingColor="#9A9A9A" // aage wale: grey
keywordColor="#FF4D7E"
fontFamily="Baloo 2"
style={{ position: "absolute", bottom: 480, left: 60, right: 140 }}
/>Colours, font, size, background sab props hain, toh apne brand mein fit ho jaata hai. Instagram ke safe zones ke andar rakho (part 3 mein safe zones dekho). Template ka simple word-highlight CaptionStrip bhi part 3 mein hai.
Remotion ka apna licence hai: individuals aur chhoti teams ke liye free, badi company ho toh remotion.dev/license dekh lo.
Series mein aage aa raha hai
- Ek reel ka asli kharcha, aur free mein kaise banaye (part 5)
Miss na ho, isliye follow kar lo 🔔
Ye "AI se video kaise banaye" series ka part 4 hai. Setup nahi kiya? Part 1 se shuru karo. Character chahiye? Part 2. Animation? Part 3.
follow karo @techstackbro 👀