Install the whole backend from one script; queue log; UI fixes

install_comfyui.sh becomes install_backend.sh and now builds everything the app
needs, not just the speech half:

- Step 7 runs normalizer/setup.sh --model, which fetches both models: the open
  inflection model first, so the install gets as far as it can before anything
  can ask for credentials, then the gated fine-tune.
- A missing Hugging Face account is no longer fatal. Accepting a licence is the
  one thing an installer cannot do, so the rest installs, the verification
  reports "fallback only (gated model missing)", and the summary prints the
  three commands that finish it.
- --skip-normalizer, disk requirement 35 -> 55 GB, removal instructions and the
  step list updated to match.

Queue logging — queue.log in the first queued video's job folder, which for a
single-video run is its own:

- Records what went wrong rather than what happened: warnings, tracebacks,
  ffmpeg errors, guard rejections, clips cut off mid-word or that crashed the
  backend, and the --regen line carrying their numbers.
- ComfyUI failures *and* restarts, so the log shows the recovery rather than
  reading as though the run simply stopped. GUI-initiated backend actions go in
  too; they never pass through a job's pipe.
- A failure also dumps the job's last 15 lines. Keyword matching alone is not
  enough — ffmpeg says "Invalid data found when processing input" and nothing
  that looks like an error.

UI:

- The output pane follows new output only while already at the bottom. Scroll up
  and it stays there; scroll back down and it resumes. Reading an earlier
  warning during a run was impossible while every ffmpeg progress frame yanked
  the view to the end.
- The ComfyUI button's status dot is drawn as its own canvas item, so it can be
  green (answering) or amber (holds the port, does not answer). A "." inside the
  label could only ever be the same grey as the words.

