lai alignment
Align audio/video with captions using the CLI
lai alignment
The lai alignment command aligns audio/video files with captions.
Commands
| Command | Description |
|---|---|
lai alignment align | Align local audio/video with caption |
lai alignment youtube | Download & align YouTube content |
lai alignment align
Align a local audio or video file with an existing caption file.
lai alignment align <audio> <caption> <output>Arguments
| Argument | Description |
|---|---|
audio | Path to audio or video file |
caption | Path to input caption file (SRT, VTT, etc.) |
output | Path for aligned output file |
Options
| Option | Description | Default |
|---|---|---|
alignment.device | Processing device (cpu, cuda, mps) | cpu |
caption.split_sentence | Enable smart sentence splitting | false |
caption.word_level | Enable word-level timestamps | false |
media.channel_selector | Audio channel (left, right, average) | average |
media.streaming_chunk_secs | Chunk size for streaming (1-1800 seconds) | 600 |
Examples
Basic alignment:
lai alignment align audio.wav caption.srt output.srtWith GPU acceleration:
lai alignment align video.mp4 caption.vtt output.srt alignment.device=cudaWith sentence splitting and word-level timestamps:
lai alignment align audio.wav caption.srt output.json \
caption.split_sentence=true \
caption.word_level=trueLong audio with streaming:
lai alignment align long_audio.wav subtitle.srt output.srt \
media.streaming_chunk_secs=300.0lai alignment youtube
Download a YouTube video and align it with auto-downloaded subtitles.
lai alignment youtube <url>Arguments
| Argument | Description |
|---|---|
url | YouTube video URL |
Options
| Option | Description | Default |
|---|---|---|
media.output_dir | Directory for downloaded files | Current directory |
caption.output_path | Path for aligned output | aligned.srt |
caption.split_sentence | Enable smart sentence splitting | false |
media.streaming_chunk_secs | Chunk size for streaming | 600 |
Examples
Basic YouTube alignment:
lai alignment youtube "https://youtube.com/watch?v=VIDEO_ID"With custom output directory:
lai alignment youtube "https://youtube.com/watch?v=VIDEO_ID" \
media.output_dir=~/Downloads \
caption.output_path=aligned.srt \
caption.split_sentence=trueOutput Formats
The output format is determined by the file extension:
| Extension | Format |
|---|---|
.srt | SubRip |
.vtt | WebVTT |
.ass | Advanced SubStation Alpha |
.json | JSON (preserves word-level data) |
.txt | Plain text |
.ttml | TTML (broadcast) |
.xml | FCPXML, Premiere XML, Avid DS |