You received a transcript from an ASR system, but the output is raw text without timestamps. Manually timing a one-hour video? That takes longer than the edit itself. And the client requires SRT for YouTube, but you deliver TXT. Familiar? We automate this routine: convert any transcription into standard SRT or VTT subtitles with optimal timing. No manual fixes. Our stack: Faster-Whisper large-v3, VAD filter, post-processing with duration constraints. Sync error — no more than ±0.2 seconds. Automatic SRT and VTT subtitle generation reduces costs 3-5 times compared to manual markup. Contact us for a test on your file.
What problems we solve
Problem 1: Format incompatibility
SRT and VTT are different standards: SRT uses a comma as millisecond separator (00:01:15,400), VTT uses a dot (00:01:15.400). Plus VTT requires the WEBVTT header and supports positioning. A format error — subtitles won't display. Our code handles these nuances automatically.
Problem 2: Long subtitles and too rapid changes
Subtitles longer than 42 characters are hard to read, and segments shorter than 1.2 seconds can't be read. The model might output a 0.5-second segment — we merge them with neighboring ones or enforce a minimum duration.
Problem 3: Lack of broadcast optimization
Our standards: maximum 7 seconds per subtitle, splitting by meaning, no more than two lines. In the optimize_subtitles post-processing step, we automatically trim long lines and adjust timing.
Automatic SRT and VTT subtitle generation: how it works
We use faster-whisper (a fork of OpenAI's Whisper), which runs 4 times faster than the original on CUDA. The large-v3 model achieves a Word Error Rate of 5-7% for Russian.
from faster_whisper import WhisperModel
from datetime import timedelta
model = WhisperModel("large-v3", device="cuda")
def format_time_srt(seconds: float) -> str:
td = timedelta(seconds=seconds)
total_seconds = int(td.total_seconds())
hours = total_seconds // 3600
minutes = (total_seconds % 3600) // 60
secs = total_seconds % 60
milliseconds = int((seconds % 1) * 1000)
return f"{hours:02d}:{minutes:02d}:{secs:02d},{milliseconds:03d}"
def format_time_vtt(seconds: float) -> str:
# VTT uses a dot instead of comma
return format_time_srt(seconds).replace(",", ".")
def generate_srt(audio_path: str, language: str = "ru") -> str:
segments, _ = model.transcribe(
audio_path, language=language, vad_filter=True
)
lines = []
for i, seg in enumerate(segments, 1):
start = format_time_srt(seg.start)
end = format_time_srt(seg.end)
text = seg.text.strip()
lines.append(f"{i}\n{start} --> {end}\n{text}\n")
return "\n".join(lines)
def generate_vtt(audio_path: str, language: str = "ru") -> str:
segments, _ = model.transcribe(
audio_path, language=language, vad_filter=True
)
lines = ["WEBVTT\n"]
for seg in segments:
start = format_time_vtt(seg.start)
end = format_time_vtt(seg.end)
text = seg.text.strip()
lines.append(f"{start} --> {end}\n{text}\n")
return "\n".join(lines)
Why we use Whisper large-v3?
Compared to the base model, large-v3 gives 30% lower Word Error Rate on noisy recordings. We also apply vad_filter=True — a voice activity detection filter that discards silence and noise. This reduces empty subtitles and improves timing.
| Model | WER (Russian) | Speed (RTF on A100) | Size |
|---|---|---|---|
| Whisper base | ~12% | 0.05 | 160 MB |
| Whisper large-v3 | ~6% | 0.12 | 3 GB |
| Faster-Whisper large-v3 | ~6% | 0.03 | 3 GB |
Faster-Whisper uses the CTranslate2 runtime — GPU inference is 4 times faster. For production this is critical: process a one-hour broadcast in 2 minutes instead of 8.
How we optimize subtitles for broadcast
After generation, we apply post-processing:
- Maximum line length — 42 characters (TV standard).
- Maximum subtitle duration — 7 seconds (readability).
- Minimum duration — 1.2 seconds (to avoid flickering).
- Splitting at natural pauses — we look for a space, not just cut by counter.
def optimize_subtitles(segments: list, max_line_length: int = 42,
max_duration: float = 7.0,
min_duration: float = 1.2) -> list:
"""Optimize subtitles for broadcast standards"""
optimized = []
for seg in segments:
duration = seg.end - seg.start
text = seg.text.strip()
# Limit line length
if len(text) > max_line_length:
mid = text.rfind(" ", 0, max_line_length)
text = text[:mid] + "\n" + text[mid+1:]
# Minimum duration
end = max(seg.end, seg.start + min_duration)
optimized.append({**seg.__dict__, "text": text, "end": end})
return optimized
For VTT, we also add positioning: line:90% position:50% align:center — subtitles display at the bottom center. Different styles can be assigned to different speakers.
What is max_duration and why 7 seconds?
According to readability studies, subtitles longer than 7 seconds cause viewer discomfort. If Whisper outputs a 10-second segment, we split it based on pauses. If there are no pauses, we divide by characters equally.
The standard WebVTT defines basic rules, but we add heuristics for optimal perception.
Work process
- Analysis: you send a sample audio/video — we evaluate recording quality, noise presence, number of speakers.
- Design: choose model (Whisper, Wav2Vec2, or custom), configure VAD, determine output format (SRT/VTT), need for styling.
- Implementation: write script or REST API. Cover code with tests. Use Docker for dependency isolation.
- Testing: run on 10-15 files, compare timing with reference. Timing error no more than ±0.2 sec.
- Deployment: deploy on your server or cloud (AWS/GCP). Provide documentation and operator training.
| Stage | What we do | Artifact |
|---|---|---|
| Analysis | Evaluate audio track, choose strategy | Technical specification |
| Development | Write code, integrate | Script/API, Docker image |
| Testing | Check accuracy and performance | Test report |
| Deployment | Deploy, hand over access | Documentation, training |
What's included
- Source code of SRT/VTT generation scripts (Python).
- REST API (FastAPI) with endpoints for audio upload and subtitle download.
- Docker container with all dependencies (CUDA, Whisper, FFmpeg).
- Deployment and operation documentation.
- Training for your engineers on system usage.
- 30 days of support after handover.
Example ffmpeg command to extract audio from video
```bash ffmpeg -i video.mp4 -vn -acodec pcm_s16le -ar 16000 -ac 1 audio.wav ```Timeline and cost
Script generation — from 1 day. REST API service — 2 to 3 days. Exact cost is calculated after analyzing your data and requirements. Write to us — we will evaluate your project for free. Automation reduces subtitle costs by 3-5 times compared to manual markup.
Common mistakes in automatic subtitle generation
- Disabling VAD filter — background noise and pauses end up in subtitles as empty strings.
- Incorrect segment duration — without post-processing, too short (<1 sec) subtitles that cannot be read.
- Ignoring regional encodings — SRT on Windows requires UTF-8 with BOM, otherwise mojibake.
Conclusion
Automatic subtitle generation saves you weeks of manual markup. We use modern ASR models with fine-tuned timing parameters. Guarantee sync accuracy and compliance with broadcast standards. Our engineers have over 5 years of experience in NLP and MLOps. Get a consultation: write to us — we'll show a demo on your file. Contact us, and you'll appreciate the time and budget savings.







