New Tool Radar

Local Speech & Transcription

How to Control Subtitle Segment Length in whisper.cpp

Set --max-len in whisper.cpp so each subtitle segment stays short enough to read, and get word-level timestamps with -ml 1.

Schematic diagram with four steps: run whisper-cli with -ml 40, check the segment lengths in the output, confirm the subtitles read well, then try -ml 1 for word-level segments.

Long transcription segments make unreadable subtitles: a single segment that runs for a minute is useless on screen. whisper.cpp has an experimental section for controlling the length of the generated text segments, built around the --max-len argument.

Set the maximum segment length

Add --max-len (or -ml) to the whisper-cli command with the length you want, in characters: for example -ml 40 caps segments at about 40 characters. The README notes the same argument is used to obtain word-level timestamps — simply use -ml 1 for per-word segments. Shorter segments mean more segments, so pick a length that reads well on screen rather than the shortest possible.

./build/bin/whisper-cli -m models/ggml-base.en.bin -f samples/jfk.wav -ml 40
# word-level timestamps: -ml 1

The segment-length controls are experimental, so expect them to behave differently across versions: a length that works in one release may split differently in the next. Check the output on a short sample before running a long recording.

Try it: four checks

Check What you should see If you do not see it
Flag accepted The command runs with -ml Check the flag spelling
Segments shorter Each segment is near the set length Check the output file
Subtitles readable Segments fit on screen Try 40 characters first
Word mode works -ml 1 gives word-level segments That is the documented use

Expected result. We checked the whisper.cpp README, which has an experimental section on controlling the length of the generated text segments and says the –max-len argument can be used to obtain word-level timestamps with -ml 1. We did not transcribe audio on this machine.

Limits

This guide covers the segment-length flag only. The controls are experimental and can change between versions. We did not test any transcription ourselves.

Sources

See all