# Usage ComfyUI must be running before any command that generates speech (`~/comfy-tts-app/start_comfyui.sh`). `--rebuild` is the exception — it only touches ffmpeg and works with the backend stopped. ## Invocation ``` python3 lektor_ai_comfy.py [SRT] VIDEO [options] ``` Both positionals are optional in the argparse sense, because several modes do not need an SRT file. The rule: ```bash # External subtitle file — pass both, SRT first python3 lektor_ai_comfy.py input/film.pl.srt input/film.mkv # Subtitles inside the video — pass the video alone python3 lektor_ai_comfy.py input/film.mkv --embedded-subs # --rebuild and --regen also need only the video python3 lektor_ai_comfy.py input/film.mkv --rebuild ``` When a single positional is given in a mode that needs no SRT, the script moves it into the video slot automatically. Always quote paths containing spaces or parentheses: ```bash python3 lektor_ai_comfy.py "input/Star City (2026)/S01_E01 The Eyes.mkv" --embedded-subs ``` ## Working modes ### Full generation (default) Parses subtitles, generates one TTS clip per block, assembles, muxes. ```bash python3 lektor_ai_comfy.py input/film.mkv --embedded-subs ``` Roughly real-time-ish on a 4070 Ti SUPER: a 60-minute episode of ~700 subtitle blocks takes on the order of an hour. Each clip is saved as it completes, so a crash never loses more than the clip in flight. ### `--embedded-subs` Lists the video's subtitle tracks and prompts for one: ``` Available subtitle tracks in S01_E01 The Eyes.mkv: [1] Stream #2: subrip [eng] — Forced [2] Stream #3: subrip [eng] [3] Stream #4: subrip [eng] — SDH ... [30] Stream #31: subrip [pol] Select track number: 30 ``` The chosen track is extracted to `embedded_sub.srt` in the job folder and processed exactly like an external file. Image-based tracks are listed but marked unusable — they hold bitmaps, not text. ### `--rebuild` Reassembles audio from existing clips and rebuilds the video, with no TTS at all. This is the fast iteration loop — seconds to minutes rather than an hour. ```bash python3 lektor_ai_comfy.py input/film.mkv --rebuild python3 lektor_ai_comfy.py input/film.mkv --rebuild --orig-volume 0.5 --tts-volume 2.0 ``` Use it after `--regen`, or to adjust the mix. It reads that video's job folder (`output/clips/