Whisper on RTSP audio
Three prototypes that turn an IP camera's RTSP audio into live Russian text with Whisper — cloud, whisper.cpp and CTranslate2
A two-day experiment in live speech-to-text from a security camera's audio stream.
A two-day experiment in live speech-to-text from a security camera's audio stream.
Three variants share the same ffmpeg-based RTSP ingestion: a .NET 9 console app posting WAV chunks to the OpenAI transcription API with a rolling context prompt, an offline .NET variant driving a local whisper.cpp CLI, and a multithreaded C++ pipeline (ring buffer, energy VAD, utterance buffering, partial/final transcript stabiliser) that talks to a persistent faster-whisper/CTranslate2 Python worker over stdin/stdout.
What it does
- ffmpeg subprocess ingests RTSP audio and segments it into 15-second 16 kHz mono WAV chunks (or raw PCM for the C++ variant)
- Cloud path: POST /v1/audio/transcriptions (whisper-1) with language hint and a rolling prompt built from previous transcripts for continuity
- Offline path A: spawns whisper-cli.exe from whisper.cpp with a local ggml model, thread/GPU flags
- Offline path B (C++): RingBuffer + RMS energy VAD + utterance windowing, persistent Python ASR worker loaded once, base64 tab-separated request/response protocol, ready-file handshake
- TranscriptStabilizer emits [PARTIAL] updates and commits [FINAL] text; console output on its own thread
- All configuration via CLI args / environment variables (RTSP URL, ffmpeg path, model, language, chunk size)
Compares three ASR deployment strategies (cloud API, whisper.cpp CLI, CTranslate2 via faster-whisper) behind one ingestion design. The C++ variant shows a proper streaming architecture: thread-safe queues, VAD-gated utterance buffer, partial/final stabilisation, and a long-lived model process instead of per-chunk spawn. Small and unpolished (prototype quality, credentials baked into defaults).
Want something like this?
I build it live on a Zoom call, you watch the screen, the timer stops when you say stop. First 15 minutes are free.