Add a standalone script that uses WhisperX to align text transcripts
with audio and export SRT subtitle files.
Features:
- Loads audio and text files
- Uses WhisperX forced alignment to get word-level timestamps
- Groups words into subtitle lines based on:
- Punctuation marks (,。!?;、,.!?;…)
- Maximum duration (default 4.5 seconds)
- Maximum character count (default 28 characters)
- Exports to SRT format using pysubs2
Usage:
python scripts/align_audio/align_to_srt.py -a audio.wav -t text.txt -o output.srt
Options:
--audio, -a: Input audio file path
--text, -t: Input text file path (UTF-8)
--output, -o: Output SRT file path
--language, -l: Language code (default: zh)
--device, -d: Device to use (auto/cuda/cpu)
--max-sec: Max subtitle duration in seconds (default: 4.5)
--max-ch: Max characters per subtitle line (default: 28)
--punct: Punctuation marks that trigger line breaks
Note: This script uses whisperx.load_align_model() which downloads
models automatically from HuggingFace. For ComfyUI node usage,
models should be placed in ComfyUI/models/whisperx/ instead.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>