30 lines
1.3 KiB
Markdown
30 lines
1.3 KiB
Markdown
# Transcribe
|
|
|
|
Requires Bash, FFmpeg, curl, jq, and standard coreutils; `--srt` also requires
|
|
Python 3 and the accompanying `subtitles.py` file.
|
|
|
|
```sh
|
|
./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. 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](https://openrouter.ai/microsoft/mai-transcribe-2)
|