AI-Video-Assistant: A Complete Video-to-Notes Pipeline in 36KB of Python
One recording, four different chunk sizes, two transcription engines, and a chat interface. A single-author prototype makes every decision in a modern video-to-LLM stack visible.
- A single recording is sliced four different ways (10-minute transcription chunks, 25-second API pieces, 3,000-character summarization windows, 500-character retrieval windows) because each consumer in the pipeline wants a different resolution.
- Transcription is routed by a user-picked language flag rather than by detecting the audio, and the Sarvam path bundles translation into transcription so the LLM always sees English.
- The retrieval chain is a compact LCEL dict fan-out with a hard grounding prompt and an explicit refusal sentence, which constrains hallucination but does not verify it.
- The most instructive parts of the repo are its bugs: a dormant TypeError and a shared Chroma collection mark exactly where a working demo stops being a working system.
One Recording, Four Different Rulers
Point AI-Video-Assistant- at a YouTube URL or a local video file, choose a language, and it hands back a transcript, a title, a summary, action items, key decisions, open questions, and a chat box you can interrogate about what was said. Six pipeline stages, two speech engines, one LLM, roughly 36 kilobytes of Python.
The interesting part is not the output. It is what happens to the audio on the way through.
A single recording gets sliced four separate times, at four separate scales, and each slice exists for a different consumer:
- 10-minute WAV chunks are the transcription unit. They are written to disk so a failed run can be inspected after the fact.
- 25-second pieces are the unit the Sarvam API will actually accept, because its upload endpoint caps requests at 30 seconds.
- 3,000-character chunks with 200 characters of overlap are the summarization unit. Long enough to hold a coherent argument.
- 500-character chunks with 50 characters of overlap are the retrieval unit. Short enough to match a question precisely.
That asymmetry is the mental key to the whole repo. Summarization wants context; retrieval wants precision; the transcription API wants whatever fits under its limit. Rather than pick one chunk size and live with the compromise, the author picked four and let each stage do its own cutting. Few small projects make that distinction explicit, and once you see it, every other decision in the codebase reads as a consequence.
The Whole Pipeline Fits in 36KB
Zoom out and the flow is a straight line. Ingest the audio, transcribe it, generate a title and a summary and three structured extractions, index the transcript, then chat over it. Nothing is streamed, cached, or resumed. Any failure mid-pipeline discards everything before it.
- Ingest. yt-dlp pulls YouTube audio; pydub and FFmpeg convert everything else to mono 16 kHz WAV, the sample rate Whisper expects internally.
- Chunk. The WAV is cut into 10-minute files on disk.
- Transcribe. Each chunk goes to Whisper locally or to Sarvam's speech-to-text-translate endpoint.
- Generate. One call for a title (first 2,000 characters only), a map-reduce summary, and three independent extraction calls for action items, decisions, and open questions.
- Index. The transcript is re-cut into 500-character documents, embedded with all-MiniLM-L6-v2 on CPU, and persisted to ChromaDB.
- Chat. A LangChain LCEL chain retrieves context and answers questions against it.
The directory split follows the pipeline, not the layers. utils/ holds media handling and core/ holds the AI stages, and each module in core/ defines its own get_llm() rather than importing a shared factory. That is organic growth, not upfront abstraction, and it is the first honest hint that this was built stage by stage rather than designed in one sitting.
Small code has a real advantage here. In a hosted meeting-notes product, the chunk sizes, the language routing, the API constraint handling, and the grounding prompt are all hidden behind a subscription. In this repo they are sitting in six files you can read in an afternoon.
Two Engines, Picked by a Language Flag
The transcription router is the most load-bearing design decision in the repo, and it is one line long. If the language argument is hinglish, the chunk goes to Sarvam. Everything else goes to Whisper.
The routing is a product decision wearing technical clothes. The user declares the language. The code never inspects the audio to decide. That is deliberate: language detection on short chunks is unreliable, and a wrong guess silently sends the whole meeting down the wrong path. Asking the user is cheaper and more predictable.
The two paths are also not symmetric, and that asymmetry ripples downstream. Whisper transcribes in the spoken language, so a Hinglish recording processed through Whisper would come out as mixed-script text the LLM then has to reason about. Sarvam's translate endpoint returns English no matter what went in. On that path, every later stage (summary, extraction, retrieval, chat) operates on English, which simplifies all of them.
| Whisper path | Sarvam path | |
|---|---|---|
| Selected when the user picks | english | hinglish |
| Where it runs | Locally, on your machine | Hosted REST API |
| Model | openai-whisper, small by default | saaras:v2.5 by default |
| Output language | The spoken language | English, via the translate endpoint |
| Upload limit | None | 30 seconds per request |
| Cost | Free after the one-time model download | Per-request API billing |
| Speaker labels | Off | Off, with_diarization set to false |
Whisper loads once per process through a module-level global, which is the right instinct for a heavyweight model. It is also the only place the codebase makes any attempt at resource reuse.
The 25-Second Rule
Sarvam's upload endpoint will not accept a file longer than 30 seconds. The 10-minute chunks that feed it are six times over that limit, so transcribe_chunk_sarvam has to slice again, in-process, before every single request.
SARVAM_PIECE_SECONDS = 25 # 30s API cap minus a 5s safety margin
for i, start in enumerate(range(0, len(audio), SARVAM_PIECE_SECONDS * 1000)):
piece = audio[start:start + SARVAM_PIECE_SECONDS * 1000]
piece_path = f"temp_piece_{i}.wav"
try:
piece.export(piece_path, format="wav")
# POST piece_path to Sarvam speech-to-text-translate
finally:
if os.path.exists(piece_path):
os.remove(piece_path)
This is the most careful code in the repository. It respects a hard external limit, it writes each piece to a temporary file and deletes it in a finally block so a network failure does not leave junk behind, and it reports progress per piece so a long transcript does not look hung. The five-second margin is a boundary-aware choice: 25 seconds, not 29, because you do not want to discover the exact edge of someone else's API in production.
The honest critique is that the two numbers were chosen independently and never reconciled. The 10-minute chunk size comes from the audio processor, which knows nothing about Sarvam. The 25-second piece size comes from the transcriber, which knows nothing about the 10-minute chunks. They happen to nest cleanly, but nothing in the code enforces that, and nothing adds overlap between adjacent pieces. A word landing on a cut boundary gets mangled, and no later stage can recover it.
How the Chat Chain Is Wired
The second half of the pipeline is retrieval. The transcript is re-cut into 500-character documents, each wrapped with a chunk_index in its metadata, embedded locally, and stored in Chroma. The chain itself is four lines of LangChain Expression Language:
chain = (
{"context": retriever | RunnableLambda(format_docs),
"question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
Read it left to right and it is a fan-out. The retriever fetches relevant passages and formats them into a string; the passthrough forwards the raw question untouched. Both run, both land in a dictionary, and that dictionary feeds the prompt. It is the same retrieval-augmented pattern most tutorials spread across thirty lines, expressed as a single graph.
The prompt is where the design intent shows. It instructs the model to answer based ONLY on the meeting transcript context, and it supplies an exact fallback sentence for when the answer is not there. That is a deliberate anti-hallucination choice: give the model a sanctioned way to say "I don't know" rather than letting it improvise. It constrains the model, though it does not verify it. Nothing checks whether the answer actually came from the retrieved context.
One detail is stored but never used. Every document carries a chunk_index, which is exactly what you would need to cite a passage back to a position in the transcript. The metadata is written and then ignored. Source attribution in answers is the obvious next step and it is one wiring change away.
Where the Prototype Breaks
This is a learning-stage project, and the gaps are as instructive as the working parts. Four of them are concrete.
- A dormant TypeError.
load_rag_chaincallsget_retriever()with no arguments, butget_retrieverrequires the vector store as its first parameter. Calling it raises immediately. Nothing calls it, so the bug has never fired. It was written for a persistence-across-sessions feature that either got abandoned or never got finished. - Every meeting shares one collection.
build_vector_storewrites to a fixed collection name in a fixed directory. Process a second meeting and its chunks land alongside the first, so retrieval can return passages from a different conversation entirely. For a single-meeting demo this never shows up. For real use it is a correctness bug, not a rough edge. - No timestamps, no speaker labels.
transcribe_allconcatenates every chunk into one undifferentiated string. Sarvam's diarization flag is set to false, so that was considered and turned off. The result is a transcript you cannot navigate and cannot attribute. - No retries, no parallelism, no resumption. Transcription is sequential and synchronous. A failure on chunk seven of ten means the first six are gone and you start over.
None of these are gotchas to dunk on. They are the exact places where a working demo becomes a working system: idempotent storage, resumable stages, retry logic, and enough provenance in the data to answer "where did this come from." Naming them is more useful than pretending the prototype is finished.
Where It Fits
As a product, AI-Video-Assistant does not compete with hosted meeting-notes tools. It has no README, no license, no tests, and no verified users beyond a single contributor. Its star-to-fork ratio reads more like classroom cloning than adoption.
As a reference implementation, it is genuinely useful. It is one of the few places where a complete video-to-notes stack is small enough to hold in your head. The re-slicing model, the language routing, the API constraint handling, and the LCEL chain are all here in a form you can read, run, and disagree with.
The privacy story is partial and worth stating plainly. Whisper, the embedding model, and the vector store all run locally. But every summarization and extraction call ships the full transcript to Mistral, and the Sarvam path ships the audio to a third party. For meeting content, that is the trade-off that actually matters, and it is made visible here rather than buried in a terms of service.
This is what a portfolio project looks like when someone actually built the thing instead of describing it. It runs. It has bugs. And every decision in it is still legible.