comfyui.log is capped at 120,000 lines, trimmed on backend start and every five
minutes. Rewritten in place, never replaced: tee holds it open in append mode,
so swapping the inode would leave the backend writing to an unlinked file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-13 09:48:20 +02:00
co-authored by Claude Opus 5
parent e201aadc3e
commit 97866e6623
8 changed files with 421 additions and 69 deletions
+35 -22
View File
@@ -5,16 +5,17 @@ and the **script** (which needs nothing installed at all).
## Automated install
`install_comfyui.sh` in the project root reproduces the exact working
`install_backend.sh` in the project root reproduces the exact working
environment. It is idempotent — safe to re-run, and it skips any step already
satisfied.
```bash
cd ~/Programy/lektor_ai
./install_comfyui.sh
./install_backend.sh
```
Roughly 30–60 minutes, mostly downloading. Expect ~22 GB.
Roughly 45–90 minutes, almost all of it downloading. Expect ~39 GB: ~22 GB for
the speech backend and ~17 GB for the normalizer's own environment and models.
### Options
@@ -22,14 +23,15 @@ Roughly 30–60 minutes, mostly downloading. Expect ~22 GB.
|---|---|
| *(none)* | Pinned versions — ComfyUI `7cb784e0`, suite `v5.3.0`. Recommended. |
| `--latest` | Newest ComfyUI and suite instead. You are on your own for breakage. |
| `--skip-model` | Skip the 8.7 GB download; it happens on first generation anyway. |
| `--skip-model` | Skip the 8.7 GB TTS download; it happens on first generation anyway. |
| `--skip-normalizer` | ComfyUI only. Digits then reach the TTS as digits, which it misreads. |
| `--lock FILE` | Restore an exact package set from a `pip freeze` lockfile. |
| `--help` | Usage summary. |
### Changing where things go
```bash
CONDA_ROOT=/opt/miniforge3 COMFY_ROOT=/data/comfy ./install_comfyui.sh
CONDA_ROOT=/opt/miniforge3 COMFY_ROOT=/data/comfy ./install_backend.sh
```
| Variable | Default |
@@ -49,7 +51,7 @@ see [Configuring the script](#configuring-the-script).
byte-identical environment:
```bash
./install_comfyui.sh --lock comfyui-requirements.lock.txt
./install_backend.sh --lock comfyui-requirements.lock.txt
```
Regenerate it after intentional changes:
@@ -78,9 +80,13 @@ its own.
pip install (see [requirements.md](requirements.md#dependency-surface)).
7. **Model** — `bosonai/higgs-audio-v3-tts-4b` into
`ComfyUI/models/TTS/higgs_audio_v3/`.
8. **Launcher** written to `$COMFY_ROOT/start_comfyui.sh`.
9. **Verification** — imports torch, torchaudio, transformers, safetensors,
soundfile, librosa and reports CUDA availability.
8. **Number normalizer** — `normalizer/setup.sh --model`: its own venv with
`transformers>=5`, the open inflection model, and the gated fine-tune if you
have credentials. Failure here is reported, not fatal.
9. **Launcher** written to `$COMFY_ROOT/start_comfyui.sh`.
10. **Verification** — imports torch, torchaudio, transformers, safetensors,
soundfile, librosa, reports CUDA availability, and prints whether the
normalizer came up neural or on the fallback.
## Manual install
@@ -184,25 +190,32 @@ conda install -n comfy-tts -c conda-forge ffmpeg
Note that this puts ffmpeg inside the conda env, so the script must then be run
with that env active.
## Number normalizer (optional, recommended)
## Number normalizer
Digits reach the TTS as words rather than figures, in the correct Polish case.
It has its own venv on purpose — the model needs `transformers >= 5`, which must
not be forced on the ComfyUI environment installed above.
`install_backend.sh` installs this too — its own venv, the 8 GB inflection
model, and the 1.1 GB fine-tune. Nothing further is needed unless the script
says otherwise.
It gets its own venv on purpose: it needs `transformers >= 5`, which must not be
forced on the ComfyUI environment installed above. They talk over a pipe.
**The one thing the installer cannot do for you** is accept a licence. The
fine-tune is gated, so if you have no Hugging Face credentials the script
installs everything else, reports `fallback only (gated model missing)`, and
prints these three steps:
```bash
cd ~/Programy/lektor_ai
normalizer/setup.sh # venv + torch (cu128) + transformers
HF_TOKEN=hf_... normalizer/setup.sh --model # the weights, ~1.1 GB
# 1. accept the terms while signed in:
# https://huggingface.co/Folx/qwen3-0.6b-pl-text-normalization
normalizer/venv/bin/hf auth login
normalizer/setup.sh --model
```
The weights are gated: accept the terms at
<https://huggingface.co/Folx/qwen3-0.6b-pl-text-normalization> while signed in,
then take a token from <https://huggingface.co/settings/tokens>. This is the only
step that touches the network; runs are offline afterwards.
`HF_TOKEN=hf_...` in the environment works instead of `hf auth login`, and the
installer picks up either automatically if you set it up beforehand.
Skipping this is fine — the pipeline falls back to `num2words` (nominative case
only) and says so. Turn the whole stage off with `numbers = no` under
Until then the pipeline runs with `num2words` for times, dates and identifiers,
and says so on every run. Turn the stage off entirely with `numbers = no` under
`[normalize]` in `settings.ini`. See [normalizer/README.md](../normalizer/README.md).
## Verifying
+49
View File
@@ -479,6 +479,48 @@ that takes longer than `timeout` — each is a warning, and the affected text go
to the TTS with its digits intact. The worker is started once per run and exits
before TTS generation begins, so it is not holding VRAM while Higgs works.
## The output pane
It follows the newest output only while you are already at the bottom. Scroll
up and it stays where you put it, however much arrives in the meantime; scroll
back down and it resumes following. There is nothing to click either way.
That matters during a run, where output lands several times a second and ffmpeg
redraws its progress bar continuously — scrolling back to read an earlier
warning was impossible while every frame yanked the view to the end.
## The queue log
Every GUI run writes `queue.log` into the **first queued video's job folder** —
which for a single-video run is simply its own. It records what went wrong, not
what happened: the output pane already carries every clip and placement, and
none of that helps at 8 a.m. when you want to know why a queue stopped.
```
===== queue started 2026-08-13 09:09:17 — 2 job(s) =====
09:09:17 --- generate: good.mkv
09:09:17 ComfyUI unreachable (<urlopen error [Errno 111] Connection refused>) [1/3 for this clip].
09:09:48 finished OK
09:09:48 --- generate: bad.mkv
09:10:04 ffmpeg error (Mixing lektor audio track):
09:10:04 /dev/null: Invalid data found when processing input
09:10:04 FAILED with exit code 1 — 0 job(s) cancelled
09:10:04 last 15 line(s) before it stopped:
09:10:04 | …
```
Each job is bracketed by a start line and its outcome. In between go the lines
that report a problem — warnings, tracebacks, ffmpeg errors, guard rejections,
clips that crashed the backend or came back cut off mid-word.
**A failure also dumps the job's last 15 lines.** Keyword matching alone is not
enough: ffmpeg says *"Invalid data found when processing input"* and nothing
that looks like an error, so an exit code would otherwise be recorded with no
explanation.
The file is appended to, never truncated, so it is a record across runs and a
crash cannot cost you the previous session.
## The backend's lifecycle
ComfyUI is normally started once and left running. The script manages it when it
@@ -496,6 +538,13 @@ has to:
Its output goes to `comfyui.log` next to the script as well as to the terminal
window, so a crash can be diagnosed after the fact.
That file is **capped at 120,000 lines** (roughly 10 MB). Past that the oldest
lines are dropped, on backend start and every five minutes while the GUI is
open. It is trimmed in place rather than rotated: there is one file to look at
after a crash, no `.1`/`.2` to hunt through, and rewriting in place is also what
keeps `tee` writing to it — replacing the file would leave the backend appending
to an unlinked inode and every later line would vanish.
The GUI has a **ComfyUI** button showing the same state: `Start ComfyUI` when it
is down, `ComfyUI ●` when it is answering, `ComfyUI ◍` when it holds the port but
does not answer. Pressing it starts or restarts.