Building a Zero-Upload In-Browser AI Auto Subtitle & SRT/VTT Caption Generator with Whisper WASM & WebGPU
Creators, educators, and software teams generate hours of video every week, yet almost every online subtitle generator either enforces strict 10-minute upload limits, burns watermarks into your footage, or charges per-minute cloud transcription fees.
The reason is simple: uploading raw MP4/MOV video files to a cloud GPU cluster and running Whisper inference server-side creates massive egress bandwidth and GPU compute bills.
At UCDREAMS, we took a zero-server approach for our Free Auto Subtitle Generator (part of the UCDREAMS Tools Hub): demuxing audio, resampling to 16kHz mono PCM, executing Whisper speech-to-text inference, and exporting editable .srt and .vtt caption tracks 100% locally inside the browser.
Here is how the client-side pipeline is architected.
1. Fast Audio Extraction & 16kHz Mono Resampling via OfflineAudioContext
Whisper neural models expect a single-channel (mono) Float32Array sampled at exactly 16,000 Hz. Instead of uploading a 1.5GB 4K video file to extract a 15MB audio track, modern browsers can decode and resample the audio locally in seconds using the Web Audio API:
export async function extractMono16kHzPCM(mediaFile: File): Promise<Float32Array> {
const arrayBuffer = await mediaFile.arrayBuffer();
const probeCtx = new AudioContext();
const decoded = await probeCtx.decodeAudioData(arrayBuffer);
await probeCtx.close();
const targetRate = 16000;
const targetLength = Math.ceil(decoded.duration * targetRate);
const offlineCtx = new OfflineAudioContext(1, targetLength, targetRate);
const source = offlineCtx.createBufferSource();
source.buffer = decoded;
source.connect(offlineCtx.destination);
source.start(0);
const rendered = await offlineCtx.startRendering();
return rendered.getChannelData(0);
}
Because OfflineAudioContext runs faster than real time on a background audio thread, a 10-minute MP4 video typically resamples to 16kHz PCM in under 2 seconds with zero server bandwidth.
2. Sliding-Window Chunking & Word-Level Timestamp Alignment
Running a transformer decoder across a 30-minute audio buffer in one pass would exceed browser WASM heap limits and stall inference. To keep memory flat under 512MB while preserving phrase boundaries, we split the Float32Array into 30-second windows with a 4-second stride overlap and execute inference inside a dedicated Web Worker using WebGPU (with SIMD WebAssembly fallback):
interface SubtitleCue {
index: number;
startSec: number;
endSec: number;
text: string;
}
export function mergeOverlappingCues(
chunks: Array<{ offsetSec: number; segments: Array<{ start: number; end: number; text: string }> }>,
overlapToleranceSec = 0.65
): SubtitleCue[] {
const merged: SubtitleCue[] = [];
for (const chunk of chunks) {
for (const seg of chunk.segments) {
const absStart = chunk.offsetSec + seg.start;
const absEnd = chunk.offsetSec + seg.end;
const cleanText = seg.text.trim();
if (!cleanText) continue;
const prev = merged[merged.length - 1];
if (prev && absStart < prev.endSec - overlapToleranceSec) {
// Drop duplicate phrase captured in the stride overlap window
continue;
}
merged.push({
index: merged.length + 1,
startSec: Math.max(0, absStart),
endSec: Math.max(absStart + 0.25, absEnd),
text: cleanText,
});
}
}
return merged;
}
3. Lossless SubRip (.srt) and WebVTT (.vtt) Serialization
Once users trim or adjust cue timings inside the interactive timeline editor, generating broadcast-ready .srt or HTML5 .vtt caption files takes microseconds:
function formatTimestamp(seconds: number, decimalSep: ',' | '.'): string {
const msTotal = Math.round(seconds * 1000);
const hrs = Math.floor(msTotal / 3_600_000);
const mins = Math.floor((msTotal % 3_600_000) / 60_000);
const secs = Math.floor((msTotal % 60_000) / 1000);
const ms = msTotal % 1000;
const pad = (n: number, w = 2) => String(n).padStart(w, '0');
return `${pad(hrs)}:${pad(mins)}:${pad(secs)}${decimalSep}${pad(ms, 3)}`;
}
export function serializeSRT(cues: SubtitleCue[]): string {
return cues
.map((cue, i) =>
`${i + 1}\n${formatTimestamp(cue.startSec, ',')} --> ${formatTimestamp(cue.endSec, ',')}\n${cue.text}`
)
.join('\n\n') + '\n';
}
Why Client-Side Subtitling Wins
- 100% Privacy for Unreleased Media: Raw podcasts, product demos, and client interviews never leave local browser RAM.
- Instant Timeline Trimming: Pair generated captions with our No-Watermark Video Editor or clean background hiss first with our Free Video & Audio Noise Remover.
-
Zero Usage Caps or Watermarks: Unlimited caption generation and
.srt/.vttexports without sign-up.
4. Try the Live Subtitle Generator & Related Tools
- Launch Auto Subtitle Generator Online (free, zero login)
- Edit or trim footage in Online Video Editor
- Remove background hiss with AI Audio Noise Remover
- Explore 35+ client-side utilities at UCDREAMS Tools or unwind in UCDREAMS Multiplayer Browser Games
Need a custom browser AI workflow, media SaaS web app, or 95+ PageSpeed website? Built by **UCDREAMS Senior Engineers* — explore AI Automation Services, Full-Stack Web App Development, and Custom Website Development, or Book a Free Consultation.*
Top comments (0)