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.

8 min read • View on GitHub • More from AkarshVyas

A wide editorial illustration of a single long magnetic tape feeding into a mechanical sorting table, where four combs with visibly different tooth spacing sift the same ribbon into four separate piles. The image illustrates the central idea of the article: one recording is re-sliced at four different scales, each scale feeding a different consumer in the pipeline.
One recording, four rulers. The same audio is cut into 10-minute transcription chunks, 25-second API pieces, 3,000-character summarization windows, and 500-character retrieval windows.
Key Takeaways

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:

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 re-slicing machine. Every stage cuts the same audio to its own ruler, and the four cuts never have to agree with each other.

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.

  1. Ingest. yt-dlp pulls YouTube audio; pydub and FFmpeg convert everything else to mono 16 kHz WAV, the sample rate Whisper expects internally.
  2. Chunk. The WAV is cut into 10-minute files on disk.
  3. Transcribe. Each chunk goes to Whisper locally or to Sarvam's speech-to-text-translate endpoint.
  4. 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.
  5. Index. The transcript is re-cut into 500-character documents, embedded with all-MiniLM-L6-v2 on CPU, and persisted to ChromaDB.
  6. 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 pathSarvam path
Selected when the user picksenglishhinglish
Where it runsLocally, on your machineHosted REST API
Modelopenai-whisper, small by defaultsaaras:v2.5 by default
Output languageThe spoken languageEnglish, via the translate endpoint
Upload limitNone30 seconds per request
CostFree after the one-time model downloadPer-request API billing
Speaker labelsOffOff, 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.

A close-up editorial illustration of a steel blade descending onto a strip of magnetic tape, cutting it into short segments. Between each cut segment there is a visible loss of a few characters of printed waveform that straddle the blade line, and the cut pieces sit side by side with no overlap. The image illustrates the article's critique that the 25-second Sarvam slices have no overlap, so words landing on a boundary get mangled.
The 25-second cuts have no overlap. Any word straddling a blade line is lost to both pieces, which is a real cost of respecting the API cap the simple way.

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.

  1. A dormant TypeError. load_rag_chain calls get_retriever() with no arguments, but get_retriever requires 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.
  2. Every meeting shares one collection. build_vector_store writes 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.
  3. No timestamps, no speaker labels. transcribe_all concatenates 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.
  4. 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.