New Tool Radar

Local AI

How to Export SRT and VTT Subtitles from faster-whisper

Save faster-whisper output as SRT and VTT subtitle files with timestamps.

Schematic illustration with three step boxes: Transcribe the audio; Choose the output format; Open the subtitle files.

A plain transcript has no timing, which is not enough for subtitles. faster-whisper can write the segments with timestamps in several formats, and the output_format setting picks them: “all” writes text, SRT, VTT, TSV and JSON in one run. This guide produces SRT and VTT files and checks them in a video player.

Before you start

  • Python with faster-whisper installed.
  • An audio or video file to subtitle, a few minutes long.
  • A video player or subtitle editor that can open SRT and VTT files.

Transcribe the file

Run the transcription and keep the segments:

from faster_whisper import WhisperModel
model = WhisperModel("base", device="cpu", compute_type="int8")
segments, info = model.transcribe("talk.wav", language="en")
segments = list(segments)

Each segment carries a start time, an end time and the text.

Write the subtitle files

Write the segments out in both formats. The simplest way is output_format=”all” in the transcribe call, which writes clip.txt, clip.srt, clip.vtt, clip.tsv and clip.json next to the audio. Or write the files yourself from the segment list, one numbered block per segment for SRT and one timestamped cue per segment for VTT.

Open both files

Open clip.srt in a video player with the audio, and open clip.vtt in a browser or subtitle editor. Each subtitle should appear at the time its words are spoken, and no subtitle should overlap the next one.

Worked example

Worked example: a 3-minute talk. The SRT file should have roughly 30 to 40 numbered blocks, each with a start and end time and one or two lines of text, and the VTT file should have the same cues with a WEBVTT header at the top. Play the audio with the SRT loaded and check that the first three subtitles match the spoken words.

Expected result

UNTESTED in this guide: no transcription was run while writing it. The expected result is that clip.srt and clip.vtt are written, each subtitle appears at the right time, and the first three cues match the spoken words.

Limitations

Subtitle timing comes from the segment boundaries, so a long segment can stay on screen too long. If a cue is too long to read, split it by hand or use shorter segments in the transcription call.

Sources

See all