ddidderr f8e50e4a3e fix(subtitles): tolerate regressing word timestamps
SRT conversion previously rejected otherwise valid word timestamps when a
start preceded the previous word's start. Clamp regressing starts to the
preceding nonempty word's start and extend ends only when necessary.
Preserve transcript order and the original response while continuing to
reject malformed timestamps. Document the adjustment and cover regressions,
cue boundaries, blank words, and invalid input.

Test Plan:
- python3 -B -m unittest -v: all eight tests passed.
- CLI conversion of a synthetic regressing response: passed.
- git diff --cached --check: passed.
- Actual recording verification blocked by unavailable 1Password auth.
2026-09-05 16:27:03 +02:00

Transcribe

Requires Bash, FFmpeg, curl, jq, and standard coreutils; --srt also requires Python 3 and the accompanying subtitles.py file.

./transcribe recording.m4a
./transcribe video.mp4 > transcript.txt
./transcribe --srt video.mp4 > subtitles.srt

Accepts m4a, mp4, aac, flac, opus, mp3, ogg, wav, and other formats your FFmpeg supports. Uses the first audio track, converts it to mono 16 kHz MP3 at 64 kbps (requires FFmpeg's libmp3lame encoder), and sends it to OpenRouter's microsoft/mai-transcribe-2 model. Temporary files are removed on exit. The transcript goes to stdout; errors to stderr.

--srt requests word timestamps using OpenRouter's verbose_json response. Words are grouped into cues of at most two lines (42 characters per line, except an unusually long unbroken word) and six seconds. Cues also break at sentence endings, pauses of at least 0.7 seconds, and speaker changes when speaker labels are available. Timing comes from the words, rounded to milliseconds. If word start times move backwards, they are clamped to the preceding word's start without reordering the transcript; end times are extended to the adjusted start only when needed. Subtitle output goes to stdout; missing or invalid word timestamps produce an error. Without --srt, output remains plain text.

One file per invocation; the whole recording is sent in one request, so the service's audio length and request size limits apply.

OpenRouter model and API reference

S
Description
No description provided
Readme
52 KiB
Languages
Python 78.7%
Shell 21.3%